大调整
This commit is contained in:
@@ -5,585 +5,157 @@
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="region_id" jdbcType="VARCHAR" property="regionId"/>
|
||||
<result column="name" jdbcType="VARCHAR" property="name"/>
|
||||
<result column="parent_id" jdbcType="BIGINT" property="parentId"/>
|
||||
<result column="group_id" jdbcType="VARCHAR" property="groupId"/>
|
||||
<result column="parent_id" jdbcType="VARCHAR" property="parentId"/>
|
||||
<result column="region_path" jdbcType="VARCHAR" property="regionPath"/>
|
||||
<result column="unclassified_flag" jdbcType="TINYINT" property="unclassifiedFlag"/>
|
||||
<result column="leader_user_id" jdbcType="VARCHAR" property="leaderUserId"/>
|
||||
<result column="order_num" jdbcType="INTEGER" property="orderNum"/>
|
||||
<result column="third_dept_id" jdbcType="VARCHAR" property="thirdDeptId"/>
|
||||
<result column="create_time" jdbcType="BIGINT" property="createTime"/>
|
||||
<result column="create_name" jdbcType="VARCHAR" property="createName"/>
|
||||
<result column="update_time" jdbcType="BIGINT" property="updateTime"/>
|
||||
<result column="update_name" jdbcType="VARCHAR" property="updateName"/>
|
||||
<result column="vds_group_corp_id" jdbcType="VARCHAR" property="vdsGroupCorpId"/>
|
||||
<result column="syn_ding_dept_id" jdbcType="VARCHAR" property="synDingDeptId"/>
|
||||
<result column="region_type" jdbcType="VARCHAR" property="regionType"/>
|
||||
<result column="region_path" jdbcType="VARCHAR" property="regionPath"/>
|
||||
<result column="deleted" jdbcType="BIT" property="deleted"/>
|
||||
<result column="store_num" jdbcType="INTEGER" property="storeNum"/>
|
||||
<result column="store_id" jdbcType="VARCHAR" property="storeId"/>
|
||||
<result column="unclassified_flag" jdbcType="TINYINT" property="unclassifiedFlag"/>
|
||||
<result column="order_num" jdbcType="INTEGER" property="orderNum"/>
|
||||
<result column="third_dept_id" jdbcType="VARCHAR" property="thirdDeptId"/>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, region_id, name, parent_id, group_id, create_time, create_name, update_time,
|
||||
update_name, vds_group_corp_id, syn_ding_dept_id, region_type, region_path, deleted,
|
||||
store_num, store_id, unclassified_flag, order_num, third_dept_id
|
||||
id, region_id, name, parent_id, region_path, unclassified_flag, leader_user_id, order_num,
|
||||
third_dept_id, create_time, create_name, update_time, update_name, deleted
|
||||
</sql>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
insert into region
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.regionId != null">
|
||||
region_id,
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
name,
|
||||
</if>
|
||||
<if test="record.parentId != null">
|
||||
parent_id,
|
||||
</if>
|
||||
<if test="record.groupId != null">
|
||||
group_id,
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="record.createName != null">
|
||||
create_name,
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="record.updateName != null">
|
||||
update_name,
|
||||
</if>
|
||||
<if test="record.vdsGroupCorpId != null">
|
||||
vds_group_corp_id,
|
||||
</if>
|
||||
<if test="record.synDingDeptId != null">
|
||||
syn_ding_dept_id,
|
||||
</if>
|
||||
<if test="record.regionType != null">
|
||||
region_type,
|
||||
</if>
|
||||
<if test="record.regionPath != null">
|
||||
region_path,
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
deleted,
|
||||
</if>
|
||||
<if test="record.storeNum != null">
|
||||
store_num,
|
||||
</if>
|
||||
<if test="record.storeId != null">
|
||||
store_id,
|
||||
</if>
|
||||
<if test="record.unclassifiedFlag != null">
|
||||
unclassified_flag,
|
||||
</if>
|
||||
<if test="record.orderNum != null">
|
||||
order_num,
|
||||
</if>
|
||||
<if test="record.thirdDeptId != null">
|
||||
third_dept_id,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.regionId != null">
|
||||
#{record.regionId},
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
#{record.name},
|
||||
</if>
|
||||
<if test="record.parentId != null">
|
||||
#{record.parentId},
|
||||
</if>
|
||||
<if test="record.groupId != null">
|
||||
#{record.groupId},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
#{record.createTime},
|
||||
</if>
|
||||
<if test="record.createName != null">
|
||||
#{record.createName},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
#{record.updateTime},
|
||||
</if>
|
||||
<if test="record.updateName != null">
|
||||
#{record.updateName},
|
||||
</if>
|
||||
<if test="record.vdsGroupCorpId != null">
|
||||
#{record.vdsGroupCorpId},
|
||||
</if>
|
||||
<if test="record.synDingDeptId != null">
|
||||
#{record.synDingDeptId},
|
||||
</if>
|
||||
<if test="record.regionType != null">
|
||||
#{record.regionType},
|
||||
</if>
|
||||
<if test="record.regionPath != null">
|
||||
#{record.regionPath},
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
#{record.deleted},
|
||||
</if>
|
||||
<if test="record.storeNum != null">
|
||||
#{record.storeNum},
|
||||
</if>
|
||||
<if test="record.storeId != null">
|
||||
#{record.storeId},
|
||||
</if>
|
||||
<if test="record.unclassifiedFlag != null">
|
||||
#{record.unclassifiedFlag},
|
||||
</if>
|
||||
<if test="record.orderNum != null">
|
||||
#{record.orderNum},
|
||||
</if>
|
||||
<if test="record.thirdDeptId != null">
|
||||
#{record.thirdDeptId},
|
||||
</if>
|
||||
</trim>
|
||||
<insert id="batchInsertOrUpdate">
|
||||
<foreach collection="insertOrUpdateList" item="record" separator=";">
|
||||
insert into region
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.regionId != null">
|
||||
region_id,
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
name,
|
||||
</if>
|
||||
<if test="record.parentId != null">
|
||||
parent_id,
|
||||
</if>
|
||||
<if test="record.regionPath != null">
|
||||
region_path,
|
||||
</if>
|
||||
<if test="record.unclassifiedFlag != null">
|
||||
unclassified_flag,
|
||||
</if>
|
||||
<if test="record.leaderUserId != null">
|
||||
leader_user_id,
|
||||
</if>
|
||||
<if test="record.orderNum != null">
|
||||
order_num,
|
||||
</if>
|
||||
<if test="record.thirdDeptId != null">
|
||||
third_dept_id,
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="record.createName != null">
|
||||
create_name,
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="record.updateName != null">
|
||||
update_name,
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
deleted,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.regionId != null">
|
||||
#{record.regionId},
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
#{record.name},
|
||||
</if>
|
||||
<if test="record.parentId != null">
|
||||
#{record.parentId},
|
||||
</if>
|
||||
<if test="record.regionPath != null">
|
||||
#{record.regionPath},
|
||||
</if>
|
||||
<if test="record.unclassifiedFlag != null">
|
||||
#{record.unclassifiedFlag},
|
||||
</if>
|
||||
<if test="record.leaderUserId != null">
|
||||
#{record.leaderUserId},
|
||||
</if>
|
||||
<if test="record.orderNum != null">
|
||||
#{record.orderNum},
|
||||
</if>
|
||||
<if test="record.thirdDeptId != null">
|
||||
#{record.thirdDeptId},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
#{record.createTime},
|
||||
</if>
|
||||
<if test="record.createName != null">
|
||||
#{record.createName},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
#{record.updateTime},
|
||||
</if>
|
||||
<if test="record.updateName != null">
|
||||
#{record.updateName},
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
#{record.deleted},
|
||||
</if>
|
||||
</trim>
|
||||
ON DUPLICATE KEY UPDATE region_id = values(region_id), name = values(name), parent_id = values(parent_id), region_path = values(region_path), leader_user_id = values(leader_user_id), order_num = values(order_num), third_dept_id = values(third_dept_id), update_time = UNIX_TIMESTAMP(), deleted = values(deleted)
|
||||
</foreach>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective">
|
||||
update region
|
||||
<set>
|
||||
<if test="record.regionId != null">
|
||||
region_id = #{record.regionId},
|
||||
<if test="regionId != null">
|
||||
region_id = #{regionId},
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
name = #{record.name},
|
||||
<if test="name != null">
|
||||
name = #{name},
|
||||
</if>
|
||||
<if test="record.parentId != null">
|
||||
parent_id = #{record.parentId},
|
||||
<if test="parentId != null">
|
||||
parent_id = #{parentId},
|
||||
</if>
|
||||
<if test="record.groupId != null">
|
||||
group_id = #{record.groupId},
|
||||
<if test="regionPath != null">
|
||||
region_path = #{regionPath},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime},
|
||||
<if test="unclassifiedFlag != null">
|
||||
unclassified_flag = #{unclassifiedFlag},
|
||||
</if>
|
||||
<if test="record.createName != null">
|
||||
create_name = #{record.createName},
|
||||
<if test="leaderUserId != null">
|
||||
leader_user_id = #{leaderUserId},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time = #{record.updateTime},
|
||||
<if test="orderNum != null">
|
||||
order_num = #{orderNum},
|
||||
</if>
|
||||
<if test="record.updateName != null">
|
||||
update_name = #{record.updateName},
|
||||
<if test="thirdDeptId != null">
|
||||
third_dept_id = #{thirdDeptId},
|
||||
</if>
|
||||
<if test="record.vdsGroupCorpId != null">
|
||||
vds_group_corp_id = #{record.vdsGroupCorpId},
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime},
|
||||
</if>
|
||||
<if test="record.synDingDeptId != null">
|
||||
syn_ding_dept_id = #{record.synDingDeptId},
|
||||
<if test="createName != null">
|
||||
create_name = #{createName},
|
||||
</if>
|
||||
<if test="record.regionType != null">
|
||||
region_type = #{record.regionType},
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime},
|
||||
</if>
|
||||
<if test="record.regionPath != null">
|
||||
region_path = #{record.regionPath},
|
||||
<if test="updateName != null">
|
||||
update_name = #{updateName},
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
deleted = #{record.deleted},
|
||||
</if>
|
||||
<if test="record.storeNum != null">
|
||||
store_num = #{record.storeNum},
|
||||
</if>
|
||||
<if test="record.storeId != null">
|
||||
store_id = #{record.storeId},
|
||||
</if>
|
||||
<if test="record.unclassifiedFlag != null">
|
||||
unclassified_flag = #{record.unclassifiedFlag},
|
||||
</if>
|
||||
<if test="record.orderNum != null">
|
||||
order_num = #{record.orderNum},
|
||||
</if>
|
||||
<if test="record.thirdDeptId != null">
|
||||
third_dept_id = #{record.thirdDeptId},
|
||||
<if test="deleted != null">
|
||||
deleted = #{deleted},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{record.id}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
|
||||
<select id="selectRegionIdsBySynDingDeptIds" resultType="java.lang.Long">
|
||||
select
|
||||
id
|
||||
from region
|
||||
where
|
||||
deleted = 0 and syn_ding_dept_id in
|
||||
<foreach collection="synDingDeptIds" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="getRegionByRegionIds" resultMap="BaseResultMap">
|
||||
select
|
||||
id ,
|
||||
id as regionId,
|
||||
name ,
|
||||
parent_id as parentId,
|
||||
group_id as groupId,
|
||||
create_time as createTime,
|
||||
create_name as createName,
|
||||
syn_ding_dept_id as synDingDeptId,
|
||||
update_time as updateTime,
|
||||
update_name as updateName,
|
||||
region_path as regionPath,
|
||||
store_num as storeNum,
|
||||
store_id as storeId,
|
||||
region_type as regionType
|
||||
from region where id in
|
||||
<foreach collection="regionIds" index="index" item="regionId"
|
||||
separator="," open="(" close=")">
|
||||
#{regionId, jdbcType=BIGINT}
|
||||
</foreach>
|
||||
and deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="getUnclassifiedRegionDO" resultMap="BaseResultMap">
|
||||
select
|
||||
id ,
|
||||
id as regionId,
|
||||
name as name ,
|
||||
parent_id as parentId,
|
||||
group_id as groupId,
|
||||
create_time as createTime,
|
||||
create_name as createName,
|
||||
update_time as updateTime,
|
||||
update_name as updateName,
|
||||
vds_group_corp_id as vdsGroupCorpId,
|
||||
syn_ding_dept_id as synDingDeptId,
|
||||
region_type as regionType,
|
||||
deleted as deleted,
|
||||
region_path as regionPath,
|
||||
store_num as storeNum,
|
||||
unclassified_flag as unclassifiedFlag
|
||||
from region
|
||||
where deleted = 0 and unclassified_flag = 1
|
||||
and (name = #{name} or id = 1) limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertRoot">
|
||||
insert ignore into region
|
||||
(
|
||||
id,
|
||||
region_id,
|
||||
name,
|
||||
parent_id,
|
||||
group_id,
|
||||
create_time,
|
||||
syn_ding_dept_id,
|
||||
create_name,
|
||||
region_type,
|
||||
region_path,
|
||||
store_num,
|
||||
unclassified_flag)
|
||||
values
|
||||
(
|
||||
#{region.id, jdbcType=BIGINT},
|
||||
#{region.regionId, jdbcType=VARCHAR},
|
||||
#{region.name, jdbcType=VARCHAR},
|
||||
#{region.parentId, jdbcType=VARCHAR},
|
||||
#{region.groupId, jdbcType=VARCHAR},
|
||||
#{region.createTime, jdbcType=BIGINT},
|
||||
#{region.synDingDeptId, jdbcType=VARCHAR},
|
||||
#{region.createName, jdbcType=VARCHAR},
|
||||
#{region.regionType, jdbcType=VARCHAR},
|
||||
#{region.regionPath},
|
||||
#{region.storeNum},
|
||||
#{region.unclassifiedFlag}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="batchInsertRegionsByDepartments">
|
||||
insert into region
|
||||
(
|
||||
id,
|
||||
name,
|
||||
parent_id,
|
||||
group_id,
|
||||
create_time,
|
||||
syn_ding_dept_id,
|
||||
region_path,
|
||||
region_type,
|
||||
order_num,
|
||||
create_name,
|
||||
store_id
|
||||
)
|
||||
values
|
||||
<foreach collection="regions" item="region" separator=",">
|
||||
(
|
||||
#{region.id},
|
||||
#{region.name},
|
||||
#{region.parentId},
|
||||
#{region.groupId},
|
||||
#{region.createTime},
|
||||
#{region.synDingDeptId},
|
||||
#{region.regionPath},
|
||||
#{region.regionType},
|
||||
#{region.orderNum},
|
||||
#{region.createName},
|
||||
#{region.storeId}
|
||||
)
|
||||
</foreach>
|
||||
ON DUPLICATE KEY UPDATE
|
||||
name=values(name), parent_id=values(parent_id), region_path=values(region_path),region_type=values(region_type),order_num=values(order_num)
|
||||
</insert>
|
||||
|
||||
<select id="selectRegionBySynDingDeptIds" resultMap="BaseResultMap">
|
||||
select
|
||||
id,
|
||||
syn_ding_dept_id
|
||||
from region
|
||||
where deleted = 0 and syn_ding_dept_id in (
|
||||
<foreach collection="synDingDeptIds" item="item" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="getAllRegion" resultType="com.cool.store.entity.RegionDO">
|
||||
select
|
||||
id ,
|
||||
id as regionId,
|
||||
name ,
|
||||
parent_id as parentId,
|
||||
group_id as groupId,
|
||||
create_time as createTime,
|
||||
create_name as createName,
|
||||
update_time as updateTime,
|
||||
update_name as updateName,
|
||||
syn_ding_dept_id as synDingDeptId,
|
||||
region_type as regionType,
|
||||
region_path as regionPath,
|
||||
deleted as deleted,
|
||||
third_dept_id as thirdDeptId
|
||||
from region
|
||||
where deleted = 0 and id > 0
|
||||
and region_type != 'store'
|
||||
</select>
|
||||
|
||||
<select id="listStoreRegionByIds" resultType="com.cool.store.entity.RegionDO">
|
||||
select
|
||||
id ,
|
||||
region_id as regionId,
|
||||
name as name ,
|
||||
parent_id as parentId,
|
||||
group_id as groupId,
|
||||
create_time as createTime,
|
||||
create_name as createName,
|
||||
update_time as updateTime,
|
||||
update_name as updateName,
|
||||
syn_ding_dept_id as synDingDeptId,
|
||||
region_type as regionType,
|
||||
deleted as deleted,
|
||||
region_path as regionPath,
|
||||
store_id as storeId
|
||||
from region
|
||||
where region_type = 'store'
|
||||
and id in (
|
||||
<foreach collection="regionIds" item="item" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="getByRegionId" resultType="com.cool.store.entity.RegionDO">
|
||||
select
|
||||
id ,
|
||||
id as regionId,
|
||||
name as name ,
|
||||
parent_id as parentId,
|
||||
group_id as groupId,
|
||||
create_time as createTime,
|
||||
create_name as createName,
|
||||
update_time as updateTime,
|
||||
update_name as updateName,
|
||||
syn_ding_dept_id as synDingDeptId,
|
||||
store_id as storeId,
|
||||
region_type as regionType,
|
||||
region_path as regionPath,
|
||||
deleted,
|
||||
store_num as storeNum
|
||||
from region
|
||||
where id = #{regionId}
|
||||
</select>
|
||||
|
||||
<select id="getRegionByRegionId" resultType="com.cool.store.dto.region.RegionNode">
|
||||
select
|
||||
id ,
|
||||
id as regionId,
|
||||
name as name ,
|
||||
parent_id as parentId,
|
||||
group_id as groupId,
|
||||
create_time as createTime,
|
||||
create_name as createName,
|
||||
update_time as updateTime,
|
||||
update_name as updateName,
|
||||
syn_ding_dept_id as synDingDeptId,
|
||||
region_type as regionType,
|
||||
region_path as regionPath,
|
||||
store_num as storeCount
|
||||
from region where id = #{regionId, jdbcType=BIGINT} and deleted = 0
|
||||
</select>
|
||||
|
||||
<insert id="insertOrUpdate" useGeneratedKeys="true" keyProperty="record.id">
|
||||
insert into region
|
||||
(
|
||||
id,
|
||||
name,
|
||||
<if test="record.parentId != null">
|
||||
parent_id,
|
||||
</if>
|
||||
region_type,
|
||||
create_time,
|
||||
syn_ding_dept_id,
|
||||
unclassified_flag,
|
||||
third_dept_id
|
||||
) value
|
||||
(
|
||||
#{record.id, jdbcType=BIGINT},
|
||||
#{record.name, jdbcType=VARCHAR},
|
||||
<if test="record.parentId != null">
|
||||
#{record.parentId, jdbcType=BIGINT},
|
||||
</if>
|
||||
#{record.regionType, jdbcType=VARCHAR},
|
||||
#{record.createTime, jdbcType=BIGINT},
|
||||
#{record.synDingDeptId, jdbcType=VARCHAR},
|
||||
#{record.unclassifiedFlag},
|
||||
#{record.thirdDeptId}
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE name=values(name), parent_id=values(parent_id), syn_ding_dept_id=values(syn_ding_dept_id),third_dept_id=values(third_dept_id),
|
||||
update_time = values(update_time), region_type = values(region_type), deleted = values(deleted)
|
||||
</insert>
|
||||
|
||||
<select id="getSpecifiedRegionIdAndDeptId" resultType="com.cool.store.dto.region.RegionSyncDTO">
|
||||
select
|
||||
id ,
|
||||
syn_ding_dept_id as synDingDeptId
|
||||
from region
|
||||
where (id > 0 or id = -3) and (deleted = 0 or syn_ding_dept_id is not null)
|
||||
<if test="parentId!=null">
|
||||
and region_path like concat('%/',#{parentId},'/%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getRegionByDingDeptIds" resultType="com.cool.store.entity.RegionDO">
|
||||
select
|
||||
id ,
|
||||
region_id as regionId,
|
||||
name as name ,
|
||||
parent_id as parentId,
|
||||
group_id as groupId,
|
||||
create_time as createTime,
|
||||
create_name as createName,
|
||||
update_time as updateTime,
|
||||
update_name as updateName,
|
||||
syn_ding_dept_id as synDingDeptId,
|
||||
region_type as regionType,
|
||||
deleted as deleted
|
||||
from region
|
||||
where deleted = 0
|
||||
and syn_ding_dept_id in (
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="getBySynDingDeptId" resultType="com.cool.store.entity.RegionDO">
|
||||
select
|
||||
id ,
|
||||
id as regionId,
|
||||
name as name ,
|
||||
parent_id as parentId,
|
||||
group_id as groupId,
|
||||
create_time as createTime,
|
||||
create_name as createName,
|
||||
update_time as updateTime,
|
||||
update_name as updateName,
|
||||
syn_ding_dept_id as synDingDeptId,
|
||||
store_id as storeId,
|
||||
region_type as regionType,
|
||||
region_path as regionPath,
|
||||
deleted,
|
||||
store_num as storeNum
|
||||
from region
|
||||
where syn_ding_dept_id = #{synDingDeptId}
|
||||
</select>
|
||||
|
||||
<insert id="ignoreInsert" keyColumn="id" keyProperty="region.id" useGeneratedKeys="true">
|
||||
insert ignore into region
|
||||
(
|
||||
region_id,
|
||||
name,
|
||||
parent_id,
|
||||
group_id,
|
||||
create_time,
|
||||
create_name
|
||||
<if test="region.regionPath !=null and region.regionPath!=''">
|
||||
,region_path
|
||||
</if>
|
||||
<if test="region.regionType !=null and region.regionType!=''">
|
||||
,region_type
|
||||
</if>
|
||||
<if test="region.storeId !=null and region.storeId!=''">
|
||||
,store_id
|
||||
</if>
|
||||
<if test="region.synDingDeptId !=null and region.synDingDeptId!=''">
|
||||
,syn_ding_dept_id
|
||||
</if>
|
||||
,order_num
|
||||
)
|
||||
values
|
||||
(
|
||||
#{region.regionId, jdbcType=VARCHAR},
|
||||
#{region.name, jdbcType=VARCHAR},
|
||||
#{region.parentId, jdbcType=VARCHAR},
|
||||
#{region.groupId, jdbcType=VARCHAR},
|
||||
#{region.createTime, jdbcType=BIGINT},
|
||||
#{region.createName, jdbcType=VARCHAR}
|
||||
<if test="region.regionPath !=null and region.regionPath!=''">
|
||||
,#{region.regionPath}
|
||||
</if>
|
||||
<if test="region.regionType !=null and region.regionType!=''">
|
||||
,#{region.regionType}
|
||||
</if>
|
||||
<if test="region.storeId !=null and region.storeId!=''">
|
||||
,#{region.storeId}
|
||||
</if>
|
||||
<if test="region.synDingDeptId !=null and region.synDingDeptId!=''">
|
||||
,#{region.synDingDeptId}
|
||||
</if>
|
||||
,(SELECT max(order_num)+1 FROM region AS num)
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateSyncRegion" >
|
||||
update region
|
||||
set `parent_id` = #{item.parentId},
|
||||
`name` = #{item.name},
|
||||
<if test="item.regionType != null and item.regionType != ''">
|
||||
`region_type` = #{item.regionType},
|
||||
</if>
|
||||
`deleted` = #{item.deleted},
|
||||
`update_time` = #{item.updateTime},
|
||||
<if test="item.storeId != null and item.storeId != ''">
|
||||
store_id = #{item.storeId},
|
||||
</if>
|
||||
`region_path` = #{item.regionPath}
|
||||
where id = #{item.id}
|
||||
</update>
|
||||
|
||||
<update id="removeRegions">
|
||||
update region
|
||||
set
|
||||
deleted = 1,
|
||||
parent_id = -1
|
||||
where id in
|
||||
<foreach collection="regionIds" index="index" item="regionId"
|
||||
separator="," open="(" close=")">
|
||||
#{regionId, jdbcType=BIGINT}
|
||||
</foreach>
|
||||
and id != 1
|
||||
<update id="deleteNotExistRegion">
|
||||
update region set deleted = 1 , update_time = UNIX_TIMESTAMP() where region_id not in <foreach collection="regionIds" separator="," item="regionId" open="(" close=")"> #{regionId}</foreach>
|
||||
</update>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user