TodoAttachMapper.xml 5.5 KB

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