SnapshotAttachMapper.xml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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.aqpt.mapper.SnapshotAttachMapper">
  4. <resultMap id="ExtDtoMap" type="com.zhyc.xps.aqpt.dto.SnapshotAttachDto">
  5. <result column="oc_id" property="ocId" jdbcType="BIGINT" />
  6. <result column="snapshot_id" property="snapshotId" jdbcType="BIGINT" />
  7. <result column="event_id" property="eventId" jdbcType="BIGINT" />
  8. <result column="file_id" property="fileId" jdbcType="BIGINT" />
  9. <result column="file_title" property="fileTitle" jdbcType="VARCHAR" />
  10. <result column="dir_id" property="dirId" jdbcType="BIGINT" />
  11. <result column="file_url" property="fileUrl" jdbcType="VARCHAR" />
  12. <result column="file_ext" property="fileExt" jdbcType="VARCHAR" />
  13. <result column="file_size" property="fileSize" jdbcType="BIGINT" />
  14. <result column="file_author" property="fileAuthor" jdbcType="VARCHAR" />
  15. <result column="file_desc" property="fileDesc" jdbcType="VARCHAR" />
  16. <result column="uploader_id" property="uploaderId" jdbcType="BIGINT" />
  17. <result column="uploader_name" property="uploaderName" jdbcType="VARCHAR" />
  18. <result column="uploaded_at" property="uploadedAt" jdbcType="TIMESTAMP"/>
  19. </resultMap>
  20. <sql id="AttachDto_Cols">
  21. A.oc_id,
  22. A.snapshot_id,
  23. A.event_id,
  24. A.file_id,
  25. B.file_title,
  26. B.dir_id,
  27. B.file_url,
  28. B.file_ext,
  29. B.file_size,
  30. B.file_author,
  31. B.file_desc,
  32. B.uploaded_by AS uploader_id,
  33. C.account_name AS uploader_name,
  34. B.uploaded_at
  35. </sql>
  36. <!--分页查询-->
  37. <select id="getByPage" parameterType="java.util.Map" resultMap="ExtDtoMap">
  38. SELECT
  39. <include refid="AttachDto_Cols"/>
  40. FROM snapshot_attach AS A
  41. LEFT JOIN doc_file AS B ON(A.oc_id = B.oc_id AND A.file_id = B.file_id)
  42. LEFT JOIN account AS C ON(B.oc_id = C.oc_id AND )
  43. WHERE B.deleted_flag = 0
  44. <if test="ocId != null">
  45. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  46. </if>
  47. <if test="snapshotId != null">
  48. AND A.snapshot_id = #{snapshotId ,jdbcType=BIGINT}
  49. </if>
  50. <if test="keyword != null and keyword != ''">
  51. AND B.file_title like "%"#{keyword}"%"
  52. </if>
  53. ORDER BY file_id ASC
  54. </select>
  55. <select id="getByList" resultMap="ExtDtoMap">
  56. SELECT
  57. <include refid="AttachDto_Cols"/>
  58. FROM snapshot_attach AS A
  59. LEFT JOIN doc_file AS B ON(A.oc_id = B.oc_id AND A.file_id = B.file_id )
  60. LEFT JOIN account AS C ON(B.oc_id = C.oc_id AND )
  61. WHERE A.deleted_flag = 0
  62. <if test="ocId != null">
  63. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  64. </if>
  65. <if test="snapshotId != null">
  66. AND A.snapshot_id = #{snapshotId ,jdbcType=BIGINT}
  67. </if>
  68. ORDER BY A.file_id ASC
  69. </select>
  70. <insert id="create" parameterType="com.zhyc.xps.aqpt.entity.SnapshotAttach">
  71. INSERT INTO snapshot_attach
  72. <trim prefix="(" suffix=")" suffixOverrides=",">
  73. <if test="ocId != null">
  74. oc_id,
  75. </if>
  76. <if test="snapshotId != null">
  77. snapshot_id,
  78. </if>
  79. <if test="eventId != null">
  80. event_id,
  81. </if>
  82. <if test="fileId != null">
  83. file_id,
  84. </if>
  85. <if test="createdBy != null">
  86. created_by,
  87. </if>
  88. <if test="createdAt != null">
  89. created_at,
  90. </if>
  91. </trim>
  92. <trim prefix="values (" suffix=")" suffixOverrides=",">
  93. <if test="ocId != null">
  94. #{ocId ,jdbcType=BIGINT},
  95. </if>
  96. <if test="snapshotId != null">
  97. #{snapshotId ,jdbcType=BIGINT},
  98. </if>
  99. <if test="eventId != null">
  100. #{eventId ,jdbcType=BIGINT},
  101. </if>
  102. <if test="fileId != null">
  103. #{fileId ,jdbcType=BIGINT},
  104. </if>
  105. <if test="createdBy != null">
  106. #{createdBy ,jdbcType=BIGINT},
  107. </if>
  108. <if test="createdAt != null">
  109. #{createdAt ,jdbcType=TIMESTAMP},
  110. </if>
  111. </trim>
  112. </insert>
  113. <!--删除-->
  114. <delete id="delete" parameterType="java.util.Map">
  115. DELETE FROM snapshot_attach
  116. WHERE 1 = 1
  117. <if test="ocId != null">
  118. AND oc_id = #{ocId ,jdbcType=BIGINT}
  119. </if>
  120. <if test="snapshotId != null">
  121. AND snapshot_id = #{snapshotId ,jdbcType=BIGINT}
  122. </if>
  123. <if test="eventId != null">
  124. AND event_id = #{eventId ,jdbcType=BIGINT}
  125. </if>
  126. <if test="fileId != null">
  127. AND file_id = #{fileId ,jdbcType=BIGINT}
  128. </if>
  129. </delete>
  130. </mapper>