191 lines
7.5 KiB
XML
191 lines
7.5 KiB
XML
<?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" />
|
|
<result column="service_name" property="serviceName"/>
|
|
</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,
|
|
service_name
|
|
</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>
|
|
<if test="serviceName != null and serviceName != ''">
|
|
service_name
|
|
</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>
|
|
<if test="serviceName != null and serviceName != ''">
|
|
#{serviceName}
|
|
</if>
|
|
</trim>
|
|
</insert>
|
|
<insert id="addBatch">
|
|
insert into x_permission(name, code, type, api_path, method, created_time,
|
|
create_by, updated_time, update_by, service_name)
|
|
values
|
|
<foreach collection="list" item="item" separator=",">
|
|
(#{item.name}, #{item.code}, #{item.type}, #{item.apiPath}, #{item.method}, #{item.createdTime},
|
|
#{item.createBy}, #{item.updatedTime}, #{item.updateBy}, #{item.serviceName})
|
|
</foreach>
|
|
</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>
|
|
<if test="null != serviceName and serviceName != ''">service_name = #{serviceName}</if>
|
|
</set>
|
|
WHERE id = #{id}
|
|
</update>
|
|
<delete id="delByServiceName">
|
|
delete from x_permission where service_name = #{serviceName}
|
|
</delete>
|
|
<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="ids" 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> |