企业同步
This commit is contained in:
@@ -376,6 +376,7 @@
|
||||
syn_ding_dept_id as synDingDeptId,
|
||||
region_type as regionType,
|
||||
deleted as deleted,
|
||||
region_path as regionPath,
|
||||
store_id as storeId
|
||||
from region_${eid}
|
||||
where region_type = 'store'
|
||||
@@ -385,4 +386,204 @@
|
||||
</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_${eid}
|
||||
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_${eid} where id = #{regionId, jdbcType=BIGINT} and deleted = 0
|
||||
</select>
|
||||
|
||||
<insert id="insertOrUpdate" useGeneratedKeys="true" keyProperty="record.id">
|
||||
insert into region_${eid}
|
||||
(
|
||||
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_${eid}
|
||||
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_${eid}
|
||||
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_${eid}
|
||||
where syn_ding_dept_id = #{synDingDeptId}
|
||||
</select>
|
||||
|
||||
<insert id="ignoreInsert" keyColumn="id" keyProperty="region.id" useGeneratedKeys="true">
|
||||
insert ignore into region_${eid}
|
||||
(
|
||||
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_${eid} AS num)
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateSyncRegion" >
|
||||
update region_${eid}
|
||||
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_${eid}
|
||||
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>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user