大调整

This commit is contained in:
zhangchenbiao
2023-06-08 15:57:28 +08:00
parent 8e866554a1
commit 071725fb3d
44 changed files with 740 additions and 2352 deletions

View File

@@ -12,10 +12,10 @@
<result column="main_admin" jdbcType="BIT" property="mainAdmin"/>
<result column="is_admin" jdbcType="BIT" property="isAdmin"/>
<result column="unionid" jdbcType="VARCHAR" property="unionid"/>
<result column="position" jdbcType="VARCHAR" property="position"/>
<result column="avatar" jdbcType="VARCHAR" property="avatar"/>
<result column="jobnumber" jdbcType="VARCHAR" property="jobnumber"/>
<result column="is_leader" jdbcType="BIT" property="isLeader"/>
<result column="leader_dept_ids" jdbcType="VARCHAR" property="leaderDeptIds"/>
<result column="face_url" jdbcType="VARCHAR" property="faceUrl"/>
<result column="user_status" jdbcType="TINYINT" property="userStatus"/>
<result column="deleted" jdbcType="BIT" property="deleted"/>
@@ -27,132 +27,143 @@
</resultMap>
<sql id="Base_Column_List">
id, user_id, name, remark, mobile, email, org_email, main_admin, is_admin, unionid,
position, avatar, jobnumber, is_leader, face_url, user_status, deleted, create_time,
avatar, jobnumber, is_leader, leader_dept_ids, face_url, user_status, deleted, create_time,
update_time
</sql>
<sql id="Blob_Column_List">
user_region_ids
</sql>
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
insert into enterprise_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">
user_id,
</if>
<if test="name != null">
name,
</if>
<if test="remark != null">
remark,
</if>
<if test="mobile != null">
mobile,
</if>
<if test="email != null">
email,
</if>
<if test="orgEmail != null">
org_email,
</if>
<if test="mainAdmin != null">
main_admin,
</if>
<if test="isAdmin != null">
is_admin,
</if>
<if test="unionid != null">
unionid,
</if>
<if test="position != null">
position,
</if>
<if test="avatar != null">
avatar,
</if>
<if test="jobnumber != null">
jobnumber,
</if>
<if test="isLeader != null">
is_leader,
</if>
<if test="faceUrl != null">
face_url,
</if>
<if test="userStatus != null">
user_status,
</if>
<if test="deleted != null">
deleted,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="userRegionIds != null">
user_region_ids,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">
#{userId},
</if>
<if test="name != null">
#{name},
</if>
<if test="remark != null">
#{remark},
</if>
<if test="mobile != null">
#{mobile},
</if>
<if test="email != null">
#{email},
</if>
<if test="orgEmail != null">
#{orgEmail},
</if>
<if test="mainAdmin != null">
#{mainAdmin},
</if>
<if test="isAdmin != null">
#{isAdmin},
</if>
<if test="unionid != null">
#{unionid},
</if>
<if test="position != null">
#{position},
</if>
<if test="avatar != null">
#{avatar},
</if>
<if test="jobnumber != null">
#{jobnumber},
</if>
<if test="isLeader != null">
#{isLeader},
</if>
<if test="faceUrl != null">
#{faceUrl},
</if>
<if test="userStatus != null">
#{userStatus},
</if>
<if test="deleted != null">
#{deleted},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="userRegionIds != null">
#{userRegionIds},
</if>
</trim>
<insert id="batchInsertOrUpdate">
<foreach collection="recordList" item="record" separator=";">
insert into enterprise_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="record.id != null">
id,
</if>
<if test="record.userId != null">
user_id,
</if>
<if test="record.name != null">
name,
</if>
<if test="record.remark != null">
remark,
</if>
<if test="record.mobile != null">
mobile,
</if>
<if test="record.email != null">
email,
</if>
<if test="record.orgEmail != null">
org_email,
</if>
<if test="record.mainAdmin != null">
main_admin,
</if>
<if test="record.isAdmin != null">
is_admin,
</if>
<if test="record.unionid != null">
unionid,
</if>
<if test="record.avatar != null">
avatar,
</if>
<if test="record.jobnumber != null">
jobnumber,
</if>
<if test="record.isLeader != null">
is_leader,
</if>
<if test="record.leaderDeptIds != null">
leader_dept_ids,
</if>
<if test="record.faceUrl != null">
face_url,
</if>
<if test="record.userStatus != null">
user_status,
</if>
<if test="record.deleted != null">
deleted,
</if>
<if test="record.createTime != null">
create_time,
</if>
<if test="record.updateTime != null">
update_time,
</if>
<if test="record.userRegionIds != null">
user_region_ids,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="record.id != null">
#{record.id},
</if>
<if test="record.userId != null">
#{record.userId},
</if>
<if test="record.name != null">
#{record.name},
</if>
<if test="record.remark != null">
#{record.remark},
</if>
<if test="record.mobile != null">
#{record.mobile},
</if>
<if test="record.email != null">
#{record.email},
</if>
<if test="record.orgEmail != null">
#{record.orgEmail},
</if>
<if test="record.mainAdmin != null">
#{record.mainAdmin},
</if>
<if test="record.isAdmin != null">
#{record.isAdmin},
</if>
<if test="record.unionid != null">
#{record.unionid},
</if>
<if test="record.avatar != null">
#{record.avatar},
</if>
<if test="record.jobnumber != null">
#{record.jobnumber},
</if>
<if test="record.isLeader != null">
#{record.isLeader},
</if>
<if test="record.leaderDeptIds != null">
#{record.leaderDeptIds},
</if>
<if test="record.faceUrl != null">
#{record.faceUrl},
</if>
<if test="record.userStatus != null">
#{record.userStatus},
</if>
<if test="record.deleted != null">
#{record.deleted},
</if>
<if test="record.createTime != null">
#{record.createTime},
</if>
<if test="record.updateTime != null">
#{record.updateTime},
</if>
<if test="record.userRegionIds != null">
#{record.userRegionIds},
</if>
</trim>
ON DUPLICATE KEY UPDATE user_id = values(user_id), name = values(name), remark = values(remark), mobile = values(mobile), email = values(email), org_email = values(org_email)
, main_admin = values(main_admin), is_admin = values(is_admin), unionid = values(unionid), avatar = values(avatar), jobnumber = values(jobnumber), is_leader = values(is_leader)
, leader_dept_ids = values(leader_dept_ids), face_url = values(face_url), user_status = values(user_status), user_region_ids = values(user_region_ids)
</foreach>
</insert>
<update id="updateByPrimaryKeySelective">
update enterprise_user
@@ -184,9 +195,6 @@
<if test="unionid != null">
unionid = #{unionid},
</if>
<if test="position != null">
position = #{position},
</if>
<if test="avatar != null">
avatar = #{avatar},
</if>
@@ -196,6 +204,9 @@
<if test="isLeader != null">
is_leader = #{isLeader},
</if>
<if test="record.leaderDeptIds != null">
leader_dept_ids = #{record.leaderDeptIds},
</if>
<if test="faceUrl != null">
face_url = #{faceUrl},
</if>
@@ -220,10 +231,15 @@
<select id="getUserInfoById" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>, <include refid="Blob_Column_List"/>
<include refid="Base_Column_List"/>,
<include refid="Blob_Column_List"/>
from
enterprise_user
where
user_id = #{userId}
</select>
<update id="deleteUser">
update enterprise_user set deleted = 1 where id in <foreach collection="excludeUserIds" open="(" close=")" separator="," item="userId">#{userId}</foreach>
</update>
</mapper>

View File

@@ -3,134 +3,78 @@
<mapper namespace="com.cool.store.mapper.EnterpriseUserRoleMapper">
<resultMap id="BaseResultMap" type="com.cool.store.entity.EnterpriseUserRoleDO">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="role_id" jdbcType="BIGINT" property="roleId"/>
<result column="role_id" jdbcType="VARCHAR" property="roleId"/>
<result column="user_id" jdbcType="VARCHAR" property="userId"/>
<result column="deleted" jdbcType="BIT" property="deleted"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
</resultMap>
<sql id="Base_Column_List">
id, role_id, user_id, create_time, update_time
id, role_id, user_id, deleted, create_time, update_time
</sql>
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
insert into enterprise_user_role
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="record.roleId != null">
<insert id="batchInsertOrUpdate">
<foreach collection="recordList" separator=";" item="record">
insert into enterprise_user_role
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="record.roleId != null">
role_id,
</if>
<if test="record.userId != null">
</if>
<if test="record.userId != null">
user_id,
</if>
<if test="record.createTime != null">
</if>
<if test="record.deleted != null">
deleted,
</if>
<if test="record.createTime != null">
create_time,
</if>
<if test="record.updateTime != null">
</if>
<if test="record.updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="record.roleId != null">
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="record.roleId != null">
#{record.roleId},
</if>
<if test="record.userId != null">
</if>
<if test="record.userId != null">
#{record.userId},
</if>
<if test="record.createTime != null">
</if>
<if test="record.deleted != null">
#{record.deleted},
</if>
<if test="record.createTime != null">
#{record.createTime},
</if>
<if test="record.updateTime != null">
</if>
<if test="record.updateTime != null">
#{record.updateTime},
</if>
</trim>
</if>
</trim>
ON DUPLICATE KEY UPDATE deleted = values(deleted)
</foreach>
</insert>
<update id="updateByPrimaryKeySelective">
update enterprise_user_role
<set>
<if test="record.roleId != null">
role_id = #{record.roleId},
<if test="roleId != null">
role_id = #{roleId},
</if>
<if test="record.userId != null">
user_id = #{record.userId},
<if test="userId != null">
user_id = #{userId},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime},
<if test="deleted != null">
deleted = #{deleted},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime},
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
where id = #{record.id}
where id = #{id}
</update>
<update id="deleteUserRole">
update enterprise_user_role set deleted = 1 where role_id = #{roleId} and user_id not in <foreach collection="userIds" item="userId" separator="," open="(" close=")">#{userId}</foreach>
</update>
<insert id="insertBatchUserRole">
insert ignore into enterprise_user_role
(role_id, user_id ,create_time)
values
<foreach collection="userRoles" item="userRole" separator=",">
(#{userRole.roleId}, #{userRole.userId} ,#{userRole.createTime})
</foreach>
</insert>
<select id="getUserAndRolesByUserId" resultType="com.cool.store.dto.buser.UserRoleDTO">
select
a.role_id as roleId,
a.user_id as userId,
b.role_name as roleName,
b.role_auth as roleAuth,
b.role_enum as roleEnum,
b.priority as priority
from enterprise_user_role a left join sys_role b on a.role_id=b.id
<where>
<if test="userIdList != null and userIdList.size>0">
<foreach collection="userIdList" item="userId" separator="," open="a.user_id in (" close=")">
#{userId}
</foreach>
</if>
AND b.role_name IS NOT NULL
</where>
</select>
<select id="listRoleByUserId" resultType="com.cool.store.entity.SysRoleDO">
select
c.id as id,
c.role_name as roleName,
c.role_auth as roleAuth,
c.source as source,
c.role_enum as roleEnum
from enterprise_user_role b
left join sys_role c on c.id = b.role_id
where b.user_id = #{userId}
</select>
<delete id="deleteBatchByPrimaryKey">
delete from enterprise_user_role where id in
<foreach item="id" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectIdsByUserId" resultType="java.lang.Long">
select id from enterprise_user_role where user_id = #{userId}
</select>
<select id="selectByUserIdAndRoleId" resultMap="BaseResultMap">
select * from enterprise_user_role
where user_id = #{userId} and role_id = #{roleId}
order by id asc
limit 1
</select>
<insert id="save">
insert ignore into enterprise_user_role
(
`role_id`,
`user_id`,
`create_time`
)
values
(
#{entity.roleId},
#{entity.userId},
#{entity.createTime}
)
</insert>
</mapper>

View File

@@ -1,43 +0,0 @@
<?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="com.cool.store.mapper.LoginRecordMapper">
<resultMap id="BaseResultMap" type="com.cool.store.entity.LoginRecordDO">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
</resultMap>
<sql id="Base_Column_List">
id, user_id, create_time
</sql>
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
insert into login_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="record.userId != null">
user_id,
</if>
<if test="record.createTime != null">
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="record.userId != null">
#{record.userId},
</if>
<if test="record.createTime != null">
#{record.createTime},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective">
update login_record
<set>
<if test="record.userId != null">
user_id = #{record.userId},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime},
</if>
</set>
where id = #{record.id}
</update>
</mapper>

View File

@@ -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>

View File

@@ -1,258 +0,0 @@
<?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="com.cool.store.mapper.SysDepartmentMapper">
<resultMap id="BaseResultMap" type="com.cool.store.entity.SysDepartmentDO">
<id column="id" jdbcType="VARCHAR" property="id"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="parent_id" jdbcType="VARCHAR" property="parentId"/>
<result column="depart_order" jdbcType="INTEGER" property="departOrder"/>
<result column="create_dept_group" jdbcType="BIT" property="createDeptGroup"/>
<result column="auto_add_user" jdbcType="BIT" property="autoAddUser"/>
<result column="dep_Hiding" jdbcType="BIT" property="depHiding"/>
<result column="dept_perimits" jdbcType="VARCHAR" property="deptPerimits"/>
<result column="user_perimits" jdbcType="VARCHAR" property="userPerimits"/>
<result column="outer_dept" jdbcType="BIT" property="outerDept"/>
<result column="outer_permit_depts" jdbcType="VARCHAR" property="outerPermitDepts"/>
<result column="outer_permit_users" jdbcType="VARCHAR" property="outerPermitUsers"/>
<result column="org_dept_owner" jdbcType="VARCHAR" property="orgDeptOwner"/>
<result column="dept_manager_userid_list" jdbcType="VARCHAR" property="deptManagerUseridList"/>
<result column="user_count" jdbcType="INTEGER" property="userCount"/>
<result column="unactive_user_count" jdbcType="INTEGER" property="unactiveUserCount"/>
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.cool.store.entity.SysDepartmentDO">
<result column="parent_ids" jdbcType="LONGVARCHAR" property="parentIds"/>
<result column="sub_ids" jdbcType="LONGVARCHAR" property="subIds"/>
</resultMap>
<sql id="Base_Column_List">
id, name, parent_id, depart_order, create_dept_group, auto_add_user, dep_Hiding,
dept_perimits, user_perimits, outer_dept, outer_permit_depts, outer_permit_users,
org_dept_owner, dept_manager_userid_list, user_count, unactive_user_count
</sql>
<sql id="Blob_Column_List">
parent_ids, sub_ids
</sql>
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
insert into sys_department
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="record.name != null">
name,
</if>
<if test="record.parentId != null">
parent_id,
</if>
<if test="record.departOrder != null">
depart_order,
</if>
<if test="record.createDeptGroup != null">
create_dept_group,
</if>
<if test="record.autoAddUser != null">
auto_add_user,
</if>
<if test="record.depHiding != null">
dep_Hiding,
</if>
<if test="record.deptPerimits != null">
dept_perimits,
</if>
<if test="record.userPerimits != null">
user_perimits,
</if>
<if test="record.outerDept != null">
outer_dept,
</if>
<if test="record.outerPermitDepts != null">
outer_permit_depts,
</if>
<if test="record.outerPermitUsers != null">
outer_permit_users,
</if>
<if test="record.orgDeptOwner != null">
org_dept_owner,
</if>
<if test="record.deptManagerUseridList != null">
dept_manager_userid_list,
</if>
<if test="record.userCount != null">
user_count,
</if>
<if test="record.unactiveUserCount != null">
unactive_user_count,
</if>
<if test="record.parentIds != null">
parent_ids,
</if>
<if test="record.subIds != null">
sub_ids,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="record.name != null">
#{record.name},
</if>
<if test="record.parentId != null">
#{record.parentId},
</if>
<if test="record.departOrder != null">
#{record.departOrder},
</if>
<if test="record.createDeptGroup != null">
#{record.createDeptGroup},
</if>
<if test="record.autoAddUser != null">
#{record.autoAddUser},
</if>
<if test="record.depHiding != null">
#{record.depHiding},
</if>
<if test="record.deptPerimits != null">
#{record.deptPerimits},
</if>
<if test="record.userPerimits != null">
#{record.userPerimits},
</if>
<if test="record.outerDept != null">
#{record.outerDept},
</if>
<if test="record.outerPermitDepts != null">
#{record.outerPermitDepts},
</if>
<if test="record.outerPermitUsers != null">
#{record.outerPermitUsers},
</if>
<if test="record.orgDeptOwner != null">
#{record.orgDeptOwner},
</if>
<if test="record.deptManagerUseridList != null">
#{record.deptManagerUseridList},
</if>
<if test="record.userCount != null">
#{record.userCount},
</if>
<if test="record.unactiveUserCount != null">
#{record.unactiveUserCount},
</if>
<if test="record.parentIds != null">
#{record.parentIds},
</if>
<if test="record.subIds != null">
#{record.subIds},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective">
update sys_department
<set>
<if test="record.name != null">
name = #{record.name},
</if>
<if test="record.parentId != null">
parent_id = #{record.parentId},
</if>
<if test="record.departOrder != null">
depart_order = #{record.departOrder},
</if>
<if test="record.createDeptGroup != null">
create_dept_group = #{record.createDeptGroup},
</if>
<if test="record.autoAddUser != null">
auto_add_user = #{record.autoAddUser},
</if>
<if test="record.depHiding != null">
dep_Hiding = #{record.depHiding},
</if>
<if test="record.deptPerimits != null">
dept_perimits = #{record.deptPerimits},
</if>
<if test="record.userPerimits != null">
user_perimits = #{record.userPerimits},
</if>
<if test="record.outerDept != null">
outer_dept = #{record.outerDept},
</if>
<if test="record.outerPermitDepts != null">
outer_permit_depts = #{record.outerPermitDepts},
</if>
<if test="record.outerPermitUsers != null">
outer_permit_users = #{record.outerPermitUsers},
</if>
<if test="record.orgDeptOwner != null">
org_dept_owner = #{record.orgDeptOwner},
</if>
<if test="record.deptManagerUseridList != null">
dept_manager_userid_list = #{record.deptManagerUseridList},
</if>
<if test="record.userCount != null">
user_count = #{record.userCount},
</if>
<if test="record.unactiveUserCount != null">
unactive_user_count = #{record.unactiveUserCount},
</if>
<if test="record.parentIds != null">
parent_ids = #{record.parentIds},
</if>
<if test="record.subIds != null">
sub_ids = #{record.subIds},
</if>
</set>
where id = #{record.id}
</update>
<insert id="batchInsertOrUpdate" parameterType="java.util.List">
insert into sys_department
(
id,
name,
parent_id,
depart_order,
auto_add_user
) values
<foreach collection="list" item="it" separator=",">
(
#{it.id, jdbcType=BIGINT},
#{it.name, jdbcType=VARCHAR},
#{it.parentId, jdbcType=BIGINT},
#{it.departOrder, jdbcType=INTEGER},
#{it.autoAddUser, jdbcType=BOOLEAN}
)
</foreach>
ON DUPLICATE KEY UPDATE name=values(name), parent_id=values(parent_id)
</insert>
<select id="getDeptChildListByParentId"
resultType="com.cool.store.dto.enterprise.QueryDeptChildDTO">
select
id,
name,
depart_order as departOrder,
parent_id as parentId
from sys_department
where parent_id = #{parentId}
</select>
<delete id="deleteByNotInIds">
delete from sys_department
where id not in
<foreach collection="list" item="item" open="(" separator="," close=")" >
#{item}
</foreach>
and id != '1'
</delete>
<select id="getSyncDeptTreeList" resultType="com.cool.store.dto.dept.SyncTreeNode">
select
id,
name,
parent_id as pid
from sys_department
</select>
<select id="selectAll" resultType="com.cool.store.entity.SysDepartmentDO">
select
id,
name,
parent_id as parentId,
depart_order as departOrder
from sys_department
</select>
</mapper>