CmProductArchiveContentMapper.xml 3.2 KB

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