DocFileMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  4. <mapper namespace="com.zhyc.xps.sys.mapper.DocFileMapper">
  5. <resultMap id="DocFileDtoResultMap" type="com.zhyc.xps.sys.dto.DocFileDto">
  6. <result column="oc_id" property="ocId" jdbcType="BIGINT" /><!--ID-->
  7. <result column="file_id" property="fileId" jdbcType="BIGINT" /><!--FILE ID-->
  8. <result column="file_title" property="fileTitle" jdbcType="VARCHAR" />
  9. <result column="dir_id" property="dirId" jdbcType="BIGINT" /><!--DIR ID-->
  10. <result column="file_icon" property="fileIcon" jdbcType="VARCHAR" />
  11. <result column="file_mime_type" property="fileMimeType" jdbcType="VARCHAR" />
  12. <result column="file_url" property="fileUrl" jdbcType="VARCHAR" />
  13. <result column="file_ext" property="fileExt" jdbcType="VARCHAR" />
  14. <result column="file_size" property="fileSize" jdbcType="BIGINT" />
  15. <result column="file_author" property="fileAuthor" jdbcType="VARCHAR" />
  16. <result column="file_desc" property="fileDesc" jdbcType="VARCHAR" />
  17. <result column="unloader_name" property="uploaderName" jdbcType="VARCHAR" />
  18. <result column="uploader_id" property="uploaderId" jdbcType="BIGINT" />
  19. <result column="uploaded_at" property="uploadedAt" jdbcType="TIMESTAMP" />
  20. </resultMap>
  21. <sql id="DocFileDto_Cols">
  22. A.oc_id,
  23. A.file_id,
  24. A.file_title,
  25. A.dir_id,
  26. A.file_icon,
  27. A.file_url,
  28. A.file_ext,
  29. A.file_mime_type,
  30. A.file_size,
  31. A.file_author,
  32. A.file_desc,
  33. A.uploaded_by AS uploader_id,
  34. B.account_name AS unloader_name,
  35. A.uploaded_at
  36. </sql>
  37. <!--根据ID获取群组信息-->
  38. <select id="getById" resultMap="DocFileDtoResultMap">
  39. SELECT
  40. <include refid="DocFileDto_Cols"/>
  41. FROM doc_file AS A
  42. LEFT JOIN account AS B ON (A.oc_id = B.oc_id AND A.uploaded_by = B.account_id)
  43. WHERE A.deleted_flag = 0
  44. <if test="ocId != null">
  45. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  46. </if>
  47. <if test="fileId !=null">
  48. AND A.file_id = #{fileId ,jdbcType=BIGINT}
  49. </if>
  50. </select>
  51. <!--分页查询-->
  52. <select id="getByPage" resultMap="DocFileDtoResultMap" parameterType="java.util.Map">
  53. SELECT
  54. <include refid="DocFileDto_Cols"/>
  55. FROM doc_file AS A
  56. LEFT JOIN account AS B ON (A.oc_id = B.oc_id AND A.uploaded_by = B.account_id)
  57. WHERE A.deleted_flag = 0
  58. <if test="ocId != null">
  59. AND A.oc_id = #{ocId, jdbcType=BIGINT}
  60. </if>
  61. <if test="dirId != null">
  62. AND A.dir_id = #{dirId, jdbcType=BIGINT}
  63. </if>
  64. <if test="keywords != null and keywords != ''">
  65. AND A.file_title like "%"#{keywords}"%"
  66. </if>
  67. order by A.created_at DESC
  68. </select>
  69. <!--列表查询-->
  70. <select id="getByList" resultMap="DocFileDtoResultMap" parameterType="java.util.Map">
  71. SELECT
  72. <include refid="DocFileDto_Cols"/>
  73. FROM doc_file AS A
  74. LEFT JOIN account AS B ON (A.oc_id = B.oc_id AND A.uploaded_by = B.account_id)
  75. WHERE A.deleted_flag = 0
  76. <if test="ocId != null">
  77. AND A.oc_id = #{ocId, jdbcType=BIGINT}
  78. </if>
  79. <if test="dirId != null">
  80. AND A.dir_id = #{dirId, jdbcType=BIGINT}
  81. </if>
  82. <if test="keywords != null and keywords != ''">
  83. AND A.file_title like "%"#{keywords}"%"
  84. </if>
  85. order by A.created_at DESC
  86. </select>
  87. <!--Create-->
  88. <insert id="create" parameterType="com.zhyc.xps.sys.entity.DocFile">
  89. INSERT INTO doc_file
  90. <trim prefix="(" suffix=")" suffixOverrides=",">
  91. <if test="ocId != null">
  92. oc_id,
  93. </if>
  94. <if test="fileId != null">
  95. file_id,
  96. </if>
  97. <if test="fileTitle != null and fileTitle!=''">
  98. file_title,
  99. </if>
  100. <if test="dirId != null">
  101. dir_id,
  102. </if>
  103. <if test="fileUrl != null and fileUrl != ''">
  104. file_url,
  105. </if>
  106. <if test="fileIcon != null and fileIcon != ''">
  107. file_icon,
  108. </if>
  109. <if test="fileExt != null and fileExt != ''">
  110. file_ext,
  111. </if>
  112. <if test="fileMimeType != null and fileMimeType != ''">
  113. file_mime_type,
  114. </if>
  115. <if test="fileSize != null">
  116. file_size,
  117. </if>
  118. <if test="fileAuthor != null and fileAuthor != ''">
  119. file_author,
  120. </if>
  121. <if test="fileDesc != null and fileDesc != ''">
  122. file_desc,
  123. </if>
  124. <if test="uploadedBy != null">
  125. uploaded_by,
  126. </if>
  127. <if test="uploadedAt != null">
  128. uploaded_at,
  129. </if>
  130. <if test="createdBy != null">
  131. created_by,
  132. </if>
  133. <if test="createdAt != null">
  134. created_at,
  135. </if>
  136. </trim>
  137. <trim prefix="values (" suffix=")" suffixOverrides=",">
  138. <if test="ocId != null">
  139. #{ocId ,jdbcType=BIGINT},
  140. </if>
  141. <if test="fileId != null">
  142. #{fileId ,jdbcType=BIGINT},
  143. </if>
  144. <if test="fileTitle != null and fileTitle!=''">
  145. #{fileTitle ,jdbcType=VARCHAR},
  146. </if>
  147. <if test="dirId != null">
  148. #{dirId ,jdbcType=BIGINT},
  149. </if>
  150. <if test="fileUrl != null and fileUrl != ''">
  151. #{fileUrl ,jdbcType=VARCHAR},
  152. </if>
  153. <if test="fileIcon != null and fileIcon != ''">
  154. #{fileIcon ,jdbcType=VARCHAR},
  155. </if>
  156. <if test="fileExt != null and fileExt != ''">
  157. #{fileExt ,jdbcType=VARCHAR},
  158. </if>
  159. <if test="fileMimeType != null and fileMimeType != ''">
  160. #{fileMimeType ,jdbcType=VARCHAR},
  161. </if>
  162. <if test="fileSize != null">
  163. #{fileSize ,jdbcType=BIGINT},
  164. </if>
  165. <if test="fileAuthor != null and fileAuthor != ''">
  166. #{fileAuthor ,jdbcType=VARCHAR},
  167. </if>
  168. <if test="fileDesc != null and fileDesc != ''">
  169. #{fileDesc ,jdbcType=VARCHAR},
  170. </if>
  171. <if test="uploadedBy != null">
  172. #{uploadedBy ,jdbcType=BIGINT},
  173. </if>
  174. <if test="uploadedAt != null">
  175. #{uploadedAt ,jdbcType=TIMESTAMP},
  176. </if>
  177. <if test="createdBy != null">
  178. #{createdBy ,jdbcType=BIGINT},
  179. </if>
  180. <if test="createdAt != null">
  181. #{createdAt ,jdbcType=TIMESTAMP},
  182. </if>
  183. </trim>
  184. </insert>
  185. <!--更新群组-->
  186. <update id="update" parameterType="com.zhyc.xps.sys.entity.DocFile">
  187. UPDATE doc_file
  188. <trim suffixOverrides=",">
  189. <set>
  190. <if test="fileTitle != null and fileTitle!=''">
  191. file_title = #{fileTitle ,jdbcType=VARCHAR},
  192. </if>
  193. <if test="dirId != null">
  194. dir_id = #{dirId ,jdbcType=BIGINT},
  195. </if>
  196. <if test="fileUrl != null and fileUrl != ''">
  197. file_url = #{fileUrl ,jdbcType=VARCHAR},
  198. </if>
  199. <if test="fileExt != null and fileExt != ''">
  200. file_ext = #{fileExt ,jdbcType=VARCHAR},
  201. </if>
  202. <if test="fileMimeType != null and fileMimeType != ''">
  203. file_mime_type = #{fileMimeType ,jdbcType=VARCHAR},
  204. </if>
  205. <if test="fileSize != null">
  206. file_size = #{fileSize ,jdbcType=BIGINT},
  207. </if>
  208. <if test="fileAuthor != null and fileAuthor != ''">
  209. file_author = #{fileAuthor ,jdbcType=VARCHAR},
  210. </if>
  211. <if test="fileDesc != null and fileDesc != ''">
  212. file_desc = #{fileDesc ,jdbcType=VARCHAR},
  213. </if>
  214. <if test="uploadedBy != null">
  215. uploaded_by = #{uploadedBy ,jdbcType=BIGINT},
  216. </if>
  217. <if test="uploadedAt != null">
  218. uploaded_at = #{uploadedAt ,jdbcType=TIMESTAMP},
  219. </if>
  220. <if test="updatedBy != null">
  221. updated_by = #{updatedBy ,jdbcType=BIGINT},
  222. </if>
  223. <if test="updatedAt != null">
  224. updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
  225. </if>
  226. </set>
  227. </trim>
  228. WHERE file_id = #{fileId ,jdbcType=BIGINT}
  229. <if test="ocId != null">
  230. AND oc_id = #{ocId ,jdbcType=BIGINT}
  231. </if>
  232. </update>
  233. <!--删除 -->
  234. <update id="delete" parameterType="java.util.Map">
  235. UPDATE doc_file
  236. <trim suffixOverrides=",">
  237. <set>
  238. <if test="deletedBy != null">
  239. deleted_by = #{deletedBy ,jdbcType=BIGINT},
  240. </if>
  241. <if test="deletedAt != null">
  242. deleted_at = #{deletedAt ,jdbcType=DATE},
  243. </if>
  244. <if test="deletedFlag != null">
  245. deleted_flag = #{deletedFlag ,jdbcType=BIGINT},
  246. </if>
  247. </set>
  248. </trim>
  249. WHERE 1 = 1 AND deleted_flag = 0
  250. <if test="ocId != null">
  251. AND oc_id = #{ocId,jdbcType=BIGINT}
  252. </if>
  253. <if test="fileId != null ">
  254. AND file_id = #{fileId ,jdbcType=BIGINT}
  255. </if>
  256. </update>
  257. <!--获取子项数目-->
  258. <select id="getFileCountOfDir" parameterType="java.util.Map" resultType="java.lang.Long">
  259. SELECT
  260. count(*)
  261. FROM doc_file AS A
  262. WHERE A.deleted_flag = 0
  263. <if test="ocId != null">
  264. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  265. </if>
  266. <if test="dirId != null ">
  267. AND A.dir_id = #{dirId ,jdbcType=BIGINT}
  268. </if>
  269. </select>
  270. </mapper>