ganzi-api/inventory-dao/src/main/resources/mapper/SysResourceMapper.xml
2022-09-16 15:07:17 +08:00

312 lines
11 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.rzyc.mapper.personal.SysResourceMapper">
<resultMap id="BaseResultMap" type="com.rzyc.model.personal.SysResource">
<result column="resource_id" jdbcType="VARCHAR" property="resourceId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="path" jdbcType="VARCHAR" property="path" />
<result column="component" jdbcType="VARCHAR" property="component" />
<result column="meta" jdbcType="VARCHAR" property="meta" />
<result column="parent_id" jdbcType="VARCHAR" property="parentId" />
<result column="redirect" jdbcType="VARCHAR" property="redirect" />
<result column="sort_id" jdbcType="INTEGER" property="sortId" />
<result column="modified" jdbcType="VARCHAR" property="modified" />
<result column="created" jdbcType="VARCHAR" property="created" />
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="hidden" jdbcType="VARCHAR" property="hidden" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
resource_id, name, path, component, meta, parent_id, redirect, sort_id, modified,
created, modify_time, create_time
</sql>
<select id="selectByExample" parameterType="com.rzyc.model.personal.SysResourceExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from sys_resource
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
<if test="limit != null">
<if test="offset != null">
limit ${offset}, ${limit}
</if>
<if test="offset == null">
limit ${limit}
</if>
</if>
</select>
<delete id="deleteByExample" parameterType="com.rzyc.model.personal.SysResourceExample">
delete from sys_resource
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.rzyc.model.personal.SysResource">
insert into sys_resource (resource_id, name, path,
component, meta, parent_id,
redirect, sort_id, modified,
created, modify_time, create_time
)
values (#{resourceId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{path,jdbcType=VARCHAR},
#{component,jdbcType=VARCHAR}, #{meta,jdbcType=VARCHAR}, #{parentId,jdbcType=VARCHAR},
#{redirect,jdbcType=VARCHAR}, #{sortId,jdbcType=INTEGER}, #{modified,jdbcType=VARCHAR},
#{created,jdbcType=VARCHAR}, #{modifyTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.rzyc.model.personal.SysResource">
insert into sys_resource
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="resourceId != null">
resource_id,
</if>
<if test="name != null">
name,
</if>
<if test="path != null">
path,
</if>
<if test="component != null">
component,
</if>
<if test="meta != null">
meta,
</if>
<if test="parentId != null">
parent_id,
</if>
<if test="redirect != null">
redirect,
</if>
<if test="sortId != null">
sort_id,
</if>
<if test="modified != null">
modified,
</if>
<if test="created != null">
created,
</if>
<if test="modifyTime != null">
modify_time,
</if>
<if test="createTime != null">
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="resourceId != null">
#{resourceId,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="path != null">
#{path,jdbcType=VARCHAR},
</if>
<if test="component != null">
#{component,jdbcType=VARCHAR},
</if>
<if test="meta != null">
#{meta,jdbcType=VARCHAR},
</if>
<if test="parentId != null">
#{parentId,jdbcType=VARCHAR},
</if>
<if test="redirect != null">
#{redirect,jdbcType=VARCHAR},
</if>
<if test="sortId != null">
#{sortId,jdbcType=INTEGER},
</if>
<if test="modified != null">
#{modified,jdbcType=VARCHAR},
</if>
<if test="created != null">
#{created,jdbcType=VARCHAR},
</if>
<if test="modifyTime != null">
#{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.rzyc.model.personal.SysResourceExample" resultType="java.lang.Long">
select count(*) from sys_resource
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update sys_resource
<set>
<if test="record.resourceId != null">
resource_id = #{record.resourceId,jdbcType=VARCHAR},
</if>
<if test="record.name != null">
name = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.path != null">
path = #{record.path,jdbcType=VARCHAR},
</if>
<if test="record.component != null">
component = #{record.component,jdbcType=VARCHAR},
</if>
<if test="record.meta != null">
meta = #{record.meta,jdbcType=VARCHAR},
</if>
<if test="record.parentId != null">
parent_id = #{record.parentId,jdbcType=VARCHAR},
</if>
<if test="record.redirect != null">
redirect = #{record.redirect,jdbcType=VARCHAR},
</if>
<if test="record.sortId != null">
sort_id = #{record.sortId,jdbcType=INTEGER},
</if>
<if test="record.modified != null">
modified = #{record.modified,jdbcType=VARCHAR},
</if>
<if test="record.created != null">
created = #{record.created,jdbcType=VARCHAR},
</if>
<if test="record.modifyTime != null">
modify_time = #{record.modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update sys_resource
set resource_id = #{record.resourceId,jdbcType=VARCHAR},
name = #{record.name,jdbcType=VARCHAR},
path = #{record.path,jdbcType=VARCHAR},
component = #{record.component,jdbcType=VARCHAR},
meta = #{record.meta,jdbcType=VARCHAR},
parent_id = #{record.parentId,jdbcType=VARCHAR},
redirect = #{record.redirect,jdbcType=VARCHAR},
sort_id = #{record.sortId,jdbcType=INTEGER},
modified = #{record.modified,jdbcType=VARCHAR},
created = #{record.created,jdbcType=VARCHAR},
modify_time = #{record.modifyTime,jdbcType=TIMESTAMP},
create_time = #{record.createTime,jdbcType=TIMESTAMP}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<!--角色功能-->
<select id="findByRoleId" resultMap="BaseResultMap">
SELECT sr.* FROM sys_role_resource rr
LEFT JOIN sys_resource sr ON rr.`resource_id` = sr.`resource_id`
WHERE rr.`role_id` = #{roleId}
and sr.resource_id is not null
ORDER BY sr.`sort_id` ASC
</select>
<!--查询全部-->
<select id="findAll" resultMap="BaseResultMap">
SELECT * FROM `sys_resource`
</select>
<!--资源字段-->
<resultMap id="ResourceResultMap" type="com.rzyc.model.personal.SysResource">
<result column="resource_id" jdbcType="VARCHAR" property="resourceId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="path" jdbcType="VARCHAR" property="path" />
<result column="component" jdbcType="VARCHAR" property="component" />
<result column="meta" jdbcType="VARCHAR" property="meta" />
<result column="parent_id" jdbcType="VARCHAR" property="parentId" />
<result column="redirect" jdbcType="VARCHAR" property="redirect" />
<result column="role_resource_id" jdbcType="VARCHAR" property="roleResourceId" />
<result column="sort_id" jdbcType="INTEGER" property="sortId" />
<result column="modified" jdbcType="VARCHAR" property="modified" />
<result column="created" jdbcType="VARCHAR" property="created" />
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="hidden" jdbcType="VARCHAR" property="hidden" />
</resultMap>
<!--角色资源-->
<select id="roleResource" resultMap="ResourceResultMap">
SELECT rr.`role_resource_id`,sr.*
FROM sys_resource sr
LEFT JOIN sys_role_resource rr
ON sr.`resource_id` = rr.`resource_id`
AND rr.`role_id` = #{roleId}
ORDER BY sr.`sort_id` ASC
</select>
</mapper>