EntRiskPointArtMapper.xml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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.EntRiskPointArtMapper">
  4. <resultMap id="BaseResultMap" type="com.zhyc.xps.aqpt.entity.EntRiskPointArt">
  5. <result column="oc_id" property="ocId" jdbcType="BIGINT"/>
  6. <result column="risk_point_id" property="riskPointId" jdbcType="BIGINT"/>
  7. <result column="art_id" property="artId" jdbcType="BIGINT"/>
  8. </resultMap>
  9. <resultMap id="RiskPointArtDtoMap" type="com.zhyc.xps.aqpt.dto.EntRiskPointArtDto" extends="BaseResultMap">
  10. <result column="art_title" property="artTitle" jdbcType="VARCHAR"/>
  11. <result column="art_author" property="artAuthor" jdbcType="VARCHAR"/>
  12. <result column="editor_id" property="editorId" jdbcType="BIGINT"/>
  13. <result column="editor_name" property="editorName" jdbcType="VARCHAR"/>
  14. <result column="art_cat_id" property="artCatId" jdbcType="BIGINT"/>
  15. <result column="art_cat_title" property="artCatTitle" jdbcType="VARCHAR"/>
  16. </resultMap>
  17. <resultMap id="ArtDtoResultMap" type="com.zhyc.xps.sys.dto.ArtDto">
  18. <result column="oc_id" property="ocId" jdbcType="BIGINT"/><!--ID-->
  19. <result column="art_id" property="artId" jdbcType="BIGINT"/><!--群组ID-->
  20. <result column="art_cat_id" property="artCatId" jdbcType="BIGINT"/>
  21. <result column="art_author" property="artAuthor" jdbcType="VARCHAR"/>
  22. <result column="art_title" property="artTitle" jdbcType="VARCHAR"/>
  23. <result column="art_source" property="artSource" jdbcType="VARCHAR"/>
  24. <result column="is_fixed" property="isFixed" jdbcType="BIGINT"/>
  25. <result column="editor_id" property="editorId" jdbcType="BIGINT"/>
  26. <result column="issued_at" property="issuedAt" jdbcType="DATE"/>
  27. <result column="status" property="status" jdbcType="BIGINT"/>
  28. <result column="art_cat_title" property="artCatTitle" jdbcType="VARCHAR"/>
  29. <result column="editor_name" property="editorName" jdbcType="VARCHAR"/>
  30. </resultMap>
  31. <sql id="RiskPointArtDto_Cols">
  32. A.oc_id,
  33. A.risk_point_id,
  34. A.art_id,
  35. B.art_title,
  36. B.art_author,
  37. B.issued_at,
  38. B.editor_id,
  39. C.account_name as editor_name,
  40. B.art_cat_id,
  41. D.art_cat_title
  42. </sql>
  43. <!--分页查询ART信息-->
  44. <select id="getByPage" parameterType="java.util.Map" resultMap="RiskPointArtDtoMap">
  45. SELECT
  46. <include refid="RiskPointArtDto_Cols"/>
  47. FROM ent_risk_point_art AS A
  48. LEFT JOIN art AS B ON(A.oc_id = B.oc_id AND A.art_id = B.art_id)
  49. LEFT JOIN account AS C ON(B.oc_id = C.oc_id AND B.editor_id = C.account_id)
  50. LEFT JOIN art_cat AS D ON(B.oc_id = D.oc_id AND B.art_cat_id= D.art_cat_id)
  51. WHERE 1 = 1 AND B.deleted_flag = 0
  52. <if test="ocId != null">
  53. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  54. </if>
  55. <if test="riskPointId != null">
  56. AND A.risk_point_id = #{riskPointId}
  57. </if>
  58. <if test="keywords != null and keywords != ''">
  59. AND B.art_title like "%"#{keywords}"%"
  60. </if>
  61. ORDER BY B.issued_at DESC
  62. </select>
  63. <select id="getByList" parameterType="java.util.Map" resultMap="RiskPointArtDtoMap">
  64. SELECT
  65. <include refid="RiskPointArtDto_Cols"/>
  66. FROM ent_risk_point_art AS A
  67. LEFT JOIN art AS B ON(A.oc_id = B.oc_id AND A.art_id = B.art_id)
  68. LEFT JOIN account AS C ON(B.oc_id = C.oc_id AND B.editor_id = C.account_id)
  69. LEFT JOIN art_cat AS D ON(B.oc_id = D.oc_id AND B.art_cat_id= D.art_cat_id)
  70. WHERE B.deleted_flag = 0
  71. <if test="ocId != null">
  72. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  73. </if>
  74. <if test="riskPointId != null">
  75. AND A.risk_point_id = #{riskPointId}
  76. </if>
  77. <if test="artId != null">
  78. AND A.art_id = #{artId}
  79. </if>
  80. <if test="keywords != null and keywords != ''">
  81. AND B.art_title like "%"#{keywords}"%"
  82. </if>
  83. ORDER BY B.issued_at DESC
  84. </select>
  85. <insert id="create" parameterType="com.zhyc.xps.aqpt.entity.EntRiskPointArt">
  86. INSERT INTO ent_risk_point_art
  87. <trim prefix="(" suffix=")" suffixOverrides=",">
  88. <if test="ocId != null">
  89. oc_id,
  90. </if>
  91. <if test="riskPointId != null">
  92. risk_point_id,
  93. </if>
  94. <if test="artId != null">
  95. art_id,
  96. </if>
  97. </trim>
  98. <trim prefix="values (" suffix=")" suffixOverrides=",">
  99. <if test="ocId != null">
  100. #{ocId ,jdbcType=BIGINT},
  101. </if>
  102. <if test="riskPointId != null">
  103. #{riskPointId ,jdbcType=BIGINT},
  104. </if>
  105. <if test="artId != null">
  106. #{artId ,jdbcType=BIGINT},
  107. </if>
  108. </trim>
  109. </insert>
  110. <!--删除-->
  111. <delete id="delete" parameterType="java.util.Map">
  112. DELETE FROM ent_risk_point_art
  113. WHERE 1 = 1
  114. <if test="ocId != null">
  115. AND oc_id = #{ocId ,jdbcType=BIGINT}
  116. </if>
  117. <if test="riskPointId != null">
  118. AND risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  119. </if>
  120. <if test="artId != null">
  121. AND art_id = #{artId ,jdbcType=BIGINT}
  122. </if>
  123. </delete>
  124. <!--选择-->
  125. <select id="getSelectByPage" parameterType="java.util.Map" resultMap="ArtDtoResultMap">
  126. SELECT
  127. A.oc_id,
  128. A.art_id,
  129. A.art_cat_id,
  130. B.art_cat_title,
  131. B.root_id,
  132. B.node_left,
  133. B.node_right,
  134. B.node_level,
  135. A.art_title,
  136. A.art_author,
  137. A.art_content,
  138. A.art_source,
  139. A.is_fixed,
  140. A.issued_at,
  141. A.editor_id,
  142. C.account_real_name AS editor_name,
  143. A.status
  144. FROM art AS A
  145. LEFT JOIN art_cat AS B ON(A.oc_id = B.oc_id AND A.art_cat_id= B.art_cat_id)
  146. LEFT JOIN account AS C ON(A.oc_id = C.oc_id AND A.editor_id = C.account_id)
  147. WHERE 1 = 1 AND A.deleted_flag = 0
  148. AND NOT EXISTS (
  149. SELECT
  150. *
  151. FROM ent_risk_point_art AS D
  152. WHERE A.oc_id = D.oc_id AND A.art_id = D.art_id AND D.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  153. )
  154. <if test="ocId != null">
  155. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  156. </if>
  157. <if test="keywords != null and keywords != ''">
  158. AND A.art_title like "%"#{keywords}"%"
  159. </if>
  160. <if test="artCatId != null ">
  161. AND B.art_cat_id = #{artCatId ,jdbcType=BIGINT}
  162. </if>
  163. <if test="nodeLeft != null and nodeRight != null">
  164. <![CDATA[
  165. AND B.node_left >= #{nodeLeft ,jdbcType=BIGINT}
  166. AND B.node_right <= #{nodeRight ,jdbcType=BIGINT}
  167. ]]>
  168. </if>
  169. ORDER BY A.issued_at DESC
  170. </select>
  171. </mapper>