CmProductArchiveContentMapper.xml 3.3 KB

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