ArtAttachMapper.xml 4.5 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.zhyc.xps.sys.mapper.ArtAttachMapper">
  4. <resultMap id="ArtAttachDtoMap" type="com.zhyc.xps.common.dto.AttachDto">
  5. <result column="file_id" property="fileId" jdbcType="BIGINT" />
  6. <result column="file_title" property="fileTitle" jdbcType="VARCHAR" />
  7. <result column="dir_id" property="dirId" jdbcType="BIGINT" />
  8. <result column="file_url" property="fileUrl" jdbcType="VARCHAR" />
  9. <result column="file_icon" property="fileIcon" jdbcType="VARCHAR" />
  10. <result column="file_ext" property="fileExt" jdbcType="VARCHAR" />
  11. <result column="file_size" property="fileSize" jdbcType="BIGINT" />
  12. <result column="file_author" property="fileAuthor" jdbcType="VARCHAR" />
  13. <result column="file_desc" property="fileDesc" jdbcType="VARCHAR" />
  14. <result column="uploader_name" property="uploaderName" jdbcType="VARCHAR" />
  15. <result column="uploader_id" property="uploaderId" jdbcType="BIGINT" />
  16. <result column="uploaded_at" property="uploadedAt" jdbcType="TIMESTAMP"/>
  17. </resultMap>
  18. <sql id="ArtAttachDto_Cols">
  19. A.file_id,
  20. B.file_title,
  21. B.dir_id,
  22. B.file_icon,
  23. B.file_url,
  24. B.file_ext,
  25. B.file_size,
  26. B.file_author,
  27. B.file_desc,
  28. B.uploaded_by AS uploader_id,
  29. C.account_name AS unloader_name,
  30. B.uploaded_at
  31. </sql>
  32. <!--分页查询-->
  33. <select id="getByPage" parameterType="java.util.Map" resultMap="ArtAttachDtoMap">
  34. SELECT
  35. <include refid="ArtAttachDto_Cols"/>
  36. FROM art_attach AS A
  37. LEFT JOIN doc_file AS B ON(A.oc_id = B.oc_id AND A.file_id = B.file_id)
  38. LEFT JOIN account AS C ON(B.oc_id = C.oc_id AND B.uploaded_by = C.account_id)
  39. WHERE A.oc_id = #{ocId ,jdbcType=BIGINT} AND B.deleted_flag = 0
  40. <if test="artId != null">
  41. AND A.art_id = #{artId ,jdbcType=BIGINT}
  42. </if>
  43. <if test="keywords != null and keywords != ''">
  44. AND B.file_title like "%"#{keywords}"%"
  45. </if>
  46. ORDER BY A.file_id ASC
  47. </select>
  48. <!--列表查询-->
  49. <select id="getByList" parameterType="java.util.Map" resultMap="ArtAttachDtoMap">
  50. SELECT
  51. <include refid="ArtAttachDto_Cols"/>
  52. FROM art_attach AS A
  53. LEFT JOIN doc_file AS B ON(A.oc_id = B.oc_id AND A.file_id = B.file_id)
  54. LEFT JOIN account AS C ON(B.oc_id = C.oc_id AND B.uploaded_by = C.account_id)
  55. WHERE A.oc_id = #{ocId ,jdbcType=BIGINT} AND B.deleted_flag = 0
  56. <if test="artId != null">
  57. AND A.art_id = #{artId ,jdbcType=BIGINT}
  58. </if>
  59. <if test="keywords != null and keywords != ''">
  60. AND B.file_title like "%"#{keywords}"%"
  61. </if>
  62. ORDER BY A.file_id ASC
  63. </select>
  64. <!--新增-->
  65. <insert id="create" parameterType="com.zhyc.xps.sys.entity.ArtAttach">
  66. INSERT INTO art_attach
  67. <trim prefix="(" suffix=")" suffixOverrides=",">
  68. <if test="ocId != null">
  69. oc_id,
  70. </if>
  71. <if test="artId != null">
  72. art_id,
  73. </if>
  74. <if test="fileId != null">
  75. file_id,
  76. </if>
  77. </trim>
  78. <trim prefix="values (" suffix=")" suffixOverrides=",">
  79. <if test="ocId != null">
  80. #{ocId ,jdbcType=BIGINT},
  81. </if>
  82. <if test="artId != null">
  83. #{artId ,jdbcType=BIGINT},
  84. </if>
  85. <if test="fileId != null">
  86. #{fileId ,jdbcType=BIGINT},
  87. </if>
  88. </trim>
  89. </insert>
  90. <!--删除-->
  91. <delete id="delete" parameterType="java.util.Map">
  92. DELETE FROM art_attach
  93. WHERE oc_id = #{ocId ,jdbcType=BIGINT}
  94. <if test="artId != null">
  95. AND art_id = #{artId ,jdbcType=BIGINT}
  96. </if>
  97. <if test="fileId != null">
  98. AND file_id = #{fileId ,jdbcType=BIGINT}
  99. </if>
  100. </delete>
  101. </mapper>