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

213 lines
7.8 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.CompetitionRecordDAO">
<resultMap id="BaseResultMap" type="club.joylink.rtss.entity.CompetitionRecord">
2020-11-19 10:07:10 +08:00
<id column="id" jdbcType="BIGINT" property="id" />
<result column="user_id" jdbcType="BIGINT" property="userId" />
<result column="competition_id" jdbcType="BIGINT" property="competitionId" />
<result column="score" jdbcType="REAL" property="score" />
<result column="date_time" jdbcType="TIMESTAMP" property="dateTime" />
</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, user_id, competition_id, score, date_time
</sql>
<select id="selectByExample" parameterType="club.joylink.rtss.entity.CompetitionRecordExample" resultMap="BaseResultMap">
2020-11-19 10:07:10 +08:00
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from competition_record
<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 competition_record
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from competition_record
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="club.joylink.rtss.entity.CompetitionRecordExample">
2020-11-19 10:07:10 +08:00
delete from competition_record
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.CompetitionRecord" useGeneratedKeys="true">
2020-11-19 10:07:10 +08:00
insert into competition_record (user_id, competition_id, score,
date_time)
values (#{userId,jdbcType=BIGINT}, #{competitionId,jdbcType=BIGINT}, #{score,jdbcType=REAL},
#{dateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.CompetitionRecord" useGeneratedKeys="true">
2020-11-19 10:07:10 +08:00
insert into competition_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">
user_id,
</if>
<if test="competitionId != null">
competition_id,
</if>
<if test="score != null">
score,
</if>
<if test="dateTime != null">
date_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">
#{userId,jdbcType=BIGINT},
</if>
<if test="competitionId != null">
#{competitionId,jdbcType=BIGINT},
</if>
<if test="score != null">
#{score,jdbcType=REAL},
</if>
<if test="dateTime != null">
#{dateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="club.joylink.rtss.entity.CompetitionRecordExample" resultType="java.lang.Long">
2020-11-19 10:07:10 +08:00
select count(*) from competition_record
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update competition_record
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=BIGINT},
</if>
<if test="record.competitionId != null">
competition_id = #{record.competitionId,jdbcType=BIGINT},
</if>
<if test="record.score != null">
score = #{record.score,jdbcType=REAL},
</if>
<if test="record.dateTime != null">
date_time = #{record.dateTime,jdbcType=TIMESTAMP},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update competition_record
set id = #{record.id,jdbcType=BIGINT},
user_id = #{record.userId,jdbcType=BIGINT},
competition_id = #{record.competitionId,jdbcType=BIGINT},
score = #{record.score,jdbcType=REAL},
date_time = #{record.dateTime,jdbcType=TIMESTAMP}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="club.joylink.rtss.entity.CompetitionRecord">
2020-11-19 10:07:10 +08:00
update competition_record
<set>
<if test="userId != null">
user_id = #{userId,jdbcType=BIGINT},
</if>
<if test="competitionId != null">
competition_id = #{competitionId,jdbcType=BIGINT},
</if>
<if test="score != null">
score = #{score,jdbcType=REAL},
</if>
<if test="dateTime != null">
date_time = #{dateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="club.joylink.rtss.entity.CompetitionRecord">
2020-11-19 10:07:10 +08:00
update competition_record
set user_id = #{userId,jdbcType=BIGINT},
competition_id = #{competitionId,jdbcType=BIGINT},
score = #{score,jdbcType=REAL},
date_time = #{dateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>