FileMapper.xml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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.mapper.cmMapper.FileMapper">
  4. <insert id="insertFile" keyColumn="id" keyProperty="id" parameterType="com.caimei.model.po.FilePo" useGeneratedKeys="true">
  5. insert into cm_brand_file(authUserId, fileType, title, name, previewUrl, downloadUrl, auditStatus, status,
  6. createTime, auditBy, auditTime, checkFlag)
  7. values (#{authUserId}, #{fileType}, #{title}, #{name}, #{previewUrl}, #{downloadUrl}, #{auditStatus}, #{status},
  8. #{createTime}, #{auditBy}, #{auditTime}, #{checkFlag})
  9. </insert>
  10. <insert id="insertCourseFile">
  11. insert into cm_brand_course_file (title, name, ossName, type, module, createTime)
  12. values (#{title}, #{name}, #{ossName}, #{fileType}, #{fileModule}, NOW());
  13. </insert>
  14. <update id="updateFileByFileId">
  15. update cm_brand_file
  16. set title = #{title},
  17. status = #{status},
  18. auditStatus = #{auditStatus}
  19. where id = #{id}
  20. </update>
  21. <update id="updateFileStatusByFileId">
  22. update cm_brand_file
  23. set status = #{status}
  24. where id = #{fileId}
  25. </update>
  26. <update id="updateFileAuditStatus">
  27. update cm_brand_file
  28. set status = #{status},
  29. auditStatus = #{auditStatus},
  30. invalidReason = #{invalidReason},
  31. auditBy = #{auditBy},
  32. auditTime = #{auditTime}
  33. where id = #{fileId}
  34. </update>
  35. <update id="updateFileSelective">
  36. update cm_brand_file
  37. <set>
  38. <if test="title != null and title != ''">
  39. title = #{title},
  40. </if>
  41. <if test="previewUrl != null and previewUrl != ''">
  42. previewUrl = #{previewUrl},
  43. </if>
  44. <if test="downloadUrl != null and downloadUrl != ''">
  45. downloadUrl = #{downloadUrl},
  46. </if>
  47. <if test="name != null and name != ''">
  48. name = #{name},
  49. </if>
  50. <if test="status != null">
  51. status = #{status},
  52. </if>
  53. <if test="auditStatus != null">
  54. auditStatus = #{auditStatus},
  55. </if>
  56. <if test="checkFlag != null">
  57. checkFlag = #{checkFlag},
  58. </if>
  59. </set>
  60. where id = #{id}
  61. </update>
  62. <update id="updateCourseFile">
  63. update cm_brand_course_file
  64. set title = #{title},
  65. name = #{name},
  66. ossName = #{ossName},
  67. type = #{fileType},
  68. module = #{fileModule}
  69. where id = #{id}
  70. </update>
  71. <update id="checkFile">
  72. update cm_brand_file
  73. set checkFlag = 1
  74. where id = #{fileId}
  75. </update>
  76. <delete id="deleteFileByFileId">
  77. delete from cm_brand_file where id = #{fileId}
  78. </delete>
  79. <delete id="deleteCourseFileByFileId">
  80. delete from cm_brand_course_file where id = #{fileId}
  81. </delete>
  82. <select id="getFileList" resultType="com.caimei.model.vo.FileListVo">
  83. select a.id as fileId,a.title as fileTitle,a.name as fileName,a.previewUrl as filePreviewUrl,
  84. a.downloadUrl as fileDownloadUrl, a.auditStatus,a.invalidReason,a.status,a.createTime,
  85. au.name as auditBy,a.auditTime,a.checkFlag
  86. from cm_brand_file a
  87. left join cm_brand_auth_user au on a.auditBy = au.authUserId
  88. where a.authUserId = #{authUserId} and fileType = #{fileType}
  89. <if test="fileTitle != null and fileTitle != ''">
  90. and a.title like concat('%',#{fileTitle},'%')
  91. </if>
  92. <if test="auditStatus != null">
  93. and a.auditStatus = #{auditStatus}
  94. </if>
  95. <if test="status != null">
  96. and a.status = #{status}
  97. </if>
  98. <choose>
  99. <when test="listType == 2">
  100. order by a.auditStatus desc, a.createTime desc
  101. </when>
  102. <otherwise>
  103. order by a.createTime desc
  104. </otherwise>
  105. </choose>
  106. </select>
  107. <select id="getWxFileList" resultType="com.caimei.model.vo.WxFileListVo">
  108. select id as fileId, title as fileTitle,name as fileName, previewUrl as filePreviewUrl, downloadUrl as
  109. fileDownloadUrl, date_format(createTime, '%Y-%m-%d') as createTime
  110. from cm_brand_file a
  111. where authUserId = #{authUserId}
  112. and status = 1
  113. and fileType = #{fileType}
  114. <if test="fileTitle != null and fileTitle != ''">
  115. and title like concat('%',#{fileTitle},'%')
  116. </if>
  117. order by a.createTime desc
  118. </select>
  119. <select id="getCourseFileList" resultType="com.caimei.model.vo.CourseFileListVo">
  120. select id as fileId, title as fileTitle, name as fileName, ossName, module as fileModule, createTime
  121. from cm_brand_course_file
  122. where type = #{fileType}
  123. <if test="fileTitle != null and fileTitle != ''">
  124. and title like concat('%',#{fileTitle},'%')
  125. </if>
  126. <if test="fileModule != null and fileModule != ''">
  127. and module = #{fileModule}
  128. </if>
  129. order by createTime desc
  130. </select>
  131. <select id="getAuthImageData" resultType="com.caimei.model.po.ProductImagePo">
  132. SELECT certificateImage as authImage, a.authParty, p.snCode
  133. FROM cm_brand_auth_product p
  134. left join cm_brand_product_relation r on p.id = r.productId
  135. left join cm_brand_auth a on r.authId = a.id
  136. left join cm_brand_auth_user u on a.authUserId = u.authUserId
  137. where u.authUserId = 4;
  138. </select>
  139. <select id="getProductImageList" resultType="com.caimei.model.po.ProductImagePo">
  140. SELECT p.id as productId, certificateImage, a.authParty, p.snCode,
  141. if(p.productTypeId is null,p.name,t.name) as productName
  142. FROM cm_brand_auth_product p
  143. left join cm_brand_product_relation r on p.id = r.productId
  144. left join cm_brand_auth a on r.authId = a.id
  145. left join cm_brand_auth_user u on a.authUserId = u.authUserId
  146. left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
  147. where a.delFlag = 0
  148. <if test="authId != null">
  149. and a.id = #{authId}
  150. </if>
  151. </select>
  152. <select id="getAuthImageList" resultType="com.caimei.model.vo.AuthVo">
  153. select a.id as authId, a.authUserId, a.authImage, a.authParty
  154. from cm_brand_auth a
  155. left join cm_brand_auth_user u on a.authUserId = u.authUserId
  156. where a.delFlag = 0
  157. and find_in_set(a.id, #{authIds})
  158. </select>
  159. <select id="getFileForm" resultType="com.caimei.model.po.FilePo">
  160. select id,auditStatus from cm_brand_file where id = #{fileId}
  161. </select>
  162. </mapper>