xiangpei
2024-05-11 d470757bba19143fd3fc441365fcbb2362dfd0f0
src/main/resources/mapper/QuestionMapper.xml
@@ -16,7 +16,8 @@
    <result column="deleted" jdbcType="BIT" property="deleted" />
  </resultMap>
  <sql id="Base_Column_List">
    id, question_type, subject_id, score, grade_level, difficult, correct, info_text_content_id,
        id
        , question_type, subject_id, score, grade_level, difficult, correct, info_text_content_id,
    create_user, status, create_time, deleted
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
@@ -26,22 +27,22 @@
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from t_question
        delete
        from t_question
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.mindskip.xzs.domain.Question" useGeneratedKeys="true" keyProperty="id">
    insert into t_question (id, question_type, subject_id,
      score, grade_level, difficult,
      correct, info_text_content_id, create_user,
      status, create_time, deleted
      )
                                status, create_time, deleted)
    values (#{id,jdbcType=INTEGER}, #{questionType,jdbcType=INTEGER}, #{subjectId,jdbcType=INTEGER},
      #{score,jdbcType=INTEGER}, #{gradeLevel,jdbcType=INTEGER}, #{difficult,jdbcType=INTEGER},
      #{correct,jdbcType=VARCHAR}, #{infoTextContentId,jdbcType=INTEGER}, #{createUser,jdbcType=INTEGER},
      #{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT}
      )
                #{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT})
  </insert>
  <insert id="insertSelective" parameterType="com.mindskip.xzs.domain.Question" useGeneratedKeys="true" keyProperty="id">
    <insert id="insertSelective" parameterType="com.mindskip.xzs.domain.Question" useGeneratedKeys="true"
            keyProperty="id">
    insert into t_question
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
@@ -176,9 +177,8 @@
  </update>
  <select id="page" resultMap="BaseResultMap" parameterType="com.mindskip.xzs.viewmodel.admin.question.QuestionPageRequestVM">
    <select id="page" resultMap="BaseResultMap"
            parameterType="com.mindskip.xzs.viewmodel.admin.question.QuestionPageRequestVM">
    SELECT
    q.*
    FROM t_question q
@@ -206,12 +206,12 @@
        and t.content->'$."titleContent"' LIKE concat('%',#{questionName},'%')
      </if>
      <if test="content != null">
        and q.info_text_content_id in (SELECT id FROM t_text_content WHERE content like concat('%',#{content},'%') )
                and q.info_text_content_id in (SELECT id FROM t_text_content WHERE content like
                concat('%',#{content},'%') )
      </if>
    </where>
    group by q.id
  </select>
  <select id="selectByIds" resultMap="BaseResultMap" >
@@ -226,11 +226,14 @@
  <select id="selectAllCount"  resultType="java.lang.Integer">
      SELECT count(*) from t_question where  deleted=0
        SELECT count(*)
        from t_question
        where deleted = 0
   </select>
  <select id="selectCountByDate"  resultType="com.mindskip.xzs.domain.other.KeyValue">
      SELECT create_time as name,COUNT(create_time) as value from
        SELECT create_time as name, COUNT(create_time) as value
        from
              (
              SELECT DATE_FORMAT(create_time,'%Y-%m-%d') as create_time from t_question
               WHERE  deleted=0  and  create_time  between  #{startTime}  and  #{endTime}
@@ -239,7 +242,8 @@
   </select>
  <select id="getAll"  resultMap="BaseResultMap">
    SELECT <include refid="Base_Column_List"/>
        SELECT
        <include refid="Base_Column_List"/>
        from t_question where  deleted=0
  </select>
@@ -272,11 +276,25 @@
  </resultMap>
  <select id="selectSubjects" resultType="string">
        SELECT ts.name
        FROM t_question_subject tqs
                 INNER JOIN t_subject ts
                            ON tqs.subject_id = ts.id AND tqs.question_id = #{id} AND tqs.deleted = 0 AND ts.deleted = 0
    </select>
    <select id="getVoByIds" resultType="com.mindskip.xzs.domain.vo.QuestionVO">
    SELECT
           ts.name
            tq.id,
            tq.question_type as questionType,
            tq.difficult,
            ttc.content as contentJson
    FROM
        t_question_subject tqs
             INNER JOIN t_subject ts ON tqs.subject_id = ts.id AND tqs.question_id = #{id} AND tqs.deleted = 0 AND ts.deleted = 0
            t_question tq
                INNER JOIN t_text_content ttc ON tq.info_text_content_id = ttc.id AND tq.deleted = 0 AND tq.id IN
        <foreach
                collection="ids" open="(" separator="," close=")" item="id">
            #{id}
        </foreach>
  </select>
</mapper>