123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="cn.ezhizao.project.business.recycleBin.mapper.BizRecycleBinMapper">
- <resultMap type="cn.ezhizao.project.business.recycleBin.domain.BizRecycleBin" id="BizRecycleBinResult">
- <id column="id" property="id"/>
- </resultMap>
- <select id="getList" parameterType="BizRecycleBin" resultMap="BizRecycleBinResult">
- SELECT * FROM biz_recycle_bin
- <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
- deleted = 0
- AND from_id = 0
- AND is_return = 0
- AND is_clean=0
- <if test="sourceTableName != null and sourceTableName != ''">AND source_table_name=#{sourceTableName}
- </if>
- <if test="sourceValue != null and sourceValue != ''">AND source_value like concat('%', #{sourceValue},
- '%')
- </if>
- <if test="isClean != null ">AND is_clean = #{isClean}</if>
- <if test="isReturn != null ">AND is_return = #{isReturn}</if>
- </trim>
- </select>
- <delete id="physicalDelete">
- DELETE FROM biz_recycle_bin
- <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
- <if test="id != null">
- id = #{id} AND
- </if>
- <!-- 删除条件为其他外键可以在这里加 -->
- </trim>
- </delete>
- <select id="getById" parameterType="BizRecycleBin" resultMap="BizRecycleBinResult">
- SELECT *
- FROM biz_recycle_bin
- WHERE id = #{id}
- </select>
- <!-- -- UPDATE ${table} t-->
- <!-- -- SET t.deleted=1-->
- <!-- -- WHERE t.company_id = ${id}-->
- <!-- 软删除客户关联子表数据 -->
- <update id="deleteData">
- <foreach collection="tabs" item="item" index="index" separator=";">
- UPDATE ${item}
- SET deleted=1
- WHERE company_id=#{id}
- </foreach>
- </update>
- <!-- 软删除客户关联子表数据 -->
- <update id="deleteArchiveData">
- <foreach collection="tabs" item="item" index="index" separator=";">
- UPDATE ${item}
- SET deleted=1
- WHERE contract_id=#{id}
- </foreach>
- </update>
- <!-- 还原客户关联子表数据 -->
- <update id="restoreData">
- <foreach collection="tabs" item="item" index="index" separator=";">
- UPDATE ${item}
- SET deleted=0
- WHERE company_id=#{id}
- </foreach>
- </update>
- <!-- 还原订单关联子表数据 -->
- <update id="restoreArchiveData">
- <foreach collection="tabs" item="item" index="index" separator=";">
- UPDATE ${item}
- SET deleted=0
- WHERE contract_id=#{id}
- </foreach>
- </update>
- <!-- 回收站数据还原 -->
- <update id="restore">
- UPDATE biz_recycle_bin
- SET is_return=1
- WHERE id = #{id}
- OR from_id = #{id}
- </update>
- <!-- 回收站数据删除 -->
- <update id="remove">
- UPDATE biz_recycle_bin
- SET is_clean=1,
- deleted=1
- WHERE id = #{id}
- OR from_id = #{id}
- </update>
- <!-- 还原用户表数据 -->
- <update id="restoreCompany">
- UPDATE biz_company
- SET deleted=0
- WHERE id = #{id}
- </update>
- <!-- 还原订单表数据 -->
- <update id="restoreArchive">
- UPDATE biz_archive_input
- SET deleted=0
- WHERE id = #{id}
- </update>
- <select id="getChildById" resultType="Long">
- SELECT t.id
- FROM ${table} t
- WHERE t.company_id = ${id}
- </select>
- <select id="getArchiveById" resultType="Long">
- SELECT t.id
- FROM ${tab} t
- WHERE t.contract_id = ${id}
- </select>
- <select id="getChildIdsByParentId" resultMap="BizRecycleBinResult">
- <foreach collection="tabs" item="item" index="index" separator="union">
- SELECT t.id as source_id, #{item.tab} as source_table_name
- FROM ${item.tab} t
- WHERE t.company_id = #{item.id}
- </foreach>
- </select>
- </mapper>
|