system和auth 初步构建
This commit is contained in:
@@ -0,0 +1,148 @@
|
||||
<?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="org.xyzh.system.mapper.DepartmentMapper">
|
||||
|
||||
<!-- 基础结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.dept.TbSysDept">
|
||||
<id column="id" property="id" jdbcType="VARCHAR"/>
|
||||
<result column="dept_id" property="deptID" jdbcType="VARCHAR"/>
|
||||
<result column="name" property="name" jdbcType="VARCHAR"/>
|
||||
<result column="parent_id" property="parentID" jdbcType="VARCHAR"/>
|
||||
<result column="description" property="description" jdbcType="VARCHAR"/>
|
||||
<result column="creator" property="creator" jdbcType="VARCHAR"/>
|
||||
<result column="updater" property="updater" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="delete_time" property="deleteTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, dept_id, name, parent_id, description, creator, updater,
|
||||
create_time, update_time, delete_time, deleted
|
||||
</sql>
|
||||
|
||||
<!-- 通用条件 -->
|
||||
<sql id="Where_Clause">
|
||||
<where>
|
||||
deleted = 0
|
||||
<if test="deptID != null and deptID != ''">
|
||||
AND dept_id = #{deptID}
|
||||
</if>
|
||||
<if test="parentID != null and parentID != ''">
|
||||
AND parent_id = #{parentID}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
AND name LIKE CONCAT('%', #{name}, '%')
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 根据父部门ID查询子部门列表 -->
|
||||
<select id="selectByParentId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tb_sys_dept
|
||||
WHERE deleted = 0
|
||||
AND parent_id = #{parentId}
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 检查部门名称是否存在 -->
|
||||
<select id="countByDeptName" resultType="int">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_sys_dept
|
||||
WHERE deleted = 0
|
||||
AND name = #{deptName}
|
||||
<if test="excludeId != null and excludeId != ''">
|
||||
AND id != #{excludeId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 根据部门ID查询部门信息(包含父部门信息) -->
|
||||
<select id="selectDeptWithParent" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
d.id, d.dept_id, d.parent_id, d.name, d.description,
|
||||
d.creator, d.updater, d.create_time, d.update_time,
|
||||
d.delete_time, d.deleted,
|
||||
p.name AS parent_name
|
||||
FROM tb_sys_dept d
|
||||
LEFT JOIN tb_sys_dept p ON d.parent_id = p.dept_id AND p.deleted = 0
|
||||
WHERE d.deleted = 0
|
||||
AND d.dept_id = #{deptId}
|
||||
</select>
|
||||
|
||||
<!-- 查询部门树结构 -->
|
||||
<select id="selectDeptTree" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tb_sys_dept
|
||||
WHERE deleted = 0
|
||||
ORDER BY
|
||||
CASE WHEN parent_id IS NULL OR parent_id = '' THEN 0 ELSE 1 END,
|
||||
parent_id,
|
||||
create_time ASC
|
||||
</select>
|
||||
|
||||
<!-- 批量删除部门(逻辑删除) -->
|
||||
<update id="batchDeleteByIds">
|
||||
UPDATE tb_sys_dept
|
||||
SET deleted = 1,
|
||||
delete_time = NOW(),
|
||||
updater = #{updater}
|
||||
WHERE deleted = 0
|
||||
AND id IN
|
||||
<foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
|
||||
#{deptId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- 插入部门 -->
|
||||
<insert id="insert" parameterType="org.xyzh.common.dto.dept.TbSysDept">
|
||||
INSERT INTO tb_sys_dept
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="deptID != null">dept_id,</if>
|
||||
<if test="parentID != null">parent_id,</if>
|
||||
<if test="name != null">name,</if>
|
||||
<if test="description != null">description,</if>
|
||||
<if test="creator != null">creator,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
deleted
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="deptID != null">#{deptID},</if>
|
||||
<if test="parentID != null">#{parentID},</if>
|
||||
<if test="name != null">#{name},</if>
|
||||
<if test="description != null">#{description},</if>
|
||||
<if test="creator != null">#{creator},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
0
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<!-- 更新部门 -->
|
||||
<update id="updateById" parameterType="org.xyzh.common.dto.dept.TbSysDept">
|
||||
UPDATE tb_sys_dept
|
||||
<set>
|
||||
<if test="deptID != null">dept_id = #{deptID},</if>
|
||||
<if test="parentID != null">parent_id = #{parentID},</if>
|
||||
<if test="name != null">name = #{name},</if>
|
||||
<if test="description != null">description = #{description},</if>
|
||||
<if test="updater != null">updater = #{updater},</if>
|
||||
update_time = NOW()
|
||||
</set>
|
||||
WHERE id = #{id} AND deleted = 0
|
||||
</update>
|
||||
|
||||
<!-- 根据ID删除(逻辑删除) -->
|
||||
<update id="deleteById">
|
||||
UPDATE tb_sys_dept
|
||||
SET deleted = 1,
|
||||
delete_time = NOW()
|
||||
WHERE id = #{id} AND deleted = 0
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
214
schoolNewsServ/system/src/main/resources/mapper/MenuMapper.xml
Normal file
214
schoolNewsServ/system/src/main/resources/mapper/MenuMapper.xml
Normal file
@@ -0,0 +1,214 @@
|
||||
<?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="org.xyzh.system.mapper.MenuMapper">
|
||||
|
||||
<!-- 基础结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.menu.TbSysMenu">
|
||||
<id column="id" property="id" jdbcType="VARCHAR"/>
|
||||
<result column="menu_id" property="menuID" jdbcType="VARCHAR"/>
|
||||
<result column="name" property="menuName" jdbcType="VARCHAR"/>
|
||||
<result column="parent_id" property="parentID" jdbcType="VARCHAR"/>
|
||||
<result column="url" property="path" jdbcType="VARCHAR"/>
|
||||
<result column="icon" property="icon" jdbcType="VARCHAR"/>
|
||||
<result column="order_num" property="sort" jdbcType="INTEGER"/>
|
||||
<result column="type" property="menuType" jdbcType="INTEGER"/>
|
||||
<result column="creator" property="creator" jdbcType="VARCHAR"/>
|
||||
<result column="updater" property="updater" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="delete_time" property="deleteTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="deleted" property="deleted" jdbcType="TINYINT"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, menu_id, name, parent_id, url, icon, order_num, type,
|
||||
creator, updater, create_time, update_time, delete_time, deleted
|
||||
</sql>
|
||||
|
||||
<!-- 通用条件 -->
|
||||
<sql id="Where_Clause">
|
||||
<where>
|
||||
deleted = 0
|
||||
<if test="menuName != null and menuName != ''">
|
||||
AND menu_name LIKE CONCAT('%', #{menuName}, '%')
|
||||
</if>
|
||||
<if test="menuType != null">
|
||||
AND menu_type = #{menuType}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="visible != null">
|
||||
AND visible = #{visible}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 根据用户ID查询菜单列表 -->
|
||||
<select id="selectMenusByUserId" resultMap="BaseResultMap">
|
||||
SELECT DISTINCT
|
||||
m.id, m.menu_id, m.parent_id, m.menu_name, m.menu_type,
|
||||
m.path, m.component, m.permission, m.icon, m.sort,
|
||||
m.visible, m.status, m.external_link, m.cache, m.frame,
|
||||
m.query, m.remark, m.creator, m.updater,
|
||||
m.create_time, m.update_time, m.delete_time, m.deleted
|
||||
FROM tb_sys_menu m
|
||||
INNER JOIN tb_sys_role_menu rm ON m.menu_id = rm.menu_id
|
||||
INNER JOIN tb_sys_user_role ur ON rm.role_id = ur.role_id
|
||||
WHERE m.deleted = 0
|
||||
AND rm.deleted = 0
|
||||
AND ur.deleted = 0
|
||||
AND ur.user_id = #{userId}
|
||||
AND m.status = 1
|
||||
AND m.visible = 1
|
||||
ORDER BY m.sort ASC, m.create_time ASC
|
||||
</select>
|
||||
|
||||
<!-- 根据角色ID查询菜单列表 -->
|
||||
<select id="selectMenusByRoleId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
m.id, m.menu_id, m.parent_id, m.menu_name, m.menu_type,
|
||||
m.path, m.component, m.permission, m.icon, m.sort,
|
||||
m.visible, m.status, m.external_link, m.cache, m.frame,
|
||||
m.query, m.remark, m.creator, m.updater,
|
||||
m.create_time, m.update_time, m.delete_time, m.deleted
|
||||
FROM tb_sys_menu m
|
||||
INNER JOIN tb_sys_role_menu rm ON m.menu_id = rm.menu_id
|
||||
WHERE m.deleted = 0
|
||||
AND rm.deleted = 0
|
||||
AND rm.role_id = #{roleId}
|
||||
ORDER BY m.sort ASC, m.create_time ASC
|
||||
</select>
|
||||
|
||||
<!-- 根据父菜单ID查询子菜单列表 -->
|
||||
<select id="selectByParentId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tb_sys_menu
|
||||
WHERE deleted = 0
|
||||
AND parent_id = #{parentId}
|
||||
ORDER BY sort ASC, create_time ASC
|
||||
</select>
|
||||
|
||||
<!-- 查询菜单树结构 -->
|
||||
<select id="selectMenuTree" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tb_sys_menu
|
||||
WHERE deleted = 0
|
||||
ORDER BY
|
||||
CASE WHEN parent_id IS NULL OR parent_id = '' THEN 0 ELSE 1 END,
|
||||
parent_id,
|
||||
sort ASC,
|
||||
create_time ASC
|
||||
</select>
|
||||
|
||||
<!-- 检查菜单名称是否存在 -->
|
||||
<select id="countByMenuName" resultType="int">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_sys_menu
|
||||
WHERE deleted = 0
|
||||
AND menu_name = #{menuName}
|
||||
<if test="excludeId != null and excludeId != ''">
|
||||
AND id != #{excludeId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 批量删除菜单(逻辑删除) -->
|
||||
<update id="batchDeleteByIds">
|
||||
UPDATE tb_sys_menu
|
||||
SET deleted = 1,
|
||||
delete_time = NOW(),
|
||||
updater = #{updater}
|
||||
WHERE deleted = 0
|
||||
AND id IN
|
||||
<foreach collection="menuIds" item="menuId" open="(" separator="," close=")">
|
||||
#{menuId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- 插入菜单 -->
|
||||
<insert id="insert" parameterType="org.xyzh.common.dto.menu.TbSysMenu">
|
||||
INSERT INTO tb_sys_menu
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="menuID != null">menu_id,</if>
|
||||
<if test="parentID != null">parent_id,</if>
|
||||
<if test="menuName != null">menu_name,</if>
|
||||
<if test="menuType != null">menu_type,</if>
|
||||
<if test="path != null">path,</if>
|
||||
<if test="component != null">component,</if>
|
||||
<if test="permission != null">permission,</if>
|
||||
<if test="icon != null">icon,</if>
|
||||
<if test="sort != null">sort,</if>
|
||||
<if test="visible != null">visible,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="externalLink != null">external_link,</if>
|
||||
<if test="cache != null">cache,</if>
|
||||
<if test="frame != null">frame,</if>
|
||||
<if test="query != null">query,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="creator != null">creator,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
deleted
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="menuID != null">#{menuID},</if>
|
||||
<if test="parentID != null">#{parentID},</if>
|
||||
<if test="menuName != null">#{menuName},</if>
|
||||
<if test="menuType != null">#{menuType},</if>
|
||||
<if test="path != null">#{path},</if>
|
||||
<if test="component != null">#{component},</if>
|
||||
<if test="permission != null">#{permission},</if>
|
||||
<if test="icon != null">#{icon},</if>
|
||||
<if test="sort != null">#{sort},</if>
|
||||
<if test="visible != null">#{visible},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="externalLink != null">#{externalLink},</if>
|
||||
<if test="cache != null">#{cache},</if>
|
||||
<if test="frame != null">#{frame},</if>
|
||||
<if test="query != null">#{query},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="creator != null">#{creator},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
0
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<!-- 更新菜单 -->
|
||||
<update id="updateById" parameterType="org.xyzh.common.dto.menu.TbSysMenu">
|
||||
UPDATE tb_sys_menu
|
||||
<set>
|
||||
<if test="menuID != null">menu_id = #{menuID},</if>
|
||||
<if test="parentID != null">parent_id = #{parentID},</if>
|
||||
<if test="menuName != null">menu_name = #{menuName},</if>
|
||||
<if test="menuType != null">menu_type = #{menuType},</if>
|
||||
<if test="path != null">path = #{path},</if>
|
||||
<if test="component != null">component = #{component},</if>
|
||||
<if test="permission != null">permission = #{permission},</if>
|
||||
<if test="icon != null">icon = #{icon},</if>
|
||||
<if test="sort != null">sort = #{sort},</if>
|
||||
<if test="visible != null">visible = #{visible},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="externalLink != null">external_link = #{externalLink},</if>
|
||||
<if test="cache != null">cache = #{cache},</if>
|
||||
<if test="frame != null">frame = #{frame},</if>
|
||||
<if test="query != null">query = #{query},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="updater != null">updater = #{updater},</if>
|
||||
update_time = NOW()
|
||||
</set>
|
||||
WHERE id = #{id} AND deleted = 0
|
||||
</update>
|
||||
|
||||
<!-- 根据ID删除(逻辑删除) -->
|
||||
<update id="deleteById">
|
||||
UPDATE tb_sys_menu
|
||||
SET deleted = 1,
|
||||
delete_time = NOW()
|
||||
WHERE id = #{id} AND deleted = 0
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,185 @@
|
||||
<?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="org.xyzh.system.mapper.PermissionMapper">
|
||||
|
||||
<!-- 基础结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.permission.TbSysPermission">
|
||||
<id column="id" property="id" jdbcType="VARCHAR"/>
|
||||
<result column="permission_id" property="permissionID" jdbcType="VARCHAR"/>
|
||||
<result column="name" property="permissionName" jdbcType="VARCHAR"/>
|
||||
<result column="code" property="permissionCode" jdbcType="VARCHAR"/>
|
||||
<result column="description" property="description" jdbcType="VARCHAR"/>
|
||||
<result column="creator" property="creator" jdbcType="VARCHAR"/>
|
||||
<result column="updater" property="updater" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="delete_time" property="deleteTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, permission_id, name, code, description, creator, updater,
|
||||
create_time, update_time, delete_time, deleted
|
||||
</sql>
|
||||
|
||||
<!-- 通用条件 -->
|
||||
<sql id="Where_Clause">
|
||||
<where>
|
||||
deleted = 0
|
||||
<if test="permissionName != null and permissionName != ''">
|
||||
AND permission_name LIKE CONCAT('%', #{permissionName}, '%')
|
||||
</if>
|
||||
<if test="permissionCode != null and permissionCode != ''">
|
||||
AND permission_code = #{permissionCode}
|
||||
</if>
|
||||
<if test="permissionType != null">
|
||||
AND permission_type = #{permissionType}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 根据用户ID查询权限列表 -->
|
||||
<select id="selectPermissionsByUserId" resultMap="BaseResultMap">
|
||||
SELECT DISTINCT
|
||||
p.id, p.permission_id, p.permission_name, p.permission_code,
|
||||
p.permission_type, p.resource_url, p.http_method, p.description,
|
||||
p.status, p.sort, p.creator, p.updater,
|
||||
p.create_time, p.update_time, p.delete_time, p.deleted
|
||||
FROM tb_sys_permission p
|
||||
INNER JOIN tb_sys_role_permission rp ON p.permission_id = rp.permission_id
|
||||
INNER JOIN tb_sys_user_role ur ON rp.role_id = ur.role_id
|
||||
WHERE p.deleted = 0
|
||||
AND rp.deleted = 0
|
||||
AND ur.deleted = 0
|
||||
AND ur.user_id = #{userID}
|
||||
AND p.status = 1
|
||||
ORDER BY p.sort ASC, p.create_time ASC
|
||||
</select>
|
||||
|
||||
<!-- 根据角色ID查询权限列表 -->
|
||||
<select id="selectPermissionsByRoleId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
p.id, p.permission_id, p.permission_name, p.permission_code,
|
||||
p.permission_type, p.resource_url, p.http_method, p.description,
|
||||
p.status, p.sort, p.creator, p.updater,
|
||||
p.create_time, p.update_time, p.delete_time, p.deleted
|
||||
FROM tb_sys_permission p
|
||||
INNER JOIN tb_sys_role_permission rp ON p.permission_id = rp.permission_id
|
||||
WHERE p.deleted = 0
|
||||
AND rp.deleted = 0
|
||||
AND rp.role_id = #{roleId}
|
||||
ORDER BY p.sort ASC, p.create_time ASC
|
||||
</select>
|
||||
|
||||
<!-- 根据权限编码查询权限 -->
|
||||
<select id="selectByPermissionCode" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tb_sys_permission
|
||||
WHERE deleted = 0
|
||||
AND permission_code = #{permissionCode}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 检查权限名称是否存在 -->
|
||||
<select id="countByPermissionName" resultType="int">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_sys_permission
|
||||
WHERE deleted = 0
|
||||
AND permission_name = #{permissionName}
|
||||
<if test="excludeId != null and excludeId != ''">
|
||||
AND id != #{excludeId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 检查权限编码是否存在 -->
|
||||
<select id="countByPermissionCode" resultType="int">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_sys_permission
|
||||
WHERE deleted = 0
|
||||
AND permission_code = #{permissionCode}
|
||||
<if test="excludeId != null and excludeId != ''">
|
||||
AND id != #{excludeId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 批量删除权限(逻辑删除) -->
|
||||
<update id="batchDeleteByIds">
|
||||
UPDATE tb_sys_permission
|
||||
SET deleted = 1,
|
||||
delete_time = NOW(),
|
||||
updater = #{updater}
|
||||
WHERE deleted = 0
|
||||
AND id IN
|
||||
<foreach collection="permissionIds" item="permissionId" open="(" separator="," close=")">
|
||||
#{permissionId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- 插入权限 -->
|
||||
<insert id="insert" parameterType="org.xyzh.common.dto.permission.TbSysPermission">
|
||||
INSERT INTO tb_sys_permission
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="permissionID != null">permission_id,</if>
|
||||
<if test="permissionName != null">permission_name,</if>
|
||||
<if test="permissionCode != null">permission_code,</if>
|
||||
<if test="permissionType != null">permission_type,</if>
|
||||
<if test="resourceUrl != null">resource_url,</if>
|
||||
<if test="httpMethod != null">http_method,</if>
|
||||
<if test="description != null">description,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="sort != null">sort,</if>
|
||||
<if test="creator != null">creator,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
deleted
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="permissionID != null">#{permissionID},</if>
|
||||
<if test="permissionName != null">#{permissionName},</if>
|
||||
<if test="permissionCode != null">#{permissionCode},</if>
|
||||
<if test="permissionType != null">#{permissionType},</if>
|
||||
<if test="resourceUrl != null">#{resourceUrl},</if>
|
||||
<if test="httpMethod != null">#{httpMethod},</if>
|
||||
<if test="description != null">#{description},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="sort != null">#{sort},</if>
|
||||
<if test="creator != null">#{creator},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
0
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<!-- 更新权限 -->
|
||||
<update id="updateById" parameterType="org.xyzh.common.dto.permission.TbSysPermission">
|
||||
UPDATE tb_sys_permission
|
||||
<set>
|
||||
<if test="permissionID != null">permission_id = #{permissionID},</if>
|
||||
<if test="permissionName != null">permission_name = #{permissionName},</if>
|
||||
<if test="permissionCode != null">permission_code = #{permissionCode},</if>
|
||||
<if test="permissionType != null">permission_type = #{permissionType},</if>
|
||||
<if test="resourceUrl != null">resource_url = #{resourceUrl},</if>
|
||||
<if test="httpMethod != null">http_method = #{httpMethod},</if>
|
||||
<if test="description != null">description = #{description},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="sort != null">sort = #{sort},</if>
|
||||
<if test="updater != null">updater = #{updater},</if>
|
||||
update_time = NOW()
|
||||
</set>
|
||||
WHERE id = #{id} AND deleted = 0
|
||||
</update>
|
||||
|
||||
<!-- 根据ID删除(逻辑删除) -->
|
||||
<update id="deleteById">
|
||||
UPDATE tb_sys_permission
|
||||
SET deleted = 1,
|
||||
delete_time = NOW()
|
||||
WHERE id = #{id} AND deleted = 0
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
153
schoolNewsServ/system/src/main/resources/mapper/RoleMapper.xml
Normal file
153
schoolNewsServ/system/src/main/resources/mapper/RoleMapper.xml
Normal file
@@ -0,0 +1,153 @@
|
||||
<?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="org.xyzh.system.mapper.RoleMapper">
|
||||
|
||||
<!-- 基础结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.role.TbSysRole">
|
||||
<id column="id" property="id" jdbcType="VARCHAR"/>
|
||||
<result column="role_id" property="roleID" jdbcType="VARCHAR"/>
|
||||
<result column="name" property="roleName" jdbcType="VARCHAR"/>
|
||||
<result column="description" property="description" jdbcType="VARCHAR"/>
|
||||
<result column="creator" property="creator" jdbcType="VARCHAR"/>
|
||||
<result column="updater" property="updater" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="delete_time" property="deleteTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, role_id, name, description, creator, updater,
|
||||
create_time, update_time, delete_time, deleted
|
||||
</sql>
|
||||
|
||||
<!-- 通用条件 -->
|
||||
<sql id="Where_Clause">
|
||||
<where>
|
||||
deleted = 0
|
||||
<if test="roleName != null and roleName != ''">
|
||||
AND role_name LIKE CONCAT('%', #{roleName}, '%')
|
||||
</if>
|
||||
<if test="roleCode != null and roleCode != ''">
|
||||
AND role_code = #{roleCode}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 根据用户ID查询角色列表 -->
|
||||
<select id="selectRolesByUserId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
r.id, r.role_id, r.role_name, r.role_code, r.description,
|
||||
r.status, r.sort, r.creator, r.updater,
|
||||
r.create_time, r.update_time, r.delete_time, r.deleted
|
||||
FROM tb_sys_role r
|
||||
INNER JOIN tb_sys_user_role ur ON r.role_id = ur.role_id
|
||||
WHERE r.deleted = 0
|
||||
AND ur.deleted = 0
|
||||
AND ur.user_id = #{userID}
|
||||
ORDER BY r.sort ASC, r.create_time ASC
|
||||
</select>
|
||||
|
||||
<!-- 根据角色编码查询角色 -->
|
||||
<select id="selectByRoleCode" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tb_sys_role
|
||||
WHERE deleted = 0
|
||||
AND role_code = #{roleCode}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 检查角色名称是否存在 -->
|
||||
<select id="countByRoleName" resultType="int">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_sys_role
|
||||
WHERE deleted = 0
|
||||
AND role_name = #{roleName}
|
||||
<if test="excludeId != null and excludeId != ''">
|
||||
AND id != #{excludeId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 检查角色编码是否存在 -->
|
||||
<select id="countByRoleCode" resultType="int">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_sys_role
|
||||
WHERE deleted = 0
|
||||
AND role_code = #{roleCode}
|
||||
<if test="excludeId != null and excludeId != ''">
|
||||
AND id != #{excludeId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 批量删除角色(逻辑删除) -->
|
||||
<update id="batchDeleteByIds">
|
||||
UPDATE tb_sys_role
|
||||
SET deleted = 1,
|
||||
delete_time = NOW(),
|
||||
updater = #{updater}
|
||||
WHERE deleted = 0
|
||||
AND id IN
|
||||
<foreach collection="roleIds" item="roleId" open="(" separator="," close=")">
|
||||
#{roleId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- 插入角色 -->
|
||||
<insert id="insert" parameterType="org.xyzh.common.dto.role.TbSysRole">
|
||||
INSERT INTO tb_sys_role
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="roleID != null">role_id,</if>
|
||||
<if test="roleName != null">role_name,</if>
|
||||
<if test="roleCode != null">role_code,</if>
|
||||
<if test="description != null">description,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="sort != null">sort,</if>
|
||||
<if test="creator != null">creator,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
deleted
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="roleID != null">#{roleID},</if>
|
||||
<if test="roleName != null">#{roleName},</if>
|
||||
<if test="roleCode != null">#{roleCode},</if>
|
||||
<if test="description != null">#{description},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="sort != null">#{sort},</if>
|
||||
<if test="creator != null">#{creator},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
0
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<!-- 更新角色 -->
|
||||
<update id="updateById" parameterType="org.xyzh.common.dto.role.TbSysRole">
|
||||
UPDATE tb_sys_role
|
||||
<set>
|
||||
<if test="roleID != null">role_id = #{roleID},</if>
|
||||
<if test="roleName != null">role_name = #{roleName},</if>
|
||||
<if test="roleCode != null">role_code = #{roleCode},</if>
|
||||
<if test="description != null">description = #{description},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="sort != null">sort = #{sort},</if>
|
||||
<if test="updater != null">updater = #{updater},</if>
|
||||
update_time = NOW()
|
||||
</set>
|
||||
WHERE id = #{id} AND deleted = 0
|
||||
</update>
|
||||
|
||||
<!-- 根据ID删除(逻辑删除) -->
|
||||
<update id="deleteById">
|
||||
UPDATE tb_sys_role
|
||||
SET deleted = 1,
|
||||
delete_time = NOW()
|
||||
WHERE id = #{id} AND deleted = 0
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
194
schoolNewsServ/system/src/main/resources/mapper/UserMapper.xml
Normal file
194
schoolNewsServ/system/src/main/resources/mapper/UserMapper.xml
Normal file
@@ -0,0 +1,194 @@
|
||||
<?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="org.xyzh.system.mapper.UserMapper">
|
||||
|
||||
<!-- 基础结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.user.TbSysUser">
|
||||
<id column="id" property="id" jdbcType="VARCHAR"/>
|
||||
<result column="username" property="username" jdbcType="VARCHAR"/>
|
||||
<result column="password" property="password" jdbcType="VARCHAR"/>
|
||||
<result column="email" property="email" jdbcType="VARCHAR"/>
|
||||
<result column="phone" property="phone" jdbcType="VARCHAR"/>
|
||||
<result column="wechat_id" property="wechatID" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="delete_time" property="deleteTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="deleted" property="deleted" jdbcType="Boolean"/>
|
||||
<result column="status" property="status" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, username, password, email, phone, wechat_id,
|
||||
create_time, update_time, delete_time, deleted, status
|
||||
</sql>
|
||||
|
||||
<!-- 通用条件 -->
|
||||
<sql id="Where_Clause">
|
||||
<where>
|
||||
deleted = 0
|
||||
<if test="username != null and username != ''">
|
||||
AND username LIKE CONCAT('%', #{username}, '%')
|
||||
</if>
|
||||
<if test="email != null and email != ''">
|
||||
AND email LIKE CONCAT('%', #{email}, '%')
|
||||
</if>
|
||||
<if test="phone != null and phone != ''">
|
||||
AND phone = #{phone}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 根据用户名查询用户 -->
|
||||
<select id="selectByUsername" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tb_sys_user
|
||||
WHERE deleted = 0
|
||||
AND username = #{username}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 根据邮箱查询用户 -->
|
||||
<select id="selectByEmail" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tb_sys_user
|
||||
WHERE deleted = 0
|
||||
AND email = #{email}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 根据手机号查询用户 -->
|
||||
<select id="selectByPhone" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tb_sys_user
|
||||
WHERE deleted = 0
|
||||
AND phone = #{phone}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 根据过滤条件查询用户 -->
|
||||
<select id="selectByFilter" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tb_sys_user
|
||||
<where>
|
||||
deleted = 0
|
||||
<if test="filter.id != null and filter.id != ''">
|
||||
AND id = #{filter.id}
|
||||
</if>
|
||||
<if test="filter.username != null and filter.username != ''">
|
||||
AND username = #{filter.username}
|
||||
</if>
|
||||
<if test="filter.email != null and filter.email != ''">
|
||||
AND email = #{filter.email}
|
||||
</if>
|
||||
<if test="filter.phone != null and filter.phone != ''">
|
||||
AND phone = #{filter.phone}
|
||||
</if>
|
||||
<if test="filter.status != null">
|
||||
AND status = #{filter.status}
|
||||
</if>
|
||||
<if test="filter.wechatID != null and filter.wechatID != ''">
|
||||
AND wechat_id = #{filter.wechatID}
|
||||
</if>
|
||||
</where>
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 查询用户列表 -->
|
||||
<select id="selectUserList" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tb_sys_user
|
||||
<include refid="Where_Clause"/>
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 批量删除用户(逻辑删除) -->
|
||||
<update id="batchDeleteByIds">
|
||||
UPDATE tb_sys_user
|
||||
SET deleted = 1,
|
||||
delete_time = NOW(),
|
||||
updater = #{updater}
|
||||
WHERE deleted = 0
|
||||
AND id IN
|
||||
<foreach collection="userIds" item="userId" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- 插入用户 -->
|
||||
<insert id="insert" parameterType="org.xyzh.common.dto.user.TbSysUser">
|
||||
INSERT INTO tb_sys_user
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="username != null">username,</if>
|
||||
<if test="password != null">password,</if>
|
||||
<if test="email != null">email,</if>
|
||||
<if test="phone != null">phone,</if>
|
||||
<if test="avatar != null">avatar,</if>
|
||||
<if test="nickname != null">nickname,</if>
|
||||
<if test="gender != null">gender,</if>
|
||||
<if test="birthday != null">birthday,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="lastLoginTime != null">last_login_time,</if>
|
||||
<if test="lastLoginIp != null">last_login_ip,</if>
|
||||
<if test="creator != null">creator,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
deleted
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="username != null">#{username},</if>
|
||||
<if test="password != null">#{password},</if>
|
||||
<if test="email != null">#{email},</if>
|
||||
<if test="phone != null">#{phone},</if>
|
||||
<if test="avatar != null">#{avatar},</if>
|
||||
<if test="nickname != null">#{nickname},</if>
|
||||
<if test="gender != null">#{gender},</if>
|
||||
<if test="birthday != null">#{birthday},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="lastLoginTime != null">#{lastLoginTime},</if>
|
||||
<if test="lastLoginIp != null">#{lastLoginIp},</if>
|
||||
<if test="creator != null">#{creator},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
0
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<!-- 更新用户 -->
|
||||
<update id="updateById" parameterType="org.xyzh.common.dto.user.TbSysUser">
|
||||
UPDATE tb_sys_user
|
||||
<set>
|
||||
<if test="username != null">username = #{username},</if>
|
||||
<if test="password != null">password = #{password},</if>
|
||||
<if test="email != null">email = #{email},</if>
|
||||
<if test="phone != null">phone = #{phone},</if>
|
||||
<if test="avatar != null">avatar = #{avatar},</if>
|
||||
<if test="nickname != null">nickname = #{nickname},</if>
|
||||
<if test="gender != null">gender = #{gender},</if>
|
||||
<if test="birthday != null">birthday = #{birthday},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="lastLoginTime != null">last_login_time = #{lastLoginTime},</if>
|
||||
<if test="lastLoginIp != null">last_login_ip = #{lastLoginIp},</if>
|
||||
<if test="updater != null">updater = #{updater},</if>
|
||||
update_time = NOW()
|
||||
</set>
|
||||
WHERE id = #{id} AND deleted = 0
|
||||
</update>
|
||||
|
||||
<!-- 根据ID删除(逻辑删除) -->
|
||||
<update id="deleteById">
|
||||
UPDATE tb_sys_user
|
||||
SET deleted = 1,
|
||||
delete_time = NOW()
|
||||
WHERE id = #{id} AND deleted = 0
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user