2024-08-25 13:31:15 +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= "com.yanzhu.manage.mapper.BusExamQuestionMapper" >
<resultMap type= "BusExamQuestion" id= "BusExamQuestionResult" >
<result property= "id" column= "id" />
2024-09-25 01:00:28 +08:00
<result property= "comId" column= "com_id" />
<result property= "comName" column= "com_name" />
2024-08-25 13:31:15 +08:00
<result property= "projectId" column= "project_id" />
2024-09-25 01:00:28 +08:00
<result property= "projectName" column= "project_name" />
2024-08-25 13:31:15 +08:00
<result property= "craftType" column= "craft_type" />
<result property= "craftPost" column= "craft_post" />
<result property= "questionDiff" column= "question_diff" />
<result property= "questionType" column= "question_type" />
2024-09-29 23:40:02 +08:00
<result property= "questionScope" column= "question_scope" />
2024-08-25 13:31:15 +08:00
<result property= "questionDesc" column= "question_desc" />
<result property= "questionAnswer" column= "question_answer" />
<result property= "isDel" column= "is_del" />
<result property= "createBy" column= "create_by" />
<result property= "createTime" column= "create_time" />
<result property= "updateBy" column= "update_by" />
<result property= "updateTime" column= "update_time" />
<result property= "remark" column= "remark" />
</resultMap>
<resultMap id= "BusExamQuestionBusExamQuestionResultResult" type= "BusExamQuestion" extends= "BusExamQuestionResult" >
<collection property= "busExamQuestionResultList" notNullColumn= "sub_id" javaType= "java.util.List" resultMap= "BusExamQuestionResultResult" />
</resultMap>
<resultMap type= "BusExamQuestionResult" id= "BusExamQuestionResultResult" >
<result property= "id" column= "sub_id" />
<result property= "questionId" column= "sub_question_id" />
<result property= "opt" column= "sub_opt" />
<result property= "result" column= "sub_result" />
2024-09-25 01:00:28 +08:00
<result property= "isOk" column= "sub_is_ok" />
2024-08-25 13:31:15 +08:00
<result property= "createBy" column= "sub_create_by" />
<result property= "createTime" column= "sub_create_time" />
<result property= "updateBy" column= "sub_update_by" />
<result property= "updateTime" column= "sub_update_time" />
<result property= "remark" column= "sub_remark" />
</resultMap>
<sql id= "selectBusExamQuestionVo" >
2024-09-29 23:40:02 +08:00
select beq.id, beq.com_id, sd.dept_name as com_name, beq.project_id, pi.project_name, beq.craft_type, beq.craft_post, beq.question_diff, beq.question_type, beq.question_scope, beq.question_desc, beq.question_answer, beq.is_del, beq.create_by, beq.create_time, beq.update_by, beq.update_time, beq.remark from bus_exam_question beq
2024-09-25 01:00:28 +08:00
left join pro_project_info pi on pi.id = beq.project_id
left join sys_dept sd on sd.dept_id = pi.com_id
2024-08-25 13:31:15 +08:00
</sql>
<select id= "selectBusExamQuestionList" parameterType= "BusExamQuestion" resultMap= "BusExamQuestionResult" >
<include refid= "selectBusExamQuestionVo" />
2024-09-25 01:00:28 +08:00
<where >
and beq.is_del != 2
<if test= "comId != null " > and (beq.com_id = #{comId} or beq.com_id is null)</if>
<if test= "projectId != null " > and (beq.project_id = #{projectId} or beq.project_id is null)</if>
<if test= "activeComId != null " > and (beq.com_id = #{activeComId} or beq.com_id is null)</if>
<if test= "activeProjectId != null " > and (beq.project_id = #{activeProjectId} or beq.project_id is null)</if>
<if test= "craftType != null and craftType != ''" > and beq.craft_type = #{craftType}</if>
<if test= "craftPost != null and craftPost != ''" > and find_in_set(#{craftPost}, beq.craft_post)</if>
<if test= "questionDiff != null " > and beq.question_diff = #{questionDiff} </if>
<if test= "questionType != null " > and beq.question_type = #{questionType} </if>
2024-09-29 23:40:02 +08:00
<if test= "questionScope != null and questionScope != ''" > and beq.question_scope = #{questionScope}</if>
2024-09-25 01:00:28 +08:00
<if test= "questionDesc != null and questionDesc != ''" > and beq.question_desc = #{questionDesc}</if>
2024-10-04 14:40:48 +08:00
<if test= "isDel != null" > and beq.is_del = #{isDel}</if>
2024-08-25 13:31:15 +08:00
</where>
2024-09-25 01:00:28 +08:00
order by beq.id desc
2024-08-25 13:31:15 +08:00
</select>
<select id= "selectBusExamQuestionById" parameterType= "Long" resultMap= "BusExamQuestionBusExamQuestionResultResult" >
2024-09-29 23:40:02 +08:00
select a.id, a.com_id, sd.dept_name as com_name, a.project_id, pi.project_name, a.craft_type, a.craft_post, a.question_diff, a.question_type, a.question_scope, a.question_desc, a.question_answer, a.is_del, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,
2024-09-25 01:00:28 +08:00
b.id as sub_id, b.question_id as sub_question_id, b.opt as sub_opt, b.result as sub_result, b.is_ok as sub_is_ok, b.create_by as sub_create_by, b.create_time as sub_create_time, b.update_by as sub_update_by, b.update_time as sub_update_time, b.remark as sub_remark
2024-08-25 13:31:15 +08:00
from bus_exam_question a
2024-09-25 01:00:28 +08:00
left join pro_project_info pi on pi.id = a.project_id
left join sys_dept sd on sd.dept_id = pi.com_id
2024-08-25 13:31:15 +08:00
left join bus_exam_question_result b on b.question_id = a.id
where a.id = #{id}
</select>
<insert id= "insertBusExamQuestion" parameterType= "BusExamQuestion" useGeneratedKeys= "true" keyProperty= "id" >
insert into bus_exam_question
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
2024-09-25 01:00:28 +08:00
<if test= "comId != null" > com_id,</if>
2024-08-25 13:31:15 +08:00
<if test= "projectId != null" > project_id,</if>
<if test= "craftType != null" > craft_type,</if>
<if test= "craftPost != null" > craft_post,</if>
<if test= "questionDiff != null" > question_diff,</if>
<if test= "questionType != null" > question_type,</if>
2024-09-29 23:40:02 +08:00
<if test= "questionScope != null" > question_scope,</if>
2024-08-25 13:31:15 +08:00
<if test= "questionDesc != null" > question_desc,</if>
<if test= "questionAnswer != null" > question_answer,</if>
<if test= "isDel != null" > is_del,</if>
<if test= "createBy != null" > create_by,</if>
<if test= "createTime != null" > create_time,</if>
<if test= "updateBy != null" > update_by,</if>
<if test= "updateTime != null" > update_time,</if>
<if test= "remark != null" > remark,</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
2024-09-25 01:00:28 +08:00
<if test= "comId != null" > #{comId},</if>
2024-08-25 13:31:15 +08:00
<if test= "projectId != null" > #{projectId},</if>
<if test= "craftType != null" > #{craftType},</if>
<if test= "craftPost != null" > #{craftPost},</if>
<if test= "questionDiff != null" > #{questionDiff},</if>
<if test= "questionType != null" > #{questionType},</if>
2024-09-29 23:40:02 +08:00
<if test= "questionScope != null" > #{questionScope},</if>
2024-08-25 13:31:15 +08:00
<if test= "questionDesc != null" > #{questionDesc},</if>
<if test= "questionAnswer != null" > #{questionAnswer},</if>
<if test= "isDel != null" > #{isDel},</if>
<if test= "createBy != null" > #{createBy},</if>
<if test= "createTime != null" > #{createTime},</if>
<if test= "updateBy != null" > #{updateBy},</if>
<if test= "updateTime != null" > #{updateTime},</if>
<if test= "remark != null" > #{remark},</if>
</trim>
</insert>
<update id= "updateBusExamQuestion" parameterType= "BusExamQuestion" >
update bus_exam_question
<trim prefix= "SET" suffixOverrides= "," >
2024-09-25 01:00:28 +08:00
<if test= "comId != null" > com_id = #{comId},</if>
2024-08-25 13:31:15 +08:00
<if test= "projectId != null" > project_id = #{projectId},</if>
<if test= "craftType != null" > craft_type = #{craftType},</if>
<if test= "craftPost != null" > craft_post = #{craftPost},</if>
<if test= "questionDiff != null" > question_diff = #{questionDiff},</if>
<if test= "questionType != null" > question_type = #{questionType},</if>
2024-09-29 23:40:02 +08:00
<if test= "questionScope != null" > question_scope = #{questionScope},</if>
2024-08-25 13:31:15 +08:00
<if test= "questionDesc != null" > question_desc = #{questionDesc},</if>
<if test= "questionAnswer != null" > question_answer = #{questionAnswer},</if>
<if test= "isDel != null" > is_del = #{isDel},</if>
<if test= "createBy != null" > create_by = #{createBy},</if>
<if test= "createTime != null" > create_time = #{createTime},</if>
<if test= "updateBy != null" > update_by = #{updateBy},</if>
<if test= "updateTime != null" > update_time = #{updateTime},</if>
<if test= "remark != null" > remark = #{remark},</if>
</trim>
where id = #{id}
</update>
2024-09-25 01:00:28 +08:00
<update id= "deleteBusExamQuestionById" parameterType= "Long" >
update bus_exam_question set is_del=2 where id = #{id}
</update>
2024-08-25 13:31:15 +08:00
<delete id= "deleteBusExamQuestionByIds" parameterType= "String" >
2024-09-25 01:00:28 +08:00
update bus_exam_question set is_del=2 where id in
2024-08-25 13:31:15 +08:00
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</delete>
<delete id= "deleteBusExamQuestionResultByQuestionIds" parameterType= "String" >
delete from bus_exam_question_result where question_id in
<foreach item= "questionId" collection= "array" open= "(" separator= "," close= ")" >
#{questionId}
</foreach>
</delete>
<delete id= "deleteBusExamQuestionResultByQuestionId" parameterType= "Long" >
delete from bus_exam_question_result where question_id = #{questionId}
</delete>
<insert id= "batchBusExamQuestionResult" >
2024-09-25 01:00:28 +08:00
insert into bus_exam_question_result( id, question_id, opt, result, is_ok, create_by, create_time, update_by, update_time) values
2024-08-25 13:31:15 +08:00
<foreach item= "item" index= "index" collection= "list" separator= "," >
2024-09-25 01:00:28 +08:00
( #{item.id}, #{item.questionId}, #{item.opt}, #{item.result}, #{item.isOk}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime})
2024-08-25 13:31:15 +08:00
</foreach>
</insert>
2024-09-25 01:00:28 +08:00
2024-08-25 13:31:15 +08:00
</mapper>