EntGridMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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="com.zhyc.xps.sys.mapper.EntGridMapper">
  4. <resultMap id="GridDtoMap" type="com.zhyc.xps.sys.dto.EntGridDto">
  5. <result column="oc_id" property="ocId" jdbcType="BIGINT" />
  6. <result column="grid_id" property="gridId" jdbcType="BIGINT" />
  7. <result column="grid_code" property="gridCode" jdbcType="VARCHAR" />
  8. <result column="grid_title" property="gridTitle" jdbcType="VARCHAR" />
  9. <result column="grid_level" property="gridLevel" jdbcType="BIGINT" />
  10. <result column="grid_desc" property="gridDesc" jdbcType="VARCHAR" />
  11. <result column="status" property="status" jdbcType="BIGINT" />
  12. <result column="group_id" property="groupId" jdbcType="BIGINT" />
  13. <result column="group_name" property="groupName" jdbcType="VARCHAR" />
  14. <result column="position_id" property="positionId" jdbcType="BIGINT" />
  15. <result column="position_name" property="positionName" jdbcType="VARCHAR" />
  16. <result column="account_id" property="accountId" jdbcType="BIGINT" />
  17. <result column="account_name" property="accountName" jdbcType="VARCHAR" />
  18. <result column="checklist_num" property="checklistNum" jdbcType="BIGINT" />
  19. </resultMap>
  20. <sql id="GridDto_Cols">
  21. A.oc_id,
  22. A.grid_id,
  23. A.grid_code,
  24. A.grid_title,
  25. A.grid_level,
  26. A.grid_desc,
  27. A.status,
  28. A.group_id,
  29. B.group_name,
  30. A.position_id,
  31. C.position_name,
  32. A.account_id,
  33. D.account_name,
  34. IFNULL(E.checklist_num, 0) AS checklist_num
  35. </sql>
  36. <!--根据ID获取信息-->
  37. <select id="getById" resultMap="GridDtoMap">
  38. SELECT
  39. <include refid="GridDto_Cols"/>
  40. FROM ent_grid AS A
  41. LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
  42. LEFT JOIN s_position AS C ON (A.oc_id = C.oc_id AND A.position_id = C.position_id)
  43. LEFT JOIN account AS D ON (A.oc_id = D.oc_id AND A.account_id = D.account_id)
  44. LEFT JOIN (
  45. SELECT oc_id, target_id, count(*) AS checklist_num
  46. FROM checklist_target
  47. WHERE oc_id = #{ocId ,jdbcType=BIGINT} AND target_type = 1
  48. GROUP BY target_id
  49. ) AS E ON (A.oc_id = E.oc_id AND A.grid_id = E.target_id)
  50. WHERE A.oc_id = #{ocId ,jdbcType=BIGINT}
  51. AND A.grid_id = #{gridId ,jdbcType=BIGINT}
  52. </select>
  53. <!--基于Code获取信息-->
  54. <select id="getByCode" resultMap="GridDtoMap">
  55. SELECT
  56. <include refid="GridDto_Cols"/>
  57. FROM ent_grid AS A
  58. LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
  59. LEFT JOIN s_position AS C ON (A.oc_id = C.oc_id AND A.position_id = C.position_id)
  60. LEFT JOIN account AS D ON (A.oc_id = D.oc_id AND A.account_id = D.account_id)
  61. LEFT JOIN (
  62. SELECT oc_id, target_id, count(*) AS checklist_num
  63. FROM checklist_target
  64. WHERE oc_id = #{ocId ,jdbcType=BIGINT} AND target_type = 1
  65. GROUP BY target_id
  66. ) AS E ON (A.oc_id = E.oc_id AND A.grid_id = E.target_id)
  67. WHERE A.oc_id = #{ocId, jdbcType=BIGINT}
  68. AND A.grid_code = #{gridCode, jdbcType=VARCHAR}
  69. </select>
  70. <!--分页查询信息-->
  71. <select id="getByPage" parameterType="java.util.Map" resultMap="GridDtoMap">
  72. SELECT
  73. <include refid="GridDto_Cols"/>
  74. FROM ent_grid AS A
  75. LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id )
  76. LEFT JOIN s_position AS C ON (A.oc_id = C.oc_id AND A.position_id = C.position_id)
  77. LEFT JOIN account AS D ON (A.oc_id = D.oc_id AND A.account_id = D.account_id)
  78. LEFT JOIN (
  79. SELECT oc_id, target_id, count(*) AS checklist_num
  80. FROM checklist_target
  81. WHERE oc_id = #{ocId ,jdbcType=BIGINT} AND target_type = 1
  82. GROUP BY target_id
  83. ) AS E ON (A.oc_id = E.oc_id AND A.grid_id = E.target_id)
  84. WHERE A.deleted_flag = 0 AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  85. <if test="status != null">
  86. AND A.status = #{status ,jdbcType=BIGINT}
  87. </if>
  88. <if test="keywords != null and keywords != ''">
  89. and A.grid_title like "%"#{keywords}"%"
  90. </if>
  91. ORDER BY A.grid_id ASC
  92. </select>
  93. <select id="getByList" parameterType="java.util.Map" resultMap="GridDtoMap">
  94. SELECT
  95. <include refid="GridDto_Cols"/>
  96. FROM ent_grid AS A
  97. LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id )
  98. LEFT JOIN s_position AS C ON (A.oc_id = C.oc_id AND A.position_id = C.position_id)
  99. LEFT JOIN account AS D ON (A.oc_id = D.oc_id AND A.account_id = D.account_id)
  100. LEFT JOIN (
  101. SELECT oc_id, target_id, count(*) AS checklist_num
  102. FROM checklist_target
  103. WHERE oc_id = #{ocId ,jdbcType=BIGINT} AND target_type = 1
  104. GROUP BY target_id
  105. ) AS E ON (A.oc_id = E.oc_id AND A.grid_id = E.target_id)
  106. WHERE A.deleted_flag = 0 AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  107. <if test="status != null">
  108. AND A.status = #{status ,jdbcType=BIGINT}
  109. </if>
  110. <if test="keywords != null and keywords != ''">
  111. AND A.grid_title like "%"#{keywords}"%"
  112. </if>
  113. ORDER BY A.grid_id ASC
  114. </select>
  115. <insert id="create" parameterType="com.zhyc.xps.sys.entity.EntGrid">
  116. INSERT INTO ent_grid
  117. <trim prefix="(" suffix=")" suffixOverrides=",">
  118. <if test="ocId != null">
  119. oc_id,
  120. </if>
  121. <if test="gridId != null">
  122. grid_id,
  123. </if>
  124. <if test="gridCode != null and gridCode != ''">
  125. grid_code,
  126. </if>
  127. <if test="gridTitle != null and gridTitle != ''">
  128. grid_title,
  129. </if>
  130. <if test="gridLevel != null">
  131. grid_level,
  132. </if>
  133. <if test="status != null">
  134. status,
  135. </if>
  136. <if test="gridDesc != null">
  137. grid_desc,
  138. </if>
  139. <if test="groupId != null">
  140. group_id,
  141. </if>
  142. <if test="positionId != null">
  143. position_id,
  144. </if>
  145. <if test="accountId != null">
  146. account_id,
  147. </if>
  148. <if test="createdBy != null">
  149. created_by,
  150. </if>
  151. <if test="createdAt != null">
  152. created_at,
  153. </if>
  154. </trim>
  155. <trim prefix="values (" suffix=")" suffixOverrides=",">
  156. <if test="ocId != null">
  157. #{ocId ,jdbcType=BIGINT},
  158. </if>
  159. <if test="gridId != null">
  160. #{gridId ,jdbcType=BIGINT},
  161. </if>
  162. <if test="gridCode != null and gridCode != ''">
  163. #{gridCode ,jdbcType=VARCHAR},
  164. </if>
  165. <if test="gridTitle != null">
  166. #{gridTitle ,jdbcType=VARCHAR},
  167. </if>
  168. <if test="gridLevel != null">
  169. #{gridLevel ,jdbcType=BIGINT},
  170. </if>
  171. <if test="status != null">
  172. #{status ,jdbcType=BIGINT},
  173. </if>
  174. <if test="gridDesc != null">
  175. #{gridDesc ,jdbcType=VARCHAR},
  176. </if>
  177. <if test="groupId != null">
  178. #{groupId ,jdbcType=BIGINT},
  179. </if>
  180. <if test="positionId != null">
  181. #{positionId ,jdbcType=BIGINT},
  182. </if>
  183. <if test="accountId != null">
  184. #{accountId ,jdbcType=BIGINT},
  185. </if>
  186. <if test="createdBy != null">
  187. #{createdBy ,jdbcType=BIGINT},
  188. </if>
  189. <if test="createdAt != null">
  190. #{createdAt ,jdbcType=TIMESTAMP},
  191. </if>
  192. </trim>
  193. </insert>
  194. <!--更新-->
  195. <update id="update" parameterType="com.zhyc.xps.sys.entity.EntGrid">
  196. UPDATE ent_grid
  197. <trim suffixOverrides=",">
  198. <set>
  199. <if test="gridTitle != null and gridTitle != ''">
  200. grid_title = #{gridTitle, jdbcType=VARCHAR},
  201. </if>
  202. <if test="gridLevel != null">
  203. grid_level = #{gridLevel ,jdbcType=BIGINT},
  204. </if>
  205. <if test="gridDesc != null and gridDesc != ''">
  206. grid_desc = #{gridDesc, jdbcType=VARCHAR},
  207. </if>
  208. <if test="status != null">
  209. status = #{status ,jdbcType=BIGINT},
  210. </if>
  211. <if test="groupId != null">
  212. group_id = #{groupId ,jdbcType=BIGINT},
  213. </if>
  214. <if test="positionId != null">
  215. position_id = #{positionId ,jdbcType=BIGINT},
  216. </if>
  217. <if test="accountId != null">
  218. account_id = #{accountId ,jdbcType=BIGINT},
  219. </if>
  220. <if test="updatedBy != null ">
  221. updated_by = #{updatedBy ,jdbcType=BIGINT},
  222. </if>
  223. <if test="updatedAt != null">
  224. updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
  225. </if>
  226. <if test="layerId != null">
  227. layer_id = #{layerId ,jdbcType=BIGINT},
  228. </if>
  229. </set>
  230. </trim>
  231. WHERE 1 = 1
  232. <if test="ocId != null">
  233. AND oc_id = #{ocId ,jdbcType=BIGINT}
  234. </if>
  235. <if test="gridId != null">
  236. AND grid_id = #{gridId ,jdbcType=BIGINT}
  237. </if>
  238. </update>
  239. <!--删除-->
  240. <update id="delete" parameterType="java.util.Map">
  241. UPDATE ent_grid
  242. <trim suffixOverrides=",">
  243. <set>
  244. <if test="deletedFlag != null">
  245. deleted_flag = #{deletedFlag, jdbcType=BIGINT},
  246. </if>
  247. <if test="deletedAt != null">
  248. deleted_at = #{deletedAt, jdbcType=TIMESTAMP},
  249. </if>
  250. <if test="deletedBy != null">
  251. deleted_by = #{deletedBy,jdbcType=BIGINT},
  252. </if>
  253. </set>
  254. </trim>
  255. WHERE 1 = 1
  256. <if test="ocId != null">
  257. AND oc_id = #{ocId ,jdbcType=BIGINT}
  258. </if>
  259. <if test="gridId != null">
  260. AND grid_id = #{gridId ,jdbcType=BIGINT}
  261. </if>
  262. <if test="ocId != null">
  263. AND oc_id = #{ocId ,jdbcType=BIGINT}
  264. </if>
  265. </update>
  266. </mapper>