ZkChecklistMapper.xml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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.aqpt.mapper.ZkChecklistMapper">
  4. <resultMap id="BaseResultMap" type="com.zhyc.xps.aqpt.entity.ZkChecklist">
  5. <result column="industry_id" property="industryId" jdbcType="BIGINT" />
  6. <result column="checklist_id" property="checklistId" jdbcType="BIGINT" />
  7. <result column="created_by" property="createdBy" jdbcType="BIGINT" />
  8. <result column="created_at" property="createdAt" jdbcType="DATE" />
  9. <result column="updated_by" property="updatedBy" jdbcType="BIGINT" />
  10. <result column="updated_at" property="updatedAt" jdbcType="DATE" />
  11. </resultMap>
  12. <resultMap id="ZkChecklistDtoResultMap" type="com.zhyc.xps.aqpt.dto.ZkChecklistDto" extends="BaseResultMap">
  13. <result column="industry_name" property="industryName" jdbcType="VARCHAR" />
  14. <result column="checklist_cat_id" property="checklistCatId" jdbcType="BIGINT" />
  15. <result column="checklist_cat_title" property="checklistCatTitle" jdbcType="VARCHAR" />
  16. <result column="checklist_type_id" property="checklistTypeId" jdbcType="BIGINT" />
  17. <result column="checklist_title" property="checklistTitle" jdbcType="VARCHAR" />
  18. <result column="checklist_desc" property="checklistDesc" jdbcType="VARCHAR" />
  19. <result column="is_fixed" property="isFixed" jdbcType="BIGINT" />
  20. <result column="issued_by" property="issuedBy" jdbcType="BIGINT" />
  21. <result column="issued_at" property="issuedAt" jdbcType="TIMESTAMP"/>
  22. <result column="author" property="author" jdbcType="VARCHAR" />
  23. <result column="status" property="status" jdbcType="BIGINT" />
  24. <result column="version" property="version" jdbcType="VARCHAR" />
  25. </resultMap>
  26. <sql id="Base_Column_List">
  27. industry_id,
  28. checklist_id,
  29. created_by,
  30. created_at,
  31. updated_by,
  32. updated_at
  33. </sql>
  34. <sql id="ZkChecklistDto_Column_List">
  35. A.industry_id,
  36. B.industry_name,
  37. A.checklist_id,
  38. C.checklist_cat_id,
  39. C.checklist_type_id,
  40. D.checklist_cat_title,
  41. C.checklist_desc,
  42. C.checklist_title,
  43. C.is_fixed,
  44. C.issued_by,
  45. C.issued_at,
  46. C.author
  47. </sql>
  48. <!--根据ID获取信息-->
  49. <select id="getById" resultMap="ZkChecklistDtoResultMap">
  50. SELECT
  51. <include refid="ZkChecklistDto_Column_List"/>
  52. FROM zk_checklist AS A
  53. LEFT JOIN industry AS B ON (A.industry_id = B.industry_id)
  54. LEFT JOIN checklist AS C ON (A.checklist_id = C.checklist_id)
  55. LEFT JOIN checklist_cat D ON (C.checklist_cat_id = D.checklist_cat_id)
  56. WHERE 1 = 1 AND C.deleted_flag = 0
  57. <if test="industryId != null">
  58. AND A.industry_id = #{industryId ,jdbcType=BIGINT}
  59. </if>
  60. <if test="checklistId != null">
  61. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  62. </if>
  63. </select>
  64. <!--根据ID获取信息-->
  65. <select id="getByChecklistId" resultMap="ZkChecklistDtoResultMap">
  66. SELECT
  67. <include refid="ZkChecklistDto_Column_List"/>
  68. FROM zk_checklist AS A
  69. LEFT JOIN industry AS B ON (A.industry_id = B.industry_id)
  70. LEFT JOIN checklist AS C ON (A.checklist_id = C.checklist_id)
  71. LEFT JOIN checklist_cat D ON (C.checklist_cat_id = D.checklist_cat_id)
  72. WHERE 1 = 1 AND C.deleted_flag = 0
  73. <if test="checklistId != null">
  74. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  75. </if>
  76. Limit 0, 1
  77. </select>
  78. <!--分页查询信息-->
  79. <select id="getByPage" parameterType="java.util.Map" resultMap="ZkChecklistDtoResultMap">
  80. SELECT
  81. <include refid="ZkChecklistDto_Column_List"/>
  82. FROM zk_checklist AS A
  83. LEFT JOIN industry AS B ON (A.industry_id = B.industry_id)
  84. LEFT JOIN checklist AS C ON (A.checklist_id = C.checklist_id)
  85. LEFT JOIN checklist_cat D ON (C.checklist_cat_id = D.checklist_cat_id)
  86. WHERE 1 = 1 AND C.deleted_flag = 0
  87. <if test="industryId != null">
  88. AND A.industry_id = #{industryId ,jdbcType=BIGINT}
  89. </if>
  90. <if test="checklistId != null">
  91. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  92. </if>
  93. <if test="keywords != null and keywords != ''">
  94. AND C.checklist_title like "%"#{keywords}"%"
  95. </if>
  96. <if test="nodeLeft != null and nodeLeft != '' and nodeRight != null and nodeRight != ''">
  97. <![CDATA[
  98. AND
  99. B.node_left >= #{nodeLeft, jdbcType=BIGINT}
  100. AND
  101. B.node_right <= #{nodeRight, jdbcType=BIGINT}
  102. ]]>
  103. </if>
  104. ORDER BY C.issued_at DESC
  105. </select>
  106. <!--查询信息列表-->
  107. <select id="getByList" parameterType="java.util.Map" resultMap="ZkChecklistDtoResultMap">
  108. SELECT
  109. <include refid="ZkChecklistDto_Column_List"/>
  110. FROM zk_checklist AS A
  111. LEFT JOIN industry AS B ON (A.industry_id = B.industry_id)
  112. LEFT JOIN checklist AS C ON (A.checklist_id = C.checklist_id)
  113. LEFT JOIN checklist_cat D ON (C.checklist_cat_id = D.checklist_cat_id)
  114. WHERE 1 = 1 AND C.deleted_flag = 0
  115. <if test="industryId != null">
  116. AND A.industry_id = #{industryId ,jdbcType=BIGINT}
  117. </if>
  118. <if test="checklistId != null">
  119. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  120. </if>
  121. <if test="keywords != null and keywords != ''">
  122. AND C.checklist_title like "%"#{keywords}"%"
  123. </if>
  124. <if test="nodeLeft != null and nodeLeft != '' and nodeRight != null and nodeRight != ''">
  125. <![CDATA[
  126. AND
  127. B.node_left >= #{nodeLeft, jdbcType=BIGINT}
  128. AND
  129. B.node_right <= #{nodeRight, jdbcType=BIGINT}
  130. ]]>
  131. </if>
  132. ORDER BY C.issued_at DESC
  133. </select>
  134. <insert id="create" parameterType="com.zhyc.xps.aqpt.entity.ZkChecklist">
  135. INSERT INTO zk_checklist
  136. <trim prefix="(" suffix=")" suffixOverrides=",">
  137. <if test="industryId != null">
  138. industry_id,
  139. </if>
  140. <if test="checklistId != null">
  141. checklist_id,
  142. </if>
  143. <if test="createdBy != null">
  144. created_by,
  145. </if>
  146. <if test="createdAt != null">
  147. created_at,
  148. </if>
  149. </trim>
  150. <trim prefix="values (" suffix=")" suffixOverrides=",">
  151. <if test="industryId != null">
  152. #{industryId ,jdbcType=BIGINT},
  153. </if>
  154. <if test="checklistId != null">
  155. #{checklistId ,jdbcType=BIGINT},
  156. </if>
  157. <if test="createdBy != null">
  158. #{createdBy ,jdbcType=BIGINT},
  159. </if>
  160. <if test="createdAt != null">
  161. #{createdAt ,jdbcType=DATE},
  162. </if>
  163. </trim>
  164. </insert>
  165. <!--删除-->
  166. <delete id="delete" parameterType="java.util.Map">
  167. DELETE FROM zk_checklist
  168. WHERE 1 = 1
  169. <if test="industryId != null">
  170. AND industry_id = #{industryId ,jdbcType=BIGINT}
  171. </if>
  172. <if test="checklistId != null">
  173. AND checklist_id = #{checklistId ,jdbcType=BIGINT}
  174. </if>
  175. </delete>
  176. </mapper>