123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- <?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.jeeplus.modules.exam.mapper.EduQuestionMapper">
- <resultMap id="eduQuestionMap" type="EduQuestion">
- <id property="id" column="id" />
- <result property="title" column="title" />
- <result property="types" column="types" />
- <result property="points" column="points" />
- <result property="judgment" column="judgment" />
- <result property="pici" column="pici" />
- <collection property="eduQuestionOptionList" javaType="ArrayList"
- column="id" ofType="com.jeeplus.modules.exam.entity.EduQuestionOption" fetchType="lazy"
- select="com.jeeplus.modules.exam.mapper.EduQuestionOptionMapper.findByQuestionId" >
- <id property="id" column="id" />
- <result property="title" column="title" />
- <result property="isAnswer" column="is_answer"/>
- </collection>
- </resultMap>
- <sql id="eduQuestionColumns">
- a.id AS "id",
- a.title AS "title",
- a.types AS "types",
- a.points AS "points",
- a.is_fix AS "isFix",
- a.del_flag AS "delFlag",
- a.judgment AS "judgment",
- a.pici AS "pici"
- </sql>
-
- <sql id="eduQuestionJoins">
-
- </sql>
-
-
- <select id="get" resultType="EduQuestion" >
- SELECT
- <include refid="eduQuestionColumns"/>
- FROM edu_question a
- <include refid="eduQuestionJoins"/>
- WHERE a.id = #{id}
- </select>
-
- <select id="findList" resultType="EduQuestion" >
- SELECT
- <include refid="eduQuestionColumns"/>
- FROM edu_question a
- <include refid="eduQuestionJoins"/>
- <where>
- a.del_flag = #{DEL_FLAG_NORMAL}
- ${dataScope}
- <if test="types != null and types != ''">
- AND a.types = #{types}
- </if>
- <if test="isFix != null and isFix != ''">
- AND a.is_fix = #{isFix}
- </if>
- <if test="title != null and title != ''">
- AND a.title LIKE
- <if test="dbName == 'oracle'">'%'||#{title}||'%'</if>
- <if test="dbName == 'mssql'">'%'+#{title}+'%'</if>
- <if test="dbName == 'mysql'">concat('%',#{title},'%')</if>
- </if>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY isFix DESC,types
- </otherwise>
- </choose>
- </select>
- <!--根据数量随机抽取试题-->
- <select id="randomGet" resultType="EduQuestion" >
- SELECT
- <include refid="eduQuestionColumns"/>
- FROM edu_question a
- <where>
- a.del_flag = 0
- <if test="isFix != null and isFix != ''">
- AND a.is_fix = #{isFix}
- </if>
- <if test="pici != null and pici != ''">
- AND a.pici = #{pici}
- </if>
- </where>
- Order By rand() Limit ${num}
- </select>
- <select id="findByPaper" resultType="EduQuestion">
- SELECT
- <include refid="eduQuestionColumns"/>
- FROM edu_question a, edu_paper_detail b
- <where>
- b.question_id = a.id AND
- a.del_flag = #{DEL_FLAG_NORMAL}
- ${dataScope}
- <if test="title != null and title != ''">
- AND a.title LIKE
- <if test="dbName == 'oracle'">'%'||#{title}||'%'</if>
- <if test="dbName == 'mssql'">'%'+#{title}+'%'</if>
- <if test="dbName == 'mysql'">concat('%',#{title},'%')</if>
- </if>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
- <select id="findQuestionOption" resultMap="eduQuestionMap">
- SELECT
- <include refid="eduQuestionColumns"/>
- FROM edu_question a, edu_paper_detail b
- <where>
- b.question_id = a.id AND
- a.del_flag = #{DEL_FLAG_NORMAL}
- ${dataScope}
- group by a.id
- </where>
- <choose>
- <when test="num != null">
- Order By rand() Limit ${num}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
- <select id="findAllList" resultType="EduQuestion" >
- SELECT
- <include refid="eduQuestionColumns"/>
- FROM edu_question a
- <include refid="eduQuestionJoins"/>
- <where>
- a.del_flag = #{DEL_FLAG_NORMAL}
- ${dataScope}
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
- <insert id="insert">
- INSERT INTO edu_question(
- id,
- title,
- types,
- points,
- del_flag,
- is_fix,
- judgment,
- pici
- ) VALUES (
- #{id},
- #{title},
- #{types},
- #{points},
- #{delFlag},
- #{isFix},
- #{judgment},
- #{pici}
- )
- </insert>
-
- <update id="update">
- UPDATE edu_question SET
- title = #{title},
- types = #{types},
- points = #{points},
- is_fix = #{isFix},
- judgment = #{judgment},
- pici = #{pici}
- WHERE id = #{id}
- </update>
-
-
- <!--物理删除-->
- <update id="delete">
- DELETE FROM edu_question
- WHERE id = #{id}
- </update>
-
- <!--逻辑删除-->
- <update id="deleteByLogic">
- UPDATE edu_question SET
- del_flag = #{DEL_FLAG_DELETE}
- WHERE id = #{id}
- </update>
-
-
- <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
- <select id="findUniqueByProperty" resultType="EduQuestion" statementType="STATEMENT">
- select * FROM edu_question where ${propertyName} = '${value}'
- </select>
-
- </mapper>
|