ganzi-api/inventory-dao/src/main/resources/mapper/SysRoleMapper.xml
2022-12-29 14:12:53 +08:00

307 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.SysRoleMapper">
<resultMap id="BaseResultMap" type="com.rzyc.model.SysRole">
<id column="SysRoleId" jdbcType="CHAR" property="sysroleid" />
<result column="RoleCode" jdbcType="VARCHAR" property="rolecode" />
<result column="RoleName" jdbcType="VARCHAR" property="rolename" />
<result column="SpecialRole" jdbcType="VARCHAR" property="specialrole" />
<result column="ModifiedBy" jdbcType="VARCHAR" property="modifiedby" />
<result column="ModifiedOn" jdbcType="TIMESTAMP" property="modifiedon" />
<result column="CreatedBy" jdbcType="VARCHAR" property="createdby" />
<result column="CreatedOn" jdbcType="TIMESTAMP" property="createdon" />
</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">
SysRoleId, RoleCode, RoleName, SpecialRole, ModifiedBy, ModifiedOn, CreatedBy, CreatedOn
</sql>
<select id="selectByExample" parameterType="com.rzyc.model.SysRoleExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from SysRole
<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>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from SysRole
where SysRoleId = #{sysroleid,jdbcType=CHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from SysRole
where SysRoleId = #{sysroleid,jdbcType=CHAR}
</delete>
<delete id="deleteByExample" parameterType="com.rzyc.model.SysRoleExample">
delete from SysRole
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.rzyc.model.SysRole">
insert into SysRole (SysRoleId, RoleCode, RoleName,
SpecialRole, ModifiedBy, ModifiedOn,
CreatedBy, CreatedOn)
values (#{sysroleid,jdbcType=CHAR}, #{rolecode,jdbcType=VARCHAR}, #{rolename,jdbcType=VARCHAR},
#{specialrole,jdbcType=VARCHAR}, #{modifiedby,jdbcType=VARCHAR}, #{modifiedon,jdbcType=TIMESTAMP},
#{createdby,jdbcType=VARCHAR}, #{createdon,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.rzyc.model.SysRole">
insert into SysRole
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sysroleid != null">
SysRoleId,
</if>
<if test="rolecode != null">
RoleCode,
</if>
<if test="rolename != null">
RoleName,
</if>
<if test="specialrole != null">
SpecialRole,
</if>
<if test="modifiedby != null">
ModifiedBy,
</if>
<if test="modifiedon != null">
ModifiedOn,
</if>
<if test="createdby != null">
CreatedBy,
</if>
<if test="createdon != null">
CreatedOn,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sysroleid != null">
#{sysroleid,jdbcType=CHAR},
</if>
<if test="rolecode != null">
#{rolecode,jdbcType=VARCHAR},
</if>
<if test="rolename != null">
#{rolename,jdbcType=VARCHAR},
</if>
<if test="specialrole != null">
#{specialrole,jdbcType=VARCHAR},
</if>
<if test="modifiedby != null">
#{modifiedby,jdbcType=VARCHAR},
</if>
<if test="modifiedon != null">
#{modifiedon,jdbcType=TIMESTAMP},
</if>
<if test="createdby != null">
#{createdby,jdbcType=VARCHAR},
</if>
<if test="createdon != null">
#{createdon,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.rzyc.model.SysRoleExample" resultType="java.lang.Long">
select count(*) from SysRole
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update SysRole
<set>
<if test="record.sysroleid != null">
SysRoleId = #{record.sysroleid,jdbcType=CHAR},
</if>
<if test="record.rolecode != null">
RoleCode = #{record.rolecode,jdbcType=VARCHAR},
</if>
<if test="record.rolename != null">
RoleName = #{record.rolename,jdbcType=VARCHAR},
</if>
<if test="record.specialrole != null">
SpecialRole = #{record.specialrole,jdbcType=VARCHAR},
</if>
<if test="record.modifiedby != null">
ModifiedBy = #{record.modifiedby,jdbcType=VARCHAR},
</if>
<if test="record.modifiedon != null">
ModifiedOn = #{record.modifiedon,jdbcType=TIMESTAMP},
</if>
<if test="record.createdby != null">
CreatedBy = #{record.createdby,jdbcType=VARCHAR},
</if>
<if test="record.createdon != null">
CreatedOn = #{record.createdon,jdbcType=TIMESTAMP},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update SysRole
set SysRoleId = #{record.sysroleid,jdbcType=CHAR},
RoleCode = #{record.rolecode,jdbcType=VARCHAR},
RoleName = #{record.rolename,jdbcType=VARCHAR},
SpecialRole = #{record.specialrole,jdbcType=VARCHAR},
ModifiedBy = #{record.modifiedby,jdbcType=VARCHAR},
ModifiedOn = #{record.modifiedon,jdbcType=TIMESTAMP},
CreatedBy = #{record.createdby,jdbcType=VARCHAR},
CreatedOn = #{record.createdon,jdbcType=TIMESTAMP}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.rzyc.model.SysRole">
update SysRole
<set>
<if test="rolecode != null">
RoleCode = #{rolecode,jdbcType=VARCHAR},
</if>
<if test="rolename != null">
RoleName = #{rolename,jdbcType=VARCHAR},
</if>
<if test="specialrole != null">
SpecialRole = #{specialrole,jdbcType=VARCHAR},
</if>
<if test="modifiedby != null">
ModifiedBy = #{modifiedby,jdbcType=VARCHAR},
</if>
<if test="modifiedon != null">
ModifiedOn = #{modifiedon,jdbcType=TIMESTAMP},
</if>
<if test="createdby != null">
CreatedBy = #{createdby,jdbcType=VARCHAR},
</if>
<if test="createdon != null">
CreatedOn = #{createdon,jdbcType=TIMESTAMP},
</if>
</set>
where SysRoleId = #{sysroleid,jdbcType=CHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.rzyc.model.SysRole">
update SysRole
set RoleCode = #{rolecode,jdbcType=VARCHAR},
RoleName = #{rolename,jdbcType=VARCHAR},
SpecialRole = #{specialrole,jdbcType=VARCHAR},
ModifiedBy = #{modifiedby,jdbcType=VARCHAR},
ModifiedOn = #{modifiedon,jdbcType=TIMESTAMP},
CreatedBy = #{createdby,jdbcType=VARCHAR},
CreatedOn = #{createdon,jdbcType=TIMESTAMP}
where SysRoleId = #{sysroleid,jdbcType=CHAR}
</update>
<!--用户角色-->
<select id="userRoles" resultMap="BaseResultMap">
SELECT * FROM SysRole sr WHERE sr.`SysRoleId` in
<foreach collection="roleIds" item="roleId" index="index" open="(" close=")" separator=",">
#{roleId}
</foreach>
;
</select>
<!--用户角色-->
<select id="findAll" resultMap="BaseResultMap">
SELECT * FROM `SysRole` sr ORDER BY sr.`RoleCode` ASC
</select>
<!--角色分页-->
<select id="rolePage" resultMap="BaseResultMap">
SELECT * FROM SysRole sr WHERE sr.`RoleName` LIKE #{condition}
</select>
<!--管理员角色-->
<select id="adminRole" resultMap="BaseResultMap">
SELECT * FROM SysRole sr
WHERE sr.`manage_state` = #{manageState}
order by sr.ModifiedOn DESC
limit 1
</select>
<!--修改角色-->
<update id="changeRole" >
update SysRole
set
RoleCode = #{record.rolecode,jdbcType=VARCHAR},
RoleName = #{record.rolename,jdbcType=VARCHAR},
SpecialRole = #{record.specialrole,jdbcType=VARCHAR},
ModifiedBy = #{record.modifiedby,jdbcType=VARCHAR},
ModifiedOn = #{record.modifiedon,jdbcType=TIMESTAMP}
where SysRoleId = #{record.sysroleid,jdbcType=CHAR}
</update>
</mapper>