123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd">
- <mapper namespace="cn.xyz.mapper.ExamMapper">
- <resultMap id="BaseResultMap" type="cn.xyz.mianshi.vo.ExamVO">
- <result column="id" property="examId" jdbcType="INTEGER" />
- <result column="company_id" property="companyId" jdbcType="INTEGER" />
- <result column="type" property="examType" jdbcType="INTEGER" />
- <result column="name" property="examName" jdbcType="VARCHAR" />
- <result column="time" property="time" jdbcType="INTEGER" />
- <result column="is_precise_time" property="isPreciseTime"
- jdbcType="INTEGER" />
- <result column="status" property="status" jdbcType="INTEGER" />
- </resultMap>
- <insert id="savePaidExam" parameterType="java.util.Map">
- <![CDATA[
- INSERT INTO tb_company_exam (company_id, exam_id, create_time, status) VALUES (${companyId}, ${examId}, UNIX_TIMESTAMP(), 1)
- ]]>
- </insert>
- <select id="selectPaidExamId" parameterType="java.util.Map"
- resultType="java.lang.Integer">
- <![CDATA[
- SELECT exam_id FROM tb_company_exam WHERE company_id = ${companyId}
- ]]>
- </select>
- <select id="selectExamType" resultType="cn.xyz.mianshi.vo.ExamType">
- <![CDATA[
- SELECT * FROM tb_exam_type
- ]]>
- </select>
- <select id="get" parameterType="java.lang.Integer" resultMap="BaseResultMap">
- <![CDATA[
- SELECT * FROM tb_exam WHERE id = ${value}
- ]]>
- </select>
- <select id="countByExample" parameterType="java.util.Map"
- resultType="java.lang.Integer">
- SELECT COUNT(*) FROM tb_exam WHERE 1 = 1
- <if test="companyId != null">AND company_id = ${companyId}</if>
- <if test="type != 0">AND type = ${type}</if>
- <if test="status != 0">AND status = ${status}</if>
- <if test="idList != null">
- <foreach item="item" index="index" collection="idList" open="("
- separator="," close=")">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="selectByExample" parameterType="java.util.Map"
- resultMap="BaseResultMap">
- SELECT * FROM tb_exam WHERE 1 = 1
- <if test="companyId != null">AND company_id = ${companyId}</if>
- <if test="type != null and type != 0">AND type = ${type}</if>
- <if test="status != null and status != 0">AND status = ${status}</if>
- <if test="idList != null">
- AND id IN
- <foreach item="item" index="index" collection="idList" open="("
- separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="limit != null">limit ${limit}</if>
- </select>
- <insert id="insert" parameterType="cn.xyz.mianshi.vo.ExamVO">
- <selectKey keyProperty="examId" resultType="java.lang.Integer"
- order="AFTER">
- <![CDATA[
- SELECT LAST_INSERT_ID() as examId
- ]]>
- </selectKey>
- <![CDATA[
- INSERT INTO tb_exam (
- company_id,
- type,
- name,
- time,
- is_precise_time,
- status
- )
- VALUES
- (
- #{companyId,jdbcType=INTEGER},
- #{examType,jdbcType=INTEGER},
- #{examName,jdbcType=VARCHAR},
- #{time,jdbcType=INTEGER},
- #{isPreciseTime,jdbcType=INTEGER},
- 1
- )
- ]]>
- </insert>
- <update id="delete" parameterType="java.lang.Integer">
- DELETE FROM tb_exam WHERE id =
- ${value}
- </update>
- <update id="update" parameterType="cn.xyz.mianshi.vo.ExamVO">
- UPDATE tb_exam
- <set>
- <if test="examType != null">
- type = #{examType,jdbcType=INTEGER},
- </if>
- <if test="examName != null">
- name = #{examName,jdbcType=VARCHAR},
- </if>
- <if test="time != null">
- time = #{time,jdbcType=INTEGER},
- </if>
- <if test="isPreciseTime != null">
- is_precise_time = #{isPreciseTime,jdbcType=INTEGER},
- </if>
- <if test="status != null">
- status = #{status,jdbcType=INTEGER},
- </if>
- </set>
- WHERE id = #{examId,jdbcType=INTEGER}
- </update>
- <resultMap id="ExamGradingResultMap" type="cn.xyz.mianshi.vo.ExamGrading">
- <result column="id" property="id" jdbcType="INTEGER" />
- <result column="exam_id" property="examid" jdbcType="INTEGER" />
- <result column="min_score" property="minScore" jdbcType="INTEGER" />
- <result column="max_score" property="maxScore" jdbcType="INTEGER" />
- <result column="title" property="title" jdbcType="VARCHAR" />
- <result column="desc" property="desc" jdbcType="VARCHAR" />
- </resultMap>
- <insert id="saveExamGrading" parameterType="cn.xyz.mianshi.vo.ExamGrading">
- <selectKey keyProperty="id" resultType="java.lang.Integer"
- order="AFTER">
- <![CDATA[
- SELECT LAST_INSERT_ID() as id
- ]]>
- </selectKey>
- <![CDATA[
- INSERT INTO tb_exam_grading (
- exam_id,
- min_score,
- max_score,
- title,
- desc
- )
- VALUES
- (
- #{examId,jdbcType=INTEGER},
- #{minScore,jdbcType=INTEGER},
- #{maxScore,jdbcType=INTEGER},
- #{title,jdbcType=VARCHAR},
- #{desc,jdbcType=VARCHAR}
- )
- ]]>
- </insert>
- <select id="selectExamGrading" parameterType="java.lang.Integer"
- resultMap="ExamGradingResultMap">
- <![CDATA[
- SELECT * FROM tb_exam_grading WHERE exam_id = ${value}
- ]]>
- </select>
- <select id="getExamGradingByScore" parameterType="java.lang.Integer"
- resultMap="ExamGradingResultMap">
- <![CDATA[
- SELECT * FROM tb_exam_grading WHERE min_score <= ${value} AND ${value} <= max_score
- ]]>
- </select>
- </mapper>
|