CmProductArchiveContentMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.caimei365.manager.dao.productArchive.CmProductArchiveContentMapper">
  6. <resultMap type="CmProductArchiveContent" id="CmProductArchiveContentResult">
  7. <result property="id" column="id" />
  8. <result property="productArchiveId" column="productArchiveId" />
  9. <result property="title" column="title" />
  10. <result property="type" column="type" />
  11. <result property="content" column="content" />
  12. <result property="stageStatus" column="stageStatus" />
  13. <result property="allStatus" column="allStatus" />
  14. <result property="labelIds" column="labelIds" />
  15. <result property="addTime" column="addTime" />
  16. </resultMap>
  17. <sql id="selectCmProductArchiveContentVo">
  18. select
  19. cm_product_archive_content.id,
  20. cm_product_archive_content.productArchiveId,
  21. cm_product_archive_content.title,
  22. cm_product_archive_content.type,
  23. cm_product_archive_content.content,
  24. cm_product_archive_content.stageStatus,
  25. cm_product_archive_content.allStatus,
  26. cm_product_archive_content.labelIds,
  27. cm_product_archive_content.createBy,
  28. cm_product_archive_content.addTime
  29. </sql>
  30. <select id="getByCmProductArchiveContent" parameterType="CmProductArchiveContent" resultMap="CmProductArchiveContentResult">
  31. <include refid="selectCmProductArchiveContentVo"/>
  32. ,(SELECT GROUP_CONCAT(cusf.keyword) FROM cm_user_search_frequency cusf WHERE FIND_IN_SET(cusf.id ,cm_product_archive_content.labelIds)) as keywords
  33. from cm_product_archive_content AS cm_product_archive_content
  34. <where>
  35. <if test="id != null and id != ''"> and cm_product_archive_content.id = #{id}</if>
  36. <if test="productArchiveId != null "> and cm_product_archive_content.productArchiveId = #{productArchiveId}</if>
  37. <if test="title != null and title != ''"> and cm_product_archive_content.title = #{title}</if>
  38. <if test="type != null and type != ''"> and cm_product_archive_content.type = #{type}</if>
  39. <if test="content != null and content != ''"> and cm_product_archive_content.content = #{content}</if>
  40. <if test="stageStatus != null "> and cm_product_archive_content.stageStatus = #{stageStatus}</if>
  41. <if test="allStatus != null "> and cm_product_archive_content.allStatus = #{allStatus}</if>
  42. <if test="labelIds != null and labelIds != ''"> and cm_product_archive_content.labelIds = #{labelIds}</if>
  43. <if test="createBy != null and createBy != ''"> and cm_product_archive_content.createBy = #{createBy}</if>
  44. <if test="addTime != null "> and cm_product_archive_content.addTime = #{addTime}</if>
  45. </where>
  46. group by cm_product_archive_content.id
  47. limit 0,1
  48. </select>
  49. <select id="getCmProductArchiveContentList" parameterType="CmProductArchiveContent" resultMap="CmProductArchiveContentResult">
  50. <include refid="selectCmProductArchiveContentVo"/>
  51. ,IFNULL((select sum(c.pv) from cm_praise_statistics c where c.delFlag = 0 and c.type = 1 and cm_product_archive_content.id = c.authorId <if test="startPvCreateTime != null ">AND c.createTime >= #{startPvCreateTime} </if><if test="endPvCreateTime != null ">AND c.createTime <![CDATA[ <= ]]> #{endPvCreateTime} </if>), 0) as pv
  52. ,(SELECT GROUP_CONCAT(cusf.keyword) FROM cm_user_search_frequency cusf WHERE FIND_IN_SET(cusf.id ,cm_product_archive_content.labelIds)) as keywords
  53. from cm_product_archive_content AS cm_product_archive_content
  54. <where>
  55. <if test="id != null and id != ''"> and cm_product_archive_content.id = #{id}</if>
  56. <if test="productArchiveId != null "> and cm_product_archive_content.productArchiveId = #{productArchiveId}</if>
  57. <if test="title != null and title != ''"> and cm_product_archive_content.title like concat('%', #{title}, '%')</if>
  58. <if test="type != null and type != ''">
  59. and cm_product_archive_content.type
  60. <if test="type.toUpperCase().indexOf('=')==-1">
  61. = #{type}
  62. </if>
  63. <if test="type.toUpperCase().indexOf('=')!=-1">
  64. <if test="type.toUpperCase().indexOf('NOT')!=-1"> not </if>
  65. <if test="type.toUpperCase().indexOf('IN')!=-1"> in </if>
  66. <foreach item="typeIn" collection="type.substring(type.toUpperCase().indexOf('=')+1,type.length()).trim().split(',')" open="(" separator="," close=")">
  67. #{typeIn}
  68. </foreach>
  69. </if>
  70. </if>
  71. <if test="content != null and content != ''"> and cm_product_archive_content.content = #{content}</if>
  72. <if test="stageStatus != null "> and cm_product_archive_content.stageStatus = #{stageStatus}</if>
  73. <if test="allStatus != null "> and cm_product_archive_content.allStatus = #{allStatus}</if>
  74. <if test="labelIds != null and labelIds != ''">
  75. AND
  76. <foreach item="labelIdIn" collection="labelIds.split(',')" open="(" separator="or" close=")">
  77. cm_product_archive_content.labelIds like concat('%', #{labelIdIn}, '%')
  78. </foreach>
  79. </if>
  80. <if test="createBy != null and createBy != ''"> and cm_product_archive_content.createBy = #{createBy}</if>
  81. <if test="addTime != null "> and cm_product_archive_content.addTime = #{addTime}</if>
  82. </where>
  83. group by cm_product_archive_content.id
  84. order by cm_product_archive_content.addTime desc
  85. </select>
  86. <select id="getCount" parameterType="CmProductArchiveContent" resultType="int">
  87. select count(1)
  88. from cm_product_archive_content AS cm_product_archive_content
  89. <where>
  90. <if test="id != null and id != ''"> and cm_product_archive_content.id = #{id}</if>
  91. <if test="productArchiveId != null "> and cm_product_archive_content.productArchiveId = #{productArchiveId}</if>
  92. <if test="title != null and title != ''"> and cm_product_archive_content.title = #{title}</if>
  93. <if test="type != null and type != ''"> and cm_product_archive_content.type = #{type}</if>
  94. <if test="content != null and content != ''"> and cm_product_archive_content.content = #{content}</if>
  95. <if test="stageStatus != null "> and cm_product_archive_content.stageStatus = #{stageStatus}</if>
  96. <if test="allStatus != null "> and cm_product_archive_content.allStatus = #{allStatus}</if>
  97. <if test="labelIds != null and labelIds != ''"> and cm_product_archive_content.labelIds = #{labelIds}</if>
  98. <if test="createBy != null and createBy != ''"> and cm_product_archive_content.createBy = #{createBy}</if>
  99. <if test="addTime != null "> and cm_product_archive_content.addTime = #{addTime}</if>
  100. </where>
  101. </select>
  102. <select id="getCmProductArchiveContentById" parameterType="String" resultMap="CmProductArchiveContentResult">
  103. <include refid="selectCmProductArchiveContentVo"/>
  104. from cm_product_archive_content AS cm_product_archive_content
  105. where cm_product_archive_content.id = #{id}
  106. </select>
  107. <select id="getById" parameterType="CmProductArchiveContent" resultType="String">
  108. select id
  109. from cm_product_archive_content AS cm_product_archive_content
  110. <where>
  111. <if test="id != null and id != ''"> and cm_product_archive_content.id = #{id}</if>
  112. <if test="productArchiveId != null "> and cm_product_archive_content.productArchiveId = #{productArchiveId}</if>
  113. <if test="title != null and title != ''"> and cm_product_archive_content.title = #{title}</if>
  114. <if test="type != null and type != ''"> and cm_product_archive_content.type = #{type}</if>
  115. <if test="content != null and content != ''"> and cm_product_archive_content.content = #{content}</if>
  116. <if test="stageStatus != null "> and cm_product_archive_content.stageStatus = #{stageStatus}</if>
  117. <if test="allStatus != null "> and cm_product_archive_content.allStatus = #{allStatus}</if>
  118. <if test="labelIds != null and labelIds != ''"> and cm_product_archive_content.labelIds = #{labelIds}</if>
  119. <if test="createBy != null and createBy != ''"> and cm_product_archive_content.createBy = #{createBy}</if>
  120. <if test="addTime != null "> and cm_product_archive_content.addTime = #{addTime}</if>
  121. </where>
  122. group by cm_product_archive_content.id
  123. limit 0,1
  124. </select>
  125. <insert id="addCmProductArchiveContent" parameterType="CmProductArchiveContent" useGeneratedKeys="true" keyProperty="id">
  126. insert into cm_product_archive_content
  127. <trim prefix="(" suffix=")" suffixOverrides=",">
  128. <if test="id != null and id != ''">id,</if>
  129. <if test="productArchiveId != null">productArchiveId,</if>
  130. <if test="title != null and title != ''">title,</if>
  131. <if test="type != null and type != ''">type,</if>
  132. <if test="content != null and content != ''">content,</if>
  133. <if test="stageStatus != null">stageStatus,</if>
  134. <if test="allStatus != null">allStatus,</if>
  135. <if test="labelIds != null and labelIds != ''">labelIds,</if>
  136. <if test="createBy != null and createBy != ''">createBy,</if>
  137. <if test="addTime != null">addTime,</if>
  138. </trim>
  139. <trim prefix="values (" suffix=")" suffixOverrides=",">
  140. <if test="id != null and id != ''">#{id},</if>
  141. <if test="productArchiveId != null">#{productArchiveId},</if>
  142. <if test="title != null and title != ''">#{title},</if>
  143. <if test="type != null and type != ''">#{type},</if>
  144. <if test="content != null and content != ''">#{content},</if>
  145. <if test="stageStatus != null">#{stageStatus},</if>
  146. <if test="allStatus != null">#{allStatus},</if>
  147. <if test="labelIds != null and labelIds != ''">#{labelIds},</if>
  148. <if test="createBy != null and createBy != ''">#{createBy},</if>
  149. <if test="addTime != null">#{addTime},</if>
  150. </trim>
  151. </insert>
  152. <update id="updateCmProductArchiveContent" parameterType="CmProductArchiveContent">
  153. update cm_product_archive_content
  154. <trim prefix="SET" suffixOverrides=",">
  155. <if test="productArchiveId != null">productArchiveId = #{productArchiveId},</if>
  156. <if test="title != null and title != ''">title = #{title},</if>
  157. <if test="type != null and type != ''">type = #{type},</if>
  158. <if test="content != null and content != ''">content = #{content},</if>
  159. <if test="stageStatus != null">stageStatus = #{stageStatus},</if>
  160. <if test="allStatus != null">allStatus = #{allStatus},</if>
  161. <if test="labelIds != null and labelIds != ''">labelIds = #{labelIds},</if>
  162. <if test="createBy != null and createBy != ''">createBy = #{createBy},</if>
  163. <if test="addTime != null">addTime = #{addTime},</if>
  164. </trim>
  165. where id = #{id}
  166. </update>
  167. <delete id="delCmProductArchiveContentById" parameterType="String">
  168. delete
  169. from cm_product_archive_content where id = #{id}
  170. </delete>
  171. <delete id="delCmProductArchiveContent" parameterType="CmProductArchiveContent">
  172. delete
  173. from cm_product_archive_content AS cm_product_archive_content
  174. <where>
  175. <if test="id != null and id != ''"> and cm_product_archive_content.id = #{id}</if>
  176. <if test="productArchiveId != null "> and cm_product_archive_content.productArchiveId = #{productArchiveId}</if>
  177. <if test="title != null and title != ''"> and cm_product_archive_content.title = #{title}</if>
  178. <if test="type != null and type != ''"> and cm_product_archive_content.type = #{type}</if>
  179. <if test="content != null and content != ''"> and cm_product_archive_content.content = #{content}</if>
  180. <if test="stageStatus != null "> and cm_product_archive_content.stageStatus = #{stageStatus}</if>
  181. <if test="allStatus != null "> and cm_product_archive_content.allStatus = #{allStatus}</if>
  182. <if test="labelIds != null and labelIds != ''"> and cm_product_archive_content.labelIds = #{labelIds}</if>
  183. <if test="createBy != null and createBy != ''"> and cm_product_archive_content.createBy = #{createBy}</if>
  184. <if test="addTime != null "> and cm_product_archive_content.addTime = #{addTime}</if>
  185. </where>
  186. </delete>
  187. </mapper>