feat:自定义接口权限
This commit is contained in:
170
xs-service/src/main/resources/mapper/user/XPermission.xml
Normal file
170
xs-service/src/main/resources/mapper/user/XPermission.xml
Normal file
@@ -0,0 +1,170 @@
|
||||
<?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.XPermissionMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.xiang.xservice.auth.service.entity.XPermission" >
|
||||
<result column="id" property="id" />
|
||||
<result column="name" property="name" />
|
||||
<result column="code" property="code" />
|
||||
<result column="type" property="type" />
|
||||
<result column="parent_id" property="parentId" />
|
||||
<result column="api_path" property="apiPath" />
|
||||
<result column="method" property="method" />
|
||||
<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">
|
||||
id,
|
||||
name,
|
||||
code,
|
||||
type,
|
||||
parent_id,
|
||||
api_path,
|
||||
method,
|
||||
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.XPermission">
|
||||
INSERT INTO x_permission
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="null != name and '' != name">
|
||||
name,
|
||||
</if>
|
||||
<if test="null != code and '' != code">
|
||||
code,
|
||||
</if>
|
||||
<if test="null != type ">
|
||||
type,
|
||||
</if>
|
||||
<if test="null != parentId ">
|
||||
parent_id,
|
||||
</if>
|
||||
<if test="null != apiPath and '' != apiPath">
|
||||
api_path,
|
||||
</if>
|
||||
<if test="null != method and '' != method">
|
||||
method,
|
||||
</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 != code and '' != code">
|
||||
#{code},
|
||||
</if>
|
||||
<if test="null != type ">
|
||||
#{type},
|
||||
</if>
|
||||
<if test="null != parentId ">
|
||||
#{parentId},
|
||||
</if>
|
||||
<if test="null != apiPath and '' != apiPath">
|
||||
#{apiPath},
|
||||
</if>
|
||||
<if test="null != method and '' != method">
|
||||
#{method},
|
||||
</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_permission set del_flag = 1, update_by = #{operator}, update_time = NOW()
|
||||
where id in
|
||||
<foreach collection="list" item="id" open="(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="update" parameterType="com.xiang.xservice.auth.service.entity.XPermission">
|
||||
UPDATE x_permission
|
||||
<set>
|
||||
<if test="null != name and '' != name">name = #{name},</if>
|
||||
<if test="null != code and '' != code">code = #{code},</if>
|
||||
<if test="null != type ">type = #{type},</if>
|
||||
<if test="null != parentId ">parent_id = #{parentId},</if>
|
||||
<if test="null != apiPath and '' != apiPath">api_path = #{apiPath},</if>
|
||||
<if test="null != method and '' != method">method = #{method},</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="getPermissionList" resultMap="BaseResultMap">
|
||||
select <include refid="Base_Column_List"/>
|
||||
from x_permission
|
||||
<trim prefix="AND">
|
||||
<where>
|
||||
del_flag = 0
|
||||
<if test="name != null and name != ''">name = #{name}</if>
|
||||
<if test="code != null and code != ''">code = #{code}</if>
|
||||
<if test="type != null">type = #{type}</if>
|
||||
<if test="method != null and method != ''">method = #{method}</if>
|
||||
<if test="apiPath != null and apiPath != ''">api_path = #{apiPath}</if>
|
||||
</where>
|
||||
</trim>
|
||||
</select>
|
||||
<select id="getPermissionByIds" resultMap="BaseResultMap">
|
||||
select <include refid="Base_Column_List"/>
|
||||
from x_permission
|
||||
where id in
|
||||
<foreach collection="list" item="id" open="(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="getPermissionById" resultMap="BaseResultMap">
|
||||
select <include refid="Base_Column_List"/>
|
||||
from x_permission
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="loadAllPermission" resultType="com.xiang.xservice.auth.api.dto.resp.PermissionRoleDTO">
|
||||
select p.api_path api_url, p.method, r.code as role_code
|
||||
from x_permission p
|
||||
join x_role_permission rp on p.id = rp.permission_id
|
||||
join x_role r on rp.role_id = r.id
|
||||
where p.del_flag = 0 and r.del_flag = 0 and r.status = 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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.XRolePermissionMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.xiang.xservice.auth.service.entity.XRolePermission" >
|
||||
<result property="roleId" column="role_id"/>
|
||||
<result property="permissionId" column="permission_id"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
role_id,
|
||||
permission_id
|
||||
</sql>
|
||||
<select id="getRolePermissionsByRoleId" resultMap="BaseResultMap">
|
||||
select <include refid="Base_Column_List"/>
|
||||
from x_role_permission
|
||||
where role_id = #{roleId}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user