CpsContentInfoMapper.xml 5.2 KB

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