kongzy
2024-09-14 f0f00e9ba8a755e4317e029d73b69a92ad9f9df1
exam-system/src/main/resources/mapper/system/ExExamPaperMapper.xml
@@ -9,7 +9,7 @@
        <result property="companyId"         column="company_id"          />
        <result property="categoryId"         column="category_id"          />
        <result property="limitTime"         column="limit_time"          />
        <result property="limit"         column="limit"          />
        <result property="limited"         column="limited"          />
        <result property="singleNum"         column="single_num"          />
        <result property="singleScore"         column="single_score"          />
        <result property="singleBankId"         column="single_bank_id"          />
@@ -22,28 +22,38 @@
        <result property="judgeScore"         column="judge_score"          />
        <result property="judgeBankId"         column="judge_bank_id"          />
        <result property="judgeMethod"         column="judge_method"          />
        <result property="easyNum"         column="easy_num"          />
        <result property="easyScore"         column="easy_score"          />
        <result property="easyBankId"         column="easy_bank_id"          />
        <result property="easyMethod"         column="easy_method"          />
        <result property="passScore"         column="pass_score"          />
        <result property="version"         column="version"          />
        <result property="delFlag"         column="del_flag"          />
        <result property="createBy"       column="create_by"       />
        <result property="deadline"     column="deadline"     />
        <result property="createTime"     column="create_time"     />
        <result property="updateBy"       column="update_by"       />
        <result property="updateTime"     column="update_time"     />
        <result property="remark"         column="remark"          />
        <result property="companyName"         column="company_name"          />
        <collection property="singleQuestions" ofType="com.gkhy.exam.system.domain.ExQuestion" select="getQuestionByPaperId" column="{paperId=id,questionType=1}"/>
        <collection property="multiQuestions" ofType="com.gkhy.exam.system.domain.ExQuestion" select="getQuestionByPaperId" column="{paperId=id,questionType=2}"/>
        <collection property="judgeQuestions" ofType="com.gkhy.exam.system.domain.ExQuestion" select="getQuestionByPaperId" column="{paperId=id,questionType=3}"/>
        <result property="categoryName"         column="category_name"          />
        <association property="paperStudentInfoVO" javaType="com.gkhy.exam.system.domain.vo.PaperStudentInfoVO"  select="getPaperStudentInfoByPaperId" column="{paperId=id}"/>
    </resultMap>
    <resultMap type="com.gkhy.exam.system.domain.ExExamPaper" id="ExamPaperResult2" extends="ExamPaperResult">
        <collection property="questions" ofType="com.gkhy.exam.system.domain.ExQuestion" select="getQuestionByPaperId" column="{paperId=id}"/>
    </resultMap>
    <sql id="selectExamPaperVo">
        select a.id, a.name, a.code, a.status, a.company_id,a.category_id,a.limit_time,a.limit,a.single_num,a.single_score,a.single_bank_id,
        select a.id, a.name, a.code, a.status, a.company_id,a.category_id,a.deadline,a.limit_time,a.limited,a.single_num,a.single_score,a.single_bank_id,
               a.single_method,a.multi_num,a.multi_score,
               a.multi_bank_id,a.multi_method,a.judge_num,a.judge_score,a.judge_bank_id,a.judge_method,a.pass_score,
               a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,b.name as company_name
               a.easy_num,a.easy_score,a.easy_bank_id,a.easy_method,
               a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,b.name as company_name,c.name as category_name
        from ex_exam_paper a
        left join sys_company b on b.id=a.company_id
        left join sys_category c on c.id=a.category_id
    </sql>
    <update id="deletePaperById">
@@ -64,11 +74,14 @@
            <if test="companyId != null and companyId != ''">
                AND a.company_id= #{companyId}
            </if>
            <if test="categoryId != null and categoryId != ''">
                AND a.category_id= #{categoryId}
            </if>
        </where>
        order by a.id desc
    </select>
    <select id="selectExamPaperById" resultMap="ExamPaperResult">
    <select id="selectExamPaperById" resultMap="ExamPaperResult2">
        <include refid="selectExamPaperVo"/>
        where a.id=#{paperId}
    </select>
@@ -78,16 +91,28 @@
    </select>
    <select id="checkNameUnique" resultType="com.gkhy.exam.system.domain.ExExamPaper">
        select id ,name from ex_exam_paper where name=#{name} limit 1
        select id ,name from ex_exam_paper where name=#{name} and del_flag=0
        <if test="companyId!=null">
            and company_id=#{companyId}
        </if>
        limit 1
    </select>
    <select id="getQuestionByPaperId" resultType="com.gkhy.exam.system.domain.ExQuestion">
        select a.* from ex_question a
        inner join ex_paper_question b on a.id=b.question_id
        where b.paper_id=#{paperId} and a.question_type=#{questionType}
        order by a.id asc
        where b.paper_id=#{paperId}
        order by a.question_type asc,a.id asc
    </select>
    <select id="getPaperStudentInfoByPaperId" resultType="com.gkhy.exam.system.domain.vo.PaperStudentInfoVO">
        select count(1) as student_count,ifnull(sum(passed),0) pass_student_count,ROUND(ifnull(avg(score),0),2) as avg_score,
               (select count(1) from ex_paper_student where paper_id=#{paperId} and state!=0) as finish_count
        from ex_paper_student  where paper_id=#{paperId}
    </select>