CpsContentInfoMapper.xml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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.ruoyi.system.mapper.CpsContentInfoMapper">
  6. <resultMap type="com.ruoyi.system.domain.CpsContentInfo" id="CpsContentInfoResult">
  7. <result property="id" column="id"/>
  8. <result property="title" column="title"/>
  9. <result property="content" column="content"/>
  10. <result property="thumbnail" column="thumbnail"/>
  11. <result property="likeCnt" column="like_cnt"/>
  12. <result property="collectedCnt" column="collected_cnt"/>
  13. <result property="contentType" column="content_type"/>
  14. <result property="deptId" column="dept_id"/>
  15. <result property="updateTime" column="update_time"/>
  16. <result property="createTime" column="create_time"/>
  17. <result property="createBy" column="create_by"/>
  18. <result property="updateBy" column="update_by"/>
  19. </resultMap>
  20. <sql id="selectCpsContentInfoVo">
  21. select id,
  22. title,
  23. content,
  24. thumbnail,
  25. content_type,
  26. like_cnt,
  27. collected_cnt,
  28. dept_id,
  29. update_time,
  30. create_time,
  31. create_by,
  32. update_by
  33. from cps_content_info
  34. </sql>
  35. <select id="selectCpsContentInfoList" parameterType="com.ruoyi.system.domain.CpsContentInfo"
  36. resultMap="CpsContentInfoResult">
  37. select id, title, thumbnail, content_type,like_cnt, collected_cnt,dept_id, update_time, create_time, create_by,
  38. update_by from cps_content_info
  39. <where>
  40. <if test="title != null and title != ''">and title like concat('%', #{title}, '%')</if>
  41. <if test="content != null and content != ''">and content like concat('%', #{content}, '%')</if>
  42. <if test="contentType != null ">and content_type = #{contentType}</if>
  43. </where>
  44. order by create_time desc
  45. </select>
  46. <select id="selectCpsContentInfoById" parameterType="Long" resultMap="CpsContentInfoResult">
  47. <include refid="selectCpsContentInfoVo"/>
  48. where id = #{id}
  49. </select>
  50. <insert id="insertCpsContentInfo" parameterType="com.ruoyi.system.domain.CpsContentInfo" useGeneratedKeys="true"
  51. keyProperty="id">
  52. insert into cps_content_info
  53. <trim prefix="(" suffix=")" suffixOverrides=",">
  54. <if test="title != null">title,</if>
  55. <if test="content != null">content,</if>
  56. <if test="thumbnail != null">thumbnail,</if>
  57. <if test="contentType != null">content_type,</if>
  58. <if test="deptId !=null">dept_id,</if>
  59. <if test="updateTime != null">update_time,</if>
  60. <if test="createTime != null">create_time,</if>
  61. <if test="createBy != null">create_by,</if>
  62. <if test="updateBy != null">update_by,</if>
  63. </trim>
  64. <trim prefix="values (" suffix=")" suffixOverrides=",">
  65. <if test="title != null">#{title},</if>
  66. <if test="content != null">#{content},</if>
  67. <if test="thumbnail != null">#{thumbnail},</if>
  68. <if test="contentType != null">#{contentType},</if>
  69. <if test="deptId !=null">#{deptId},</if>
  70. <if test="updateTime != null">#{updateTime},</if>
  71. <if test="createTime != null">#{createTime},</if>
  72. <if test="createBy != null">#{createBy},</if>
  73. <if test="updateBy != null">#{updateBy},</if>
  74. </trim>
  75. </insert>
  76. <update id="updateCpsContentInfo" parameterType="com.ruoyi.system.domain.CpsContentInfo">
  77. update cps_content_info
  78. <trim prefix="SET" suffixOverrides=",">
  79. <if test="title != null">title = #{title},</if>
  80. <if test="content != null">content = #{content},</if>
  81. <if test="thumbnail != null">thumbnail = #{thumbnail},</if>
  82. <if test="contentType != null">content_type = #{contentType},</if>
  83. <if test="deptId !=null">dept_id = #{deptId},</if>
  84. <if test="updateTime != null">update_time = #{updateTime},</if>
  85. <if test="createTime != null">create_time = #{createTime},</if>
  86. <if test="createBy != null">create_by = #{createBy},</if>
  87. <if test="updateBy != null">update_by = #{updateBy},</if>
  88. </trim>
  89. where id = #{id}
  90. </update>
  91. <update id="updateCollectContent" parameterType="java.lang.Long">
  92. update cps_content_info
  93. set collected_cnt = collected_cnt + 1,
  94. update_time = now()
  95. where id = #{id}
  96. </update>
  97. <update id="updateDisCollectContent" parameterType="java.lang.Long">
  98. update cps_content_info
  99. set collected_cnt = collected_cnt - 1,
  100. update_time = now()
  101. where id = #{id}
  102. </update>
  103. <update id="updateLikeContent" parameterType="java.lang.Long">
  104. update cps_content_info
  105. set like_cnt = like_cnt + 1,
  106. update_time = now()
  107. where id = #{id}
  108. </update>
  109. <update id="updateDisLikeContent" parameterType="java.lang.Long">
  110. update cps_content_info
  111. set like_cnt = like_cnt - 1,
  112. update_time = now()
  113. where id = #{id}
  114. </update>
  115. <delete id="deleteCpsContentInfoById" parameterType="Long">
  116. delete
  117. from cps_content_info
  118. where id = #{id}
  119. </delete>
  120. <delete id="deleteCpsContentInfoByIds" parameterType="String">
  121. delete from cps_content_info where id in
  122. <foreach item="id" collection="array" open="(" separator="," close=")">
  123. #{id}
  124. </foreach>
  125. </delete>
  126. <select id="selectCpsContentInfoByIds" parameterType="String" resultMap="CpsContentInfoResult">
  127. <include refid="selectCpsContentInfoVo"/>
  128. where id in
  129. <foreach item="id" collection="array" open="(" separator="," close=")">
  130. #{id}
  131. </foreach>
  132. </select>
  133. </mapper>