feat:用户-部门

This commit is contained in:
Zhujx
2025-08-29 17:11:36 +08:00
parent dfa08559e5
commit fee19c4177
23 changed files with 534 additions and 22 deletions

View File

@@ -0,0 +1,146 @@
<?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.xiang.xservice.auth.service.repository.mapper.XDeptMapper">
<resultMap id="BaseResultMap" type="com.xiang.xservice.auth.service.entity.XUserDept" >
<result column="name" property="name" />
<result column="parent_id" property="parentId" />
<result column="tree_path" property="treePath" />
<result column="sort_no" property="sortNo" />
<result column="created_time" property="createdTime" />
<result column="create_by" property="createBy" />
<result column="updated_time" property="updatedTime" />
<result column="update_by" property="updateBy" />
<result column="del_flag" property="delFlag" />
</resultMap>
<sql id="Base_Column_List">
name,
parent_id,
tree_path,
sort_no,
created_time,
create_by,
updated_time,
update_by,
del_flag
</sql>
<insert id="insert" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="com.xiang.xservice.auth.service.entity.XUserDept">
INSERT INTO x_dept
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != name and '' != name">
name,
</if>
<if test="null != parentId ">
parent_id,
</if>
<if test="null != treePath and '' != treePath">
tree_path,
</if>
<if test="null != sortNo ">
sort_no,
</if>
<if test="null != createdTime ">
created_time,
</if>
<if test="null != createBy and '' != createBy">
create_by,
</if>
<if test="null != updatedTime ">
updated_time,
</if>
<if test="null != updateBy and '' != updateBy">
update_by,
</if>
<if test="null != delFlag ">
del_flag
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != name and '' != name">
#{name},
</if>
<if test="null != parentId ">
#{parentId},
</if>
<if test="null != treePath and '' != treePath">
#{treePath},
</if>
<if test="null != sortNo ">
#{sortNo},
</if>
<if test="null != createdTime ">
#{createdTime},
</if>
<if test="null != createBy and '' != createBy">
#{createBy},
</if>
<if test="null != updatedTime ">
#{updatedTime},
</if>
<if test="null != updateBy and '' != updateBy">
#{updateBy},
</if>
<if test="null != delFlag ">
#{delFlag}
</if>
</trim>
</insert>
<update id="delBatch" >
update x_dept
SET del_flag = 1, updated_time = now(), update_by = #{updateBy}
WHERE id IN
<foreach item="item" collection="ids" separator="," open="(" close=")">
#{item}
</foreach>
</update>
<update id="update" parameterType="com.xiang.xservice.auth.service.entity.XUserDept">
UPDATE x_dept
<set>
<if test="null != name and '' != name">name = #{name},</if>
<if test="null != parentId ">parent_id = #{parentId},</if>
<if test="null != treePath and '' != treePath">tree_path = #{treePath},</if>
<if test="null != sortNo ">sort_no = #{sortNo},</if>
<if test="null != createdTime ">created_time = #{createdTime},</if>
<if test="null != createBy and '' != createBy">create_by = #{createBy},</if>
<if test="null != updatedTime ">updated_time = #{updatedTime},</if>
<if test="null != updateBy and '' != updateBy">update_by = #{updateBy},</if>
<if test="null != delFlag ">del_flag = #{delFlag}</if>
</set>
WHERE id = #{id}
</update>
<select id="getDeptList" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from x_dept
<trim prefix="AND">
<where>
del_flag = 0
<if test="name != null and name != ''">AND name = #{name}</if>
</where>
</trim>
</select>
<select id="getDeptById" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from x_dept
where id = #{id}
</select>
<select id="getDeptByIds" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from x_dept
where id in
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</select>
<select id="getDeptByparentId" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from x_dept
where parent_id = #{parentId}
</select>
</mapper>

View File

@@ -90,12 +90,7 @@
</if>
</trim>
</insert>
<insert id="addBatch">
insert into x_role(user_id, role_id) values
<foreach collection="list" item="item" separator=",">
(#{item.userId}, #{item.roleId})
</foreach>
</insert>
<update id="delBatch" >
update x_role set del_flag = 0, update_time = #{time}, update_by = #{operator} where id in

View File

@@ -0,0 +1,26 @@
<?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.xiang.xservice.auth.service.repository.mapper.XUserDeptMapper">
<resultMap id="BaseResultMap" type="com.xiang.xservice.auth.service.entity.XUserDept" >
<result column="user_id" property="userId" />
<result column="dept_id" property="deptId" />
</resultMap>
<sql id="Base_Column_List">
user_id,
dept_id
</sql>
<insert id="addBatch">
insert into x_user_data_scope_dept(user_id, dept_id) values
<foreach collection="list" item="item" separator=",">
(#{item.userId}, #{item.deptId})
</foreach>
</insert>
<delete id="delByDeptId">
delete from x_user_data_scope_dept where dept_id = #{deptId}
</delete>
</mapper>

View File

@@ -23,6 +23,7 @@
<delete id="delByUserId">
delete from x_user_role where user_id = #{userId}
</delete>
<delete id="delByRoleIds">
delete from x_user_role where role_id in
<foreach collection="list" item="id" open="(" close=")" separator=",">
@@ -30,5 +31,12 @@
</foreach>
</delete>
<insert id="addBatch">
insert into x_user_role(user_id, role_id) values
<foreach collection="list" item="item" separator=",">
(#{item.userId}, #{item.roleId})
</foreach>
</insert>
</mapper>