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">
2020-11-19 18:28:54 +08:00
<mapper namespace= "club.joylink.rtss.dao.RaceQuestionDAO" >
<resultMap id= "BaseResultMap" type= "club.joylink.rtss.entity.RaceQuestion" >
2020-11-19 10:07:10 +08:00
<id column= "id" jdbcType= "BIGINT" property= "id" />
<result column= "topic" jdbcType= "VARCHAR" property= "topic" />
<result column= "type" jdbcType= "VARCHAR" property= "type" />
<result column= "create_user_id" jdbcType= "BIGINT" property= "createUserId" />
<result column= "create_time" jdbcType= "TIMESTAMP" property= "createTime" />
<result column= "project_code" jdbcType= "VARCHAR" property= "projectCode" />
<result column= "company_id" jdbcType= "INTEGER" property= "companyId" />
</resultMap>
2020-11-19 18:28:54 +08:00
<resultMap id= "ResultMapRef" type= "club.joylink.rtss.vo.client.question.QuestionVO" >
2020-11-19 10:07:10 +08:00
<id column= "id" jdbcType= "BIGINT" property= "id" />
<result column= "topic" jdbcType= "VARCHAR" property= "topic" />
<result column= "type" jdbcType= "VARCHAR" property= "type" />
<result column= "project_code" jdbcType= "VARCHAR" property= "projectCode" />
<result column= "company_id" jdbcType= "VARCHAR" property= "companyId" />
2020-11-19 18:28:54 +08:00
<collection property= "optionList" ofType= "club.joylink.rtss.vo.client.question.QuestionOptionVO" >
2020-11-19 10:07:10 +08:00
<id column= "oid" jdbcType= "BIGINT" property= "id" />
<result column= "content" jdbcType= "VARCHAR" property= "content" />
<result column= "correct" jdbcType= "BIT" property= "correct" />
<result column= "order" jdbcType= "TINYINT" property= "order" />
</collection>
</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, topic, `type`, create_user_id, create_time, project_code, company_id
</sql>
<select id= "selectWithRef" resultMap= "ResultMapRef" >
SELECT q.id,q.topic,q.type,q.project_code,q.company_id, o.id oid,o.content,o.correct,o.order FROM race_question q JOIN race_question_option o ON q.id = o.question_id
<where >
<if test= "topic != null" >
q.topic LIKE concat('%',#{topic},'%')
</if>
<if test= "type != null" >
AND q.type = #{type}
</if>
<if test= "projectCode != null" >
AND q.project_code = #{projectCode}
</if>
<if test= "projectCode == null" >
AND q.project_code is null
<if test= "companyId != null" >
AND q.company_id = #{companyId}
</if>
<if test= "companyId == null" >
AND q.company_id is null
</if>
</if>
</where>
</select>
2020-11-19 18:28:54 +08:00
<select id= "countNumByType" resultType= "club.joylink.rtss.vo.client.competition.TheoryQuestionCountVO" >
2020-11-19 10:07:10 +08:00
select count(*) as num,`type` from race_question
<where >
<if test= "projectCode != null" >
project_code = #{projectCode}
</if>
<if test= "projectCode == null" >
project_code is null
<if test= "companyId != null" >
AND company_id = #{companyId}
</if>
<if test= "companyId == null" >
AND company_id is null
</if>
</if>
</where>
group by `type`
</select>
2020-11-19 18:28:54 +08:00
<select id= "selectByExample" parameterType= "club.joylink.rtss.entity.RaceQuestionExample" resultMap= "BaseResultMap" >
2020-11-19 10:07:10 +08:00
select
<if test= "distinct" >
distinct
</if>
<include refid= "Base_Column_List" />
from race_question
<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 race_question
where id = #{id,jdbcType=BIGINT}
</select>
<delete id= "deleteByPrimaryKey" parameterType= "java.lang.Long" >
delete from race_question
where id = #{id,jdbcType=BIGINT}
</delete>
2020-11-19 18:28:54 +08:00
<delete id= "deleteByExample" parameterType= "club.joylink.rtss.entity.RaceQuestionExample" >
2020-11-19 10:07:10 +08:00
delete from race_question
<if test= "_parameter != null" >
<include refid= "Example_Where_Clause" />
</if>
</delete>
2020-11-19 18:28:54 +08:00
<insert id= "insert" keyColumn= "id" keyProperty= "id" parameterType= "club.joylink.rtss.entity.RaceQuestion" useGeneratedKeys= "true" >
2020-11-19 10:07:10 +08:00
insert into race_question (topic, `type`, create_user_id,
create_time, project_code, company_id
)
values (#{topic,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{createUserId,jdbcType=BIGINT},
#{createTime,jdbcType=TIMESTAMP}, #{projectCode,jdbcType=VARCHAR}, #{companyId,jdbcType=INTEGER}
)
</insert>
2020-11-19 18:28:54 +08:00
<insert id= "insertSelective" keyColumn= "id" keyProperty= "id" parameterType= "club.joylink.rtss.entity.RaceQuestion" useGeneratedKeys= "true" >
2020-11-19 10:07:10 +08:00
insert into race_question
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "topic != null" >
topic,
</if>
<if test= "type != null" >
`type`,
</if>
<if test= "createUserId != null" >
create_user_id,
</if>
<if test= "createTime != null" >
create_time,
</if>
<if test= "projectCode != null" >
project_code,
</if>
<if test= "companyId != null" >
company_id,
</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "topic != null" >
#{topic,jdbcType=VARCHAR},
</if>
<if test= "type != null" >
#{type,jdbcType=VARCHAR},
</if>
<if test= "createUserId != null" >
#{createUserId,jdbcType=BIGINT},
</if>
<if test= "createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test= "projectCode != null" >
#{projectCode,jdbcType=VARCHAR},
</if>
<if test= "companyId != null" >
#{companyId,jdbcType=INTEGER},
</if>
</trim>
</insert>
2020-11-19 18:28:54 +08:00
<select id= "countByExample" parameterType= "club.joylink.rtss.entity.RaceQuestionExample" resultType= "java.lang.Long" >
2020-11-19 10:07:10 +08:00
select count(*) from race_question
<if test= "_parameter != null" >
<include refid= "Example_Where_Clause" />
</if>
</select>
<update id= "updateByExampleSelective" parameterType= "map" >
update race_question
<set >
<if test= "record.id != null" >
id = #{record.id,jdbcType=BIGINT},
</if>
<if test= "record.topic != null" >
topic = #{record.topic,jdbcType=VARCHAR},
</if>
<if test= "record.type != null" >
`type` = #{record.type,jdbcType=VARCHAR},
</if>
<if test= "record.createUserId != null" >
create_user_id = #{record.createUserId,jdbcType=BIGINT},
</if>
<if test= "record.createTime != null" >
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test= "record.projectCode != null" >
project_code = #{record.projectCode,jdbcType=VARCHAR},
</if>
<if test= "record.companyId != null" >
company_id = #{record.companyId,jdbcType=INTEGER},
</if>
</set>
<if test= "_parameter != null" >
<include refid= "Update_By_Example_Where_Clause" />
</if>
</update>
<update id= "updateByExample" parameterType= "map" >
update race_question
set id = #{record.id,jdbcType=BIGINT},
topic = #{record.topic,jdbcType=VARCHAR},
`type` = #{record.type,jdbcType=VARCHAR},
create_user_id = #{record.createUserId,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
project_code = #{record.projectCode,jdbcType=VARCHAR},
company_id = #{record.companyId,jdbcType=INTEGER}
<if test= "_parameter != null" >
<include refid= "Update_By_Example_Where_Clause" />
</if>
</update>
2020-11-19 18:28:54 +08:00
<update id= "updateByPrimaryKeySelective" parameterType= "club.joylink.rtss.entity.RaceQuestion" >
2020-11-19 10:07:10 +08:00
update race_question
<set >
<if test= "topic != null" >
topic = #{topic,jdbcType=VARCHAR},
</if>
<if test= "type != null" >
`type` = #{type,jdbcType=VARCHAR},
</if>
<if test= "createUserId != null" >
create_user_id = #{createUserId,jdbcType=BIGINT},
</if>
<if test= "createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test= "projectCode != null" >
project_code = #{projectCode,jdbcType=VARCHAR},
</if>
<if test= "companyId != null" >
company_id = #{companyId,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
2020-11-19 18:28:54 +08:00
<update id= "updateByPrimaryKey" parameterType= "club.joylink.rtss.entity.RaceQuestion" >
2020-11-19 10:07:10 +08:00
update race_question
set topic = #{topic,jdbcType=VARCHAR},
`type` = #{type,jdbcType=VARCHAR},
create_user_id = #{createUserId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
project_code = #{projectCode,jdbcType=VARCHAR},
company_id = #{companyId,jdbcType=INTEGER}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>