ChecklistTargetMapper.xml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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.ChecklistTargetMapper">
  4. <resultMap id="ChecklistDtoResultMap" type="com.zhyc.xps.common.dto.ChecklistDto">
  5. <result column="oc_id" property="ocId" jdbcType="BIGINT" /><!--单位ID-->
  6. <result column="checklist_id" property="checklistId" jdbcType="BIGINT" /><!--清单ID-->
  7. <result column="checklist_cat_id" property="checklistCatId" jdbcType="BIGINT" />
  8. <result column="checklist_cat_title" property="checklistCatTitle" jdbcType="VARCHAR" />
  9. <result column="checklist_type_id" property="checklistTypeId" jdbcType="BIGINT" />
  10. <result column="checklist_title" property="checklistTitle" jdbcType="VARCHAR" />
  11. <result column="checklist_desc" property="checklistDesc" jdbcType="VARCHAR" />
  12. <result column="is_fixed" property="isFixed" jdbcType="BIGINT" />
  13. <result column="issued_at" property="issuedAt" jdbcType="TIMESTAMP"/>
  14. <result column="author" property="author" jdbcType="VARCHAR" />
  15. <result column="status" property="status" jdbcType="BIGINT" />
  16. <result column="version" property="version" jdbcType="VARCHAR" />
  17. <result column="issued_account_id" property="issuedAccountId" jdbcType="BIGINT" />
  18. <result column="issued_account_name" property="issuedAccountName" jdbcType="VARCHAR" />
  19. </resultMap>
  20. <sql id="ChecklistDto_Cols">
  21. A.oc_id,
  22. A.checklist_id,
  23. B.checklist_cat_id,
  24. B.checklist_type_id,
  25. C.checklist_cat_title,
  26. B.checklist_desc,
  27. B.checklist_title,
  28. B.is_fixed,
  29. D.account_name AS issued_account_name,
  30. B.issued_by AS issued_account_id,
  31. B.issued_at,
  32. B.author,
  33. B.status,
  34. B.version
  35. </sql>
  36. <!--列表查询-->
  37. <select id="getByList" parameterType="java.util.Map" resultMap="ChecklistDtoResultMap">
  38. SELECT
  39. <include refid="ChecklistDto_Cols"/>
  40. FROM checklist_target AS A
  41. LEFT JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
  42. LEFT JOIN checklist_cat AS C ON (B.oc_id = C.oc_id AND B.checklist_cat_id = C.checklist_cat_id)
  43. LEFT JOIN account AS D ON (B.oc_id = D.oc_id AND B.issued_by = D.account_id)
  44. WHERE 1 = 1
  45. <if test="ocId != null">
  46. AND A.oc_id = #{ocId,jdbcType=BIGINT}
  47. </if>
  48. <if test="checklistId != null">
  49. AND A.checklist_id = #{checklistId,jdbcType=BIGINT}
  50. </if>
  51. <if test="targetId != null">
  52. AND A.target_id = #{targetId,jdbcType=BIGINT}
  53. </if>
  54. <if test="targetType != null">
  55. AND A.target_type = #{targetType,jdbcType=BIGINT}
  56. </if>
  57. <if test="keywords != null and keywords != ''">
  58. AND B.checklist_title like "%"#{keywords}"%"
  59. </if>
  60. ORDER BY A.checklist_id
  61. </select>
  62. <!--获取选择列表-->
  63. <select id="getBySelect" resultMap="ChecklistDtoResultMap" parameterType="java.util.Map">
  64. SELECT
  65. A.oc_id,
  66. A.checklist_id,
  67. A.checklist_type_id,
  68. B.checklist_cat_title,
  69. A.checklist_desc,
  70. A.checklist_title,
  71. A.is_fixed,
  72. C.account_name AS issued_account_name,
  73. A.issued_by AS issued_account_id,
  74. A.issued_at,
  75. A.author,
  76. A.status,
  77. A.version
  78. FROM checklist AS A
  79. LEFT JOIN checklist_cat AS B ON (A.oc_id = B.oc_id AND A.checklist_cat_id = B.checklist_cat_id)
  80. LEFT JOIN account AS C ON (A.oc_id = C.oc_id AND A.issued_by = C.account_id)
  81. WHERE A.deleted_flag = 0 AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  82. AND NOT EXISTS (
  83. SELECT
  84. *
  85. FROM checklist_target AS D
  86. WHERE A.oc_id = D.oc_id AND A.checklist_id = D.checklist_id AND D.target_id = #{targetId ,jdbcType=BIGINT}
  87. )
  88. <if test="checklistId !=null">
  89. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  90. </if>
  91. <if test="keywords != null and keywords != ''">
  92. AND A.checklist_title like "%"#{keywords}"%"
  93. </if>
  94. <if test="checklistTypeId != null">
  95. AND A.checklist_type_id = #{checklistTypeId ,jdbcType=BIGINT}
  96. </if>
  97. <if test="status != null">
  98. AND A.status = #{status ,jdbcType=BIGINT}
  99. </if>
  100. ORDER BY A.checklist_id
  101. </select>
  102. <insert id="create" parameterType="com.zhyc.xps.sys.entity.ChecklistTarget">
  103. INSERT INTO checklist_target
  104. <trim prefix="(" suffix=")" suffixOverrides=",">
  105. <if test="ocId != null">
  106. oc_id,
  107. </if>
  108. <if test="checklistId != null">
  109. checklist_Id,
  110. </if>
  111. <if test="targetId != null">
  112. target_id,
  113. </if>
  114. <if test="targetType != null">
  115. target_type,
  116. </if>
  117. </trim>
  118. <trim prefix="values (" suffix=")" suffixOverrides=",">
  119. <if test="ocId != null">
  120. #{ocId, jdbcType=BIGINT},
  121. </if>
  122. <if test="checklistId != null">
  123. #{checklistId, jdbcType=BIGINT},
  124. </if>
  125. <if test="targetId != null">
  126. #{targetId, jdbcType=BIGINT},
  127. </if>
  128. <if test="targetType != null">
  129. #{targetType, jdbcType=BIGINT},
  130. </if>
  131. </trim>
  132. </insert>
  133. <!--删除-->
  134. <delete id="delete" parameterType="java.util.Map">
  135. DELETE from checklist_target
  136. WHERE 1 = 1
  137. <if test="ocId != null">
  138. AND oc_Id = #{ocId ,jdbcType=BIGINT}
  139. </if>
  140. <if test="checklistId != null">
  141. AND checklist_Id = #{checklistId ,jdbcType=BIGINT}
  142. </if>
  143. <if test="targetId != null">
  144. AND target_Id = #{targetId ,jdbcType=BIGINT}
  145. </if>
  146. <if test="targetType != null">
  147. AND target_type = #{targetType ,jdbcType=BIGINT}
  148. </if>
  149. </delete>
  150. </mapper>