大调整

This commit is contained in:
zhangchenbiao
2023-06-08 15:58:05 +08:00
parent af7188f223
commit 665cb2190f
5 changed files with 249 additions and 304 deletions

View File

@@ -5,128 +5,109 @@
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="region_id" jdbcType="VARCHAR" property="regionId"/>
<result column="user_id" jdbcType="VARCHAR" property="userId"/>
<result column="type" jdbcType="INTEGER" property="type"/>
<result column="deleted" jdbcType="BIT" property="deleted"/>
<result column="create_id" jdbcType="VARCHAR" property="createId"/>
<result column="create_time" jdbcType="BIGINT" property="createTime"/>
<result column="update_id" jdbcType="VARCHAR" property="updateId"/>
<result column="update_time" jdbcType="BIGINT" property="updateTime"/>
</resultMap>
<sql id="Base_Column_List">
id, region_id, user_id, create_id, create_time, update_id, update_time
id, region_id, user_id, type, deleted, create_id, create_time, update_id, update_time
</sql>
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
insert into user_region_mapping
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="record.regionId != null">
region_id,
</if>
<if test="record.userId != null">
user_id,
</if>
<if test="record.createId != null">
create_id,
</if>
<if test="record.createTime != null">
create_time,
</if>
<if test="record.updateId != null">
update_id,
</if>
<if test="record.updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="record.regionId != null">
#{record.regionId},
</if>
<if test="record.userId != null">
#{record.userId},
</if>
<if test="record.createId != null">
#{record.createId},
</if>
<if test="record.createTime != null">
#{record.createTime},
</if>
<if test="record.updateId != null">
#{record.updateId},
</if>
<if test="record.updateTime != null">
#{record.updateTime},
</if>
</trim>
<insert id="batchInsertOrUpdateUserRegion">
<foreach collection="insertOrUpdateList" item="record" separator=";">
insert into user_region_mapping
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="record.regionId != null">
region_id,
</if>
<if test="record.userId != null">
user_id,
</if>
<if test="record.type != null">
type,
</if>
<if test="record.deleted != null">
deleted,
</if>
<if test="record.createId != null">
create_id,
</if>
<if test="record.createTime != null">
create_time,
</if>
<if test="record.updateId != null">
update_id,
</if>
<if test="record.updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="record.regionId != null">
#{record.regionId},
</if>
<if test="record.userId != null">
#{record.userId},
</if>
<if test="record.type != null">
#{record.type},
</if>
<if test="record.deleted != null">
#{record.deleted},
</if>
<if test="record.createId != null">
#{record.createId},
</if>
<if test="record.createTime != null">
#{record.createTime},
</if>
<if test="record.updateId != null">
#{record.updateId},
</if>
<if test="record.updateTime != null">
#{record.updateTime},
</if>
</trim>
ON DUPLICATE KEY UPDATE type = values(type), deleted = values(deleted)
</foreach>
</insert>
<update id="updateByPrimaryKeySelective">
update user_region_mapping
<set>
<if test="record.regionId != null">
region_id = #{record.regionId},
<if test="regionId != null">
region_id = #{regionId},
</if>
<if test="record.userId != null">
user_id = #{record.userId},
<if test="userId != null">
user_id = #{userId},
</if>
<if test="record.createId != null">
create_id = #{record.createId},
<if test="type != null">
type = #{type},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime},
<if test="deleted != null">
deleted = #{deleted},
</if>
<if test="record.updateId != null">
update_id = #{record.updateId},
<if test="createId != null">
create_id = #{createId},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime},
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateId != null">
update_id = #{updateId},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
where id = #{record.id}
where id = #{id}
</update>
<delete id="deletedByUserIds">
delete from user_region_mapping where user_id in
<foreach collection="userIds" open="(" close=")" separator="," item="userId">
#{userId}
</foreach>
</delete>
<insert id="batchInsertRegionMapping">
insert into user_region_mapping
(
region_id,
user_id,
create_time,
update_time,
create_id,
update_id
)
values
<foreach collection="userRegionMappingDOS" item="entity" separator=",">
(
#{entity.regionId},
#{entity.userId},
#{entity.createTime},
#{entity.updateTime},
#{entity.createId},
#{entity.updateId}
)
</foreach>
</insert>
<select id="listUserRegionMappingByUserId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from user_region_mapping
<if test="userIds !=null and userIds.size >0">
where user_id in
<foreach collection="userIds" open="(" close=")" separator="," item="userId">
#{userId}
</foreach>
<delete id="deleteUserRegion">
update user_region_mapping set deleted = 1 where region_id = #{regionId} and type = #{type}
<if test="excludeUserIds != null and excludeUserIds.size() > 0">
and user_id not in <foreach collection="excludeUserIds" separator="," open="(" close=")" item="userId" >#{userId}</foreach>
</if>
</select>
<delete id="deletedByIds">
delete from user_region_mapping where id in
<foreach collection="ids" open="(" close=")" separator="," item="id">
#{id}
</foreach>
</delete>
</mapper>