sysGrainDao.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="cn.ourwill.module.sys.dao.sysGrainDao">
  4. <resultMap type="cn.ourwill.module.sys.entity.SysGrain" id="baseMap">
  5. <result column="id" property="id"/>
  6. <result column="name" property="name"/>
  7. <result column="uuid" property="uuid"/>
  8. <result column="version" property="version"/>
  9. <result column="parentId" property="parentId"/>
  10. <result column="c_id" property="cId"/>
  11. <result column="u_id" property="uId"/>
  12. <result column="c_time" property="cTime"/>
  13. <result column="u_time" property="uTime"/>
  14. <result column="pic" property="pic"/>
  15. <result column="ename" property="ename"/>
  16. <result column="grain_describe" property="grainDescribe"/>
  17. <result column="type" property="type"/>
  18. <result column="gno" property="gno"/>
  19. <result column="idkey" property="idKey"/>
  20. </resultMap>
  21. <sql id="columns">
  22. id ,
  23. `name` ,
  24. uuid ,
  25. version ,
  26. parentId ,
  27. c_id ,
  28. u_id ,
  29. c_time ,
  30. u_time ,
  31. pic,
  32. ename,
  33. grain_describe,
  34. type,
  35. gno
  36. </sql>
  37. <sql id="columnnew">
  38. id ,
  39. `name`
  40. </sql>
  41. <sql id="joinCols">
  42. </sql>
  43. <select id="get" resultMap="baseMap">
  44. SELECT
  45. <include refid="columns"/>
  46. FROM sys_grain a
  47. <include refid="joinCols"/>
  48. WHERE a.id = #{id}
  49. </select>
  50. <select id="getByEname" resultMap="baseMap">
  51. SELECT
  52. <include refid="columns"/>
  53. FROM sys_grain a
  54. <include refid="joinCols"/>
  55. WHERE a.ename = #{ename}
  56. </select>
  57. <select id="getByGno" resultMap="baseMap">
  58. SELECT
  59. <include refid="columns"/>
  60. FROM sys_grain a
  61. <include refid="joinCols"/>
  62. WHERE a.gno like "%"#{gno}"%" and a.gno is not null
  63. </select>
  64. <select id="getByParentCon" resultMap="baseMap">
  65. SELECT
  66. <include refid="columns"/>
  67. FROM sys_grain a
  68. <include refid="joinCols"/>
  69. WHERE a.gno like "%"#{gno}"%" and a.id = #{id}
  70. </select>
  71. <select id="getGrainIdByGrainName" resultMap="baseMap">
  72. SELECT
  73. <include refid="columns"/>
  74. FROM sys_grain a
  75. <include refid="joinCols"/>
  76. WHERE a.name = #{name}
  77. </select>
  78. <select id="findList" resultMap="baseMap">
  79. SELECT
  80. <include refid="columns"/>
  81. FROM sys_grain a
  82. <include refid="joinCols"/>
  83. <where>
  84. <if test="id !=null">
  85. and id = #{id}
  86. </if>
  87. <if test="name !=null">
  88. and `name` = #{name}
  89. </if>
  90. <if test="uuid !=null">
  91. and uuid = #{uuid}
  92. </if>
  93. <if test="version !=null">
  94. and version = #{version}
  95. </if>
  96. <if test="parentId !=null">
  97. and parentId = #{parentId}
  98. </if>
  99. <if test="cId !=null">
  100. and c_id = #{cId}
  101. </if>
  102. <if test="uId !=null">
  103. and u_id = #{uId}
  104. </if>
  105. <if test="cTime !=null">
  106. and c_time = #{cTime}
  107. </if>
  108. <if test="uTime !=null">
  109. and u_time = #{uTime}
  110. </if>
  111. <if test="pic !=null">
  112. and pic = #{pic}
  113. </if>
  114. <if test="grainDescribe !=null">
  115. and grain_Describe = #{grainDescribe}
  116. </if>
  117. <if test="type !=null">
  118. and type = #{type}
  119. </if>
  120. <if test="gno !=null">
  121. and gno = #{gno}
  122. </if>
  123. </where>
  124. <choose>
  125. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  126. ORDER BY ${page.orderBy}
  127. </when>
  128. <otherwise>
  129. </otherwise>
  130. </choose>
  131. </select>
  132. <select id="findAllList" resultMap="baseMap">
  133. SELECT
  134. <include refid="columns"/>
  135. FROM sys_grain a
  136. <include refid="joinCols"/>
  137. <where>
  138. <if test="id !=null">
  139. and id = #{id}
  140. </if>
  141. <if test="name !=null">
  142. and `name` = #{name}
  143. </if>
  144. <if test="uuid !=null">
  145. and uuid = #{uuid}
  146. </if>
  147. <if test="version !=null">
  148. and version = #{version}
  149. </if>
  150. <if test="parentId !=null">
  151. and parentId = #{parentId}
  152. </if>
  153. <if test="cId !=null">
  154. and c_id = #{cId}
  155. </if>
  156. <if test="uId !=null">
  157. and u_id = #{uId}
  158. </if>
  159. <if test="cTime !=null">
  160. and c_time = #{cTime}
  161. </if>
  162. <if test="uTime !=null">
  163. and u_time = #{uTime}
  164. </if>
  165. <if test="pic !=null">
  166. and pic = #{pic}
  167. </if>
  168. <if test="grainDescribe !=null">
  169. and grain_Describe = #{grainDescribe}
  170. </if>
  171. <if test="type !=null">
  172. and type = #{type}
  173. </if>
  174. <if test="gno !=null">
  175. and gno = #{gno}
  176. </if>
  177. <if test="idKey !=null">
  178. and idkey = #{idKey}
  179. </if>
  180. </where>
  181. <choose>
  182. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  183. ORDER BY ${page.orderBy}
  184. </when>
  185. <otherwise>
  186. </otherwise>
  187. </choose>
  188. </select>
  189. <insert id="insert" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
  190. parameterType="cn.ourwill.module.sys.entity.SysGrain">
  191. INSERT INTO sys_grain
  192. <trim prefix="(" suffix=")" suffixOverrides=",">
  193. <if test=" id != null">
  194. id,
  195. </if>
  196. <if test=" name != null">
  197. `name`,
  198. </if>
  199. <if test=" uuid != null">
  200. uuid,
  201. </if>
  202. <if test=" version != null">
  203. version,
  204. </if>
  205. <if test=" parentId != null">
  206. parentId,
  207. </if>
  208. <if test=" cId != null">
  209. c_id,
  210. </if>
  211. <if test=" uId != null">
  212. u_id,
  213. </if>
  214. <if test=" cTime != null">
  215. c_time,
  216. </if>
  217. <if test=" uTime != null">
  218. u_time,
  219. </if>
  220. <if test=" pic != null">
  221. pic,
  222. </if>
  223. <if test="grainDescribe !=null">
  224. grain_Describe,
  225. </if>
  226. <if test="type !=null">
  227. type,
  228. </if>
  229. <if test="gno !=null">
  230. gno
  231. </if>
  232. </trim>
  233. <trim prefix="values (" suffix=")" suffixOverrides=",">
  234. <if test=" id != null">
  235. #{id}, </if>
  236. <if test=" name != null">
  237. #{name}, </if>
  238. <if test=" uuid != null">
  239. #{uuid}, </if>
  240. <if test=" version != null">
  241. #{version}, </if>
  242. <if test=" parentId != null">
  243. #{parentId}, </if>
  244. <if test=" cId != null">
  245. #{cId}, </if>
  246. <if test=" uId != null">
  247. #{uId}, </if>
  248. <if test=" cTime != null">
  249. #{cTime}, </if>
  250. <if test=" uTime != null">
  251. #{uTime}, </if>
  252. <if test=" pic != null">
  253. #{pic}, </if>
  254. <if test="grainDescribe !=null">
  255. #{grainDescribe}, </if>
  256. <if test="type !=null">
  257. #{type}, </if>
  258. <if test="gno !=null">
  259. #{gno} </if>
  260. </trim>
  261. </insert>
  262. <update id="update" parameterType="cn.ourwill.module.sys.entity.SysGrain">
  263. UPDATE sys_grain <set>
  264. <if test="id != null">
  265. id= #{id} ,
  266. </if>
  267. <if test="name != null">
  268. `name`= #{name} ,
  269. </if>
  270. <if test="uuid != null">
  271. uuid= #{uuid} ,
  272. </if>
  273. <if test="version != null">
  274. version= #{version} ,
  275. </if>
  276. <if test="parentId != null">
  277. parentId= #{parentId} ,
  278. </if>
  279. <if test="cId != null">
  280. c_id= #{cId} ,
  281. </if>
  282. <if test="uId != null">
  283. u_id= #{uId} ,
  284. </if>
  285. <if test="cTime != null">
  286. c_time= #{cTime} ,
  287. </if>
  288. <if test="uTime != null">
  289. u_time= #{uTime} ,
  290. </if>
  291. <if test="pic != null">
  292. pic= #{pic} ,
  293. </if>
  294. <if test="grainDescribe !=null">
  295. grain_Describe = #{grainDescribe} ,
  296. </if>
  297. <if test="type !=null">
  298. type = #{type},
  299. </if>
  300. <if test="gno !=null">
  301. gno = #{gno}
  302. </if>
  303. </set>
  304. WHERE id = #{id}
  305. </update>
  306. <delete id="deleteById" parameterType="java.lang.Long">
  307. DELETE FROM sys_grain WHERE id = #{id}
  308. </delete>
  309. <delete id="deleteByIds" parameterType="java.util.List">
  310. DELETE FROM sys_grain WHERE id IN
  311. <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
  312. #{item}
  313. </foreach>
  314. </delete>
  315. <select id="getByParentId" resultMap="baseMap">
  316. SELECT
  317. <include refid="columns"/>
  318. FROM sys_grain
  319. WHERE parentId = #{value}
  320. </select>
  321. <update id="insertCode">
  322. update sys_grain set idkey=#{s2} where name=#{s1}
  323. </update>
  324. <select id="kxghidKey" resultType="java.lang.String" parameterType="java.lang.Integer">
  325. SELECT
  326. idkey
  327. FROM sys_grain
  328. WHERE id = #{gid}
  329. </select>
  330. <select id="findByDevice" resultMap="baseMap">
  331. select `name`,id from sys_grain where id in (SELECT grain_id FROM dm_device_model)
  332. </select>
  333. <select id="getId" resultType="java.lang.String">
  334. select id from sys_grain where id = #{id}
  335. </select>
  336. <select id="getById" resultType="java.lang.String">
  337. select name from sys_grain where id = #{id}
  338. </select>
  339. <select id="getNameById" resultType="java.lang.String">
  340. select name from sys_grain where id = #{id}
  341. </select>
  342. <select id="getByUuid" resultType="cn.ourwill.module.sys.entity.SysGrain">
  343. SELECT
  344. <include refid="columns"/>
  345. FROM sys_grain a
  346. <include refid="joinCols"/>
  347. WHERE a.uuid = #{uuid}
  348. </select>
  349. </mapper>