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

230 lines
8.4 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.SysRoleResourceMapper">
<resultMap id="BaseResultMap" type="com.rzyc.model.SysRoleResource">
<result column="role_resource_id" jdbcType="VARCHAR" property="roleResourceId" />
<result column="role_id" jdbcType="VARCHAR" property="roleId" />
<result column="resource_id" jdbcType="VARCHAR" property="resourceId" />
<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" />
</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">
role_resource_id, role_id, resource_id, modified, created, modify_time, create_time
</sql>
<select id="selectByExample" parameterType="com.rzyc.model.SysRoleResourceExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from sys_role_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.SysRoleResourceExample">
delete from sys_role_resource
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.rzyc.model.SysRoleResource">
insert into sys_role_resource (role_resource_id, role_id, resource_id,
modified, created, modify_time,
create_time)
values (#{roleResourceId,jdbcType=VARCHAR}, #{roleId,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR},
#{modified,jdbcType=VARCHAR}, #{created,jdbcType=VARCHAR}, #{modifyTime,jdbcType=TIMESTAMP},
#{createTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.rzyc.model.SysRoleResource">
insert into sys_role_resource
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="roleResourceId != null">
role_resource_id,
</if>
<if test="roleId != null">
role_id,
</if>
<if test="resourceId != null">
resource_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="roleResourceId != null">
#{roleResourceId,jdbcType=VARCHAR},
</if>
<if test="roleId != null">
#{roleId,jdbcType=VARCHAR},
</if>
<if test="resourceId != null">
#{resourceId,jdbcType=VARCHAR},
</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.SysRoleResourceExample" resultType="java.lang.Long">
select count(*) from sys_role_resource
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update sys_role_resource
<set>
<if test="record.roleResourceId != null">
role_resource_id = #{record.roleResourceId,jdbcType=VARCHAR},
</if>
<if test="record.roleId != null">
role_id = #{record.roleId,jdbcType=VARCHAR},
</if>
<if test="record.resourceId != null">
resource_id = #{record.resourceId,jdbcType=VARCHAR},
</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_role_resource
set role_resource_id = #{record.roleResourceId,jdbcType=VARCHAR},
role_id = #{record.roleId,jdbcType=VARCHAR},
resource_id = #{record.resourceId,jdbcType=VARCHAR},
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>
<!--删除角色资源-->
<delete id="delRoleId">
DELETE FROM `sys_role_resource` WHERE role_id = #{roleId}
</delete>
<!--批量插入-->
<insert id="insertList" >
insert into sys_role_resource (role_resource_id, role_id, resource_id,
modified, created, modify_time,
create_time)
values
<foreach collection="records" item="record" separator=",">
(#{record.roleResourceId,jdbcType=VARCHAR}, #{record.roleId,jdbcType=VARCHAR},
#{record.resourceId,jdbcType=VARCHAR},
#{record.modified,jdbcType=VARCHAR}, #{record.created,jdbcType=VARCHAR},
#{record.modifyTime,jdbcType=TIMESTAMP},
#{record.createTime,jdbcType=TIMESTAMP})
</foreach>
</insert>
</mapper>