BizRecycleBinMapper.xml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="cn.ezhizao.project.business.recycleBin.mapper.BizRecycleBinMapper">
  6. <resultMap type="cn.ezhizao.project.business.recycleBin.domain.BizRecycleBin" id="BizRecycleBinResult">
  7. <id column="id" property="id"/>
  8. </resultMap>
  9. <select id="getList" parameterType="BizRecycleBin" resultMap="BizRecycleBinResult">
  10. SELECT * FROM biz_recycle_bin
  11. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  12. deleted = 0
  13. AND from_id = 0
  14. AND is_return = 0
  15. AND is_clean=0
  16. <if test="sourceTableName != null and sourceTableName != ''">AND source_table_name=#{sourceTableName}
  17. </if>
  18. <if test="sourceValue != null and sourceValue != ''">AND source_value like concat('%', #{sourceValue},
  19. '%')
  20. </if>
  21. <if test="isClean != null ">AND is_clean = #{isClean}</if>
  22. <if test="isReturn != null ">AND is_return = #{isReturn}</if>
  23. </trim>
  24. </select>
  25. <delete id="physicalDelete">
  26. DELETE FROM biz_recycle_bin
  27. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  28. <if test="id != null">
  29. id = #{id} AND
  30. </if>
  31. <!-- 删除条件为其他外键可以在这里加 -->
  32. </trim>
  33. </delete>
  34. <select id="getById" parameterType="BizRecycleBin" resultMap="BizRecycleBinResult">
  35. SELECT *
  36. FROM biz_recycle_bin
  37. WHERE id = #{id}
  38. </select>
  39. <!-- &#45;&#45; UPDATE ${table} t-->
  40. <!-- &#45;&#45; SET t.deleted=1-->
  41. <!-- &#45;&#45; WHERE t.company_id = ${id}-->
  42. <!-- 软删除客户关联子表数据 -->
  43. <update id="deleteData">
  44. <foreach collection="tabs" item="item" index="index" separator=";">
  45. UPDATE ${item}
  46. SET deleted=1
  47. WHERE company_id=#{id}
  48. </foreach>
  49. </update>
  50. <!-- 软删除客户关联子表数据 -->
  51. <update id="deleteArchiveData">
  52. <foreach collection="tabs" item="item" index="index" separator=";">
  53. UPDATE ${item}
  54. SET deleted=1
  55. WHERE contract_id=#{id}
  56. </foreach>
  57. </update>
  58. <!-- 还原客户关联子表数据 -->
  59. <update id="restoreData">
  60. <foreach collection="tabs" item="item" index="index" separator=";">
  61. UPDATE ${item}
  62. SET deleted=0
  63. WHERE company_id=#{id}
  64. </foreach>
  65. </update>
  66. <!-- 还原订单关联子表数据 -->
  67. <update id="restoreArchiveData">
  68. <foreach collection="tabs" item="item" index="index" separator=";">
  69. UPDATE ${item}
  70. SET deleted=0
  71. WHERE contract_id=#{id}
  72. </foreach>
  73. </update>
  74. <!-- 回收站数据还原 -->
  75. <update id="restore">
  76. UPDATE biz_recycle_bin
  77. SET is_return=1
  78. WHERE id = #{id}
  79. OR from_id = #{id}
  80. </update>
  81. <!-- 回收站数据删除 -->
  82. <update id="remove">
  83. UPDATE biz_recycle_bin
  84. SET is_clean=1,
  85. deleted=1
  86. WHERE id = #{id}
  87. OR from_id = #{id}
  88. </update>
  89. <!-- 还原用户表数据 -->
  90. <update id="restoreCompany">
  91. UPDATE biz_company
  92. SET deleted=0
  93. WHERE id = #{id}
  94. </update>
  95. <!-- 还原订单表数据 -->
  96. <update id="restoreArchive">
  97. UPDATE biz_archive_input
  98. SET deleted=0
  99. WHERE id = #{id}
  100. </update>
  101. <select id="getChildById" resultType="Long">
  102. SELECT t.id
  103. FROM ${table} t
  104. WHERE t.company_id = ${id}
  105. </select>
  106. <select id="getArchiveById" resultType="Long">
  107. SELECT t.id
  108. FROM ${tab} t
  109. WHERE t.contract_id = ${id}
  110. </select>
  111. <select id="getChildIdsByParentId" resultMap="BizRecycleBinResult">
  112. <foreach collection="tabs" item="item" index="index" separator="union">
  113. SELECT t.id as source_id, #{item.tab} as source_table_name
  114. FROM ${item.tab} t
  115. WHERE t.company_id = #{item.id}
  116. </foreach>
  117. </select>
  118. </mapper>