rt-sim-training-service/src/main/resources/mybatis/mapper/UserPermissionDAO.xml

323 lines
12 KiB
XML
Raw Normal View History

2020-11-19 10:07:10 +08:00
<?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="club.joylink.rtss.dao.UserPermissionDAO">
<resultMap id="BaseResultMap" type="club.joylink.rtss.entity.UserPermission">
2020-11-19 10:07:10 +08:00
<id column="id" jdbcType="BIGINT" property="id" />
<result column="permission_id" jdbcType="BIGINT" property="permissionId" />
<result column="user_id" jdbcType="BIGINT" property="userId" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="amount" jdbcType="INTEGER" property="amount" />
<result column="remains" jdbcType="INTEGER" property="remains" />
<result column="forever" jdbcType="BIT" property="forever" />
<result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
<result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
<result column="distribute_id" jdbcType="BIGINT" property="distributeId" />
<result column="can_distribute" jdbcType="BIT" property="canDistribute" />
<result column="owner_id" jdbcType="BIGINT" property="ownerId" />
</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">
id, permission_id, user_id, `status`, amount, remains, forever, start_time, end_time,
distribute_id, can_distribute, owner_id
</sql>
<select id="selectByExample" parameterType="club.joylink.rtss.entity.UserPermissionExample" resultMap="BaseResultMap">
2020-11-19 10:07:10 +08:00
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from user_permission
<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.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from user_permission
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from user_permission
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="club.joylink.rtss.entity.UserPermissionExample">
2020-11-19 10:07:10 +08:00
delete from user_permission
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.UserPermission" useGeneratedKeys="true">
2020-11-19 10:07:10 +08:00
insert into user_permission (permission_id, user_id, `status`,
amount, remains, forever,
start_time, end_time, distribute_id,
can_distribute, owner_id)
values (#{permissionId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR},
#{amount,jdbcType=INTEGER}, #{remains,jdbcType=INTEGER}, #{forever,jdbcType=BIT},
#{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{distributeId,jdbcType=BIGINT},
#{canDistribute,jdbcType=BIT}, #{ownerId,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.UserPermission" useGeneratedKeys="true">
2020-11-19 10:07:10 +08:00
insert into user_permission
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="permissionId != null">
permission_id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="status != null">
`status`,
</if>
<if test="amount != null">
amount,
</if>
<if test="remains != null">
remains,
</if>
<if test="forever != null">
forever,
</if>
<if test="startTime != null">
start_time,
</if>
<if test="endTime != null">
end_time,
</if>
<if test="distributeId != null">
distribute_id,
</if>
<if test="canDistribute != null">
can_distribute,
</if>
<if test="ownerId != null">
owner_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="permissionId != null">
#{permissionId,jdbcType=BIGINT},
</if>
<if test="userId != null">
#{userId,jdbcType=BIGINT},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="amount != null">
#{amount,jdbcType=INTEGER},
</if>
<if test="remains != null">
#{remains,jdbcType=INTEGER},
</if>
<if test="forever != null">
#{forever,jdbcType=BIT},
</if>
<if test="startTime != null">
#{startTime,jdbcType=TIMESTAMP},
</if>
<if test="endTime != null">
#{endTime,jdbcType=TIMESTAMP},
</if>
<if test="distributeId != null">
#{distributeId,jdbcType=BIGINT},
</if>
<if test="canDistribute != null">
#{canDistribute,jdbcType=BIT},
</if>
<if test="ownerId != null">
#{ownerId,jdbcType=BIGINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="club.joylink.rtss.entity.UserPermissionExample" resultType="java.lang.Long">
2020-11-19 10:07:10 +08:00
select count(*) from user_permission
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update user_permission
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.permissionId != null">
permission_id = #{record.permissionId,jdbcType=BIGINT},
</if>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=BIGINT},
</if>
<if test="record.status != null">
`status` = #{record.status,jdbcType=VARCHAR},
</if>
<if test="record.amount != null">
amount = #{record.amount,jdbcType=INTEGER},
</if>
<if test="record.remains != null">
remains = #{record.remains,jdbcType=INTEGER},
</if>
<if test="record.forever != null">
forever = #{record.forever,jdbcType=BIT},
</if>
<if test="record.startTime != null">
start_time = #{record.startTime,jdbcType=TIMESTAMP},
</if>
<if test="record.endTime != null">
end_time = #{record.endTime,jdbcType=TIMESTAMP},
</if>
<if test="record.distributeId != null">
distribute_id = #{record.distributeId,jdbcType=BIGINT},
</if>
<if test="record.canDistribute != null">
can_distribute = #{record.canDistribute,jdbcType=BIT},
</if>
<if test="record.ownerId != null">
owner_id = #{record.ownerId,jdbcType=BIGINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update user_permission
set id = #{record.id,jdbcType=BIGINT},
permission_id = #{record.permissionId,jdbcType=BIGINT},
user_id = #{record.userId,jdbcType=BIGINT},
`status` = #{record.status,jdbcType=VARCHAR},
amount = #{record.amount,jdbcType=INTEGER},
remains = #{record.remains,jdbcType=INTEGER},
forever = #{record.forever,jdbcType=BIT},
start_time = #{record.startTime,jdbcType=TIMESTAMP},
end_time = #{record.endTime,jdbcType=TIMESTAMP},
distribute_id = #{record.distributeId,jdbcType=BIGINT},
can_distribute = #{record.canDistribute,jdbcType=BIT},
owner_id = #{record.ownerId,jdbcType=BIGINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="club.joylink.rtss.entity.UserPermission">
2020-11-19 10:07:10 +08:00
update user_permission
<set>
<if test="permissionId != null">
permission_id = #{permissionId,jdbcType=BIGINT},
</if>
<if test="userId != null">
user_id = #{userId,jdbcType=BIGINT},
</if>
<if test="status != null">
`status` = #{status,jdbcType=VARCHAR},
</if>
<if test="amount != null">
amount = #{amount,jdbcType=INTEGER},
</if>
<if test="remains != null">
remains = #{remains,jdbcType=INTEGER},
</if>
<if test="forever != null">
forever = #{forever,jdbcType=BIT},
</if>
<if test="startTime != null">
start_time = #{startTime,jdbcType=TIMESTAMP},
</if>
<if test="endTime != null">
end_time = #{endTime,jdbcType=TIMESTAMP},
</if>
<if test="distributeId != null">
distribute_id = #{distributeId,jdbcType=BIGINT},
</if>
<if test="canDistribute != null">
can_distribute = #{canDistribute,jdbcType=BIT},
</if>
<if test="ownerId != null">
owner_id = #{ownerId,jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="club.joylink.rtss.entity.UserPermission">
2020-11-19 10:07:10 +08:00
update user_permission
set permission_id = #{permissionId,jdbcType=BIGINT},
user_id = #{userId,jdbcType=BIGINT},
`status` = #{status,jdbcType=VARCHAR},
amount = #{amount,jdbcType=INTEGER},
remains = #{remains,jdbcType=INTEGER},
forever = #{forever,jdbcType=BIT},
start_time = #{startTime,jdbcType=TIMESTAMP},
end_time = #{endTime,jdbcType=TIMESTAMP},
distribute_id = #{distributeId,jdbcType=BIGINT},
can_distribute = #{canDistribute,jdbcType=BIT},
owner_id = #{ownerId,jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>