CmProductArchiveContentMapper.xml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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.caimei.modules.archive.dao.CmProductArchiveContentDao">
  4. <sql id="cmProductArchiveContentColumns">
  5. a.id AS "id",
  6. a.productArchiveId AS "productArchiveId",
  7. a.title AS "title",
  8. a.content AS "content",
  9. IFNULL(c.pv, 0) AS "actualPv",
  10. a.type AS "type",
  11. a.addTime AS "addTime",
  12. if(a.type=2,cf.ossName,ifnull(cf.waterOssName,cf.ossName)) as ossName,
  13. cf.fileName,
  14. cf.uploadTime,
  15. if(a.type=2,cf.ossUrl,ifnull(cf.waterOssUrl,cf.ossUrl)) as ossUrl
  16. </sql>
  17. <sql id="cmProductArchiveContentJoins">
  18. left join cm_product_archive_file cf on a.id = cf.archiveContentId and a.type != 1
  19. left join cm_praise_statistics c on a.id = c.authorId and c.type =1
  20. </sql>
  21. <select id="get" resultType="CmProductArchiveContent">
  22. SELECT
  23. <include refid="cmProductArchiveContentColumns"/>
  24. FROM cm_product_archive_content a
  25. <include refid="cmProductArchiveContentJoins"/>
  26. WHERE a.id = #{id}
  27. </select>
  28. <select id="findList" resultType="CmProductArchiveContent">
  29. SELECT
  30. <include refid="cmProductArchiveContentColumns"/>
  31. FROM cm_product_archive_content a
  32. <include refid="cmProductArchiveContentJoins"/>
  33. <where>
  34. <if test="title != null and title != ''">
  35. AND a.title LIKE
  36. <if test="dbName == 'oracle'">'%'||#{title}||'%'</if>
  37. <if test="dbName == 'mssql'">'%'+#{title}+'%'</if>
  38. <if test="dbName == 'mysql'">concat('%',#{title},'%')</if>
  39. </if>
  40. <if test="type != null">
  41. and a.type = #{type}
  42. </if>
  43. <if test="productArchiveId != null">
  44. and a.productArchiveId = #{productArchiveId}
  45. </if>
  46. </where>
  47. order by a.addTime desc
  48. </select>
  49. <select id="findAllList" resultType="CmProductArchiveContent">
  50. SELECT
  51. <include refid="cmProductArchiveContentColumns"/>
  52. FROM cm_product_archive_content a
  53. <include refid="cmProductArchiveContentJoins"/>
  54. <where>
  55. </where>
  56. <choose>
  57. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  58. ORDER BY ${page.orderBy}
  59. </when>
  60. <otherwise>
  61. </otherwise>
  62. </choose>
  63. </select>
  64. <select id="getImageList" resultType="com.caimei.modules.archive.entity.CmProductArchiveFile">
  65. select * from cm_product_archive_file where archiveContentId = #{id}
  66. </select>
  67. <select id="getDbFileId" resultType="java.lang.Integer">
  68. select id from cm_product_archive_file where archiveContentId = #{id} limit 1
  69. </select>
  70. <select id="findAllArchiveFile" resultType="com.caimei.modules.archive.entity.CmProductArchiveFile">
  71. select cf.id,fileName, ossName,waterOssName,ossUrl,uploadTime,cc.type as archiveContentType
  72. from cm_product_archive_file cf left join cm_product_archive_content cc on cf.archiveContentId = cc.id
  73. where cc.type != 2;
  74. </select>
  75. <insert id="insert" parameterType="CmProductArchiveContent" keyProperty="id" useGeneratedKeys="true">
  76. INSERT INTO cm_product_archive_content(
  77. productArchiveId,
  78. title,
  79. content,
  80. type,
  81. addTime
  82. ) VALUES (
  83. #{productArchiveId},
  84. #{title},
  85. #{content},
  86. #{type},
  87. now()
  88. )
  89. </insert>
  90. <insert id="insertFile" parameterType="CmProductArchiveFile" keyProperty="id" useGeneratedKeys="true">
  91. insert into cm_product_archive_file(archiveContentId, fileName, ossName, ossUrl, waterOssName, waterOssUrl,
  92. uploadTime)
  93. values (#{archiveContentId}, #{fileName}, #{ossName}, #{ossUrl}, #{waterOssName}, #{waterOssUrl}, now())
  94. </insert>
  95. <update id="update">
  96. UPDATE cm_product_archive_content SET
  97. title = #{title},
  98. content = #{content}
  99. WHERE id = #{id}
  100. </update>
  101. <update id="updateFile">
  102. update cm_product_archive_file
  103. set archiveContentId = #{archiveContentId}
  104. where id = #{fileId}
  105. </update>
  106. <update id="updateFileWaterMark">
  107. update cm_product_archive_file set waterOssName = #{waterOssName}, waterOssUrl = #{waterOssUrl}
  108. where id = #{id}
  109. </update>
  110. <delete id="delete">
  111. DELETE FROM cm_product_archive_content
  112. WHERE id = #{id}
  113. </delete>
  114. <delete id="deleteFile">
  115. delete from cm_product_archive_file where archiveContentId = #{archiveContentId}
  116. </delete>
  117. </mapper>