kongzy
2024-11-07 41c7e0ebcdaa27eef33c86f2c455bee0df9a38d3
exam-system/src/main/resources/mapper/system/ExPhaseStudentMapper.xml
@@ -11,24 +11,30 @@
        <result property="studentPhone"     column="student_phone"     />
        <result property="phaseName"     column="phase_name"     />
        <result property="createName"     column="create_name"     />
        <result property="period"     column="period"     />
        <association property="course" javaType="com.gkhy.exam.system.domain.ExCourse" resultMap="courseResult" />
        <collection property="totalProgress" ofType="java.math.BigDecimal" select="getTotalProgress" column="{phaseId=phase_id,studentId=student_id}"/>
        <collection property="startTime" ofType="java.time.LocalDateTime" select="getStartTime" column="{phaseId=phase_id,studentId=student_id}"/>
    </resultMap>
    <resultMap id="courseResult" type="com.gkhy.exam.system.domain.ExCourse">
        <id     property="id"       column="course_id"        />
        <result property="name"     column="course_name"      />
        <result property="logo"     column="course_logo"      />
        <association property="period" javaType="java.lang.Long"  select="getCoursePeriod" column="{courseId=course_id}"/>
    </resultMap>
    <insert id="batchInsert" parameterType="java.util.List">
        insert into ex_phase_student(phase_id,student_id) values
        insert into ex_phase_student(phase_id,student_id,create_id) values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.phaseId},#{item.studentId})
            (#{item.phaseId},#{item.studentId},#{item.createId})
        </foreach>
    </insert>
    <select id="countByPhaseId" resultType="java.lang.Integer">
        select count(1) from ex_phase_student where phase_id#{phaseId}
        select count(1) from ex_phase_student where phase_id=#{phaseId}
    </select>
    <select id="selectPhaseStudentById" resultMap="ExPhaseStudentResult">
    <select id="selectPhaseStudentById" resultType="com.gkhy.exam.system.domain.ExPhaseStudent">
        select a.*,b.phone as student_phone,b.name as student_name from ex_phase_student a
        left join ex_student b on a.student_id=b.id
        where a.id=#{phaseStudentId}
@@ -43,11 +49,11 @@
    </select>
    <select id="selectPhaseStudentList" resultMap="ExPhaseStudentResult">
        select a.*,b.phone as student_phone,b.name as student_name,c.name as phase_name,d.period,e.name as create_name from ex_phase_student a
        select a.*,b.phone as student_phone,b.name as student_name,c.name as phase_name,e.name as create_name,d.id as course_id,d.logo as course_logo,d.name as course_name from ex_phase_student a
        left join ex_student b on a.student_id=b.id
        left join ex_course_phase c on c.id=a.phase_id
        left join ex_course d on d.id=c.couser_id
        left join sys_user e e.id=a.create_id
        left join ex_course d on d.id=c.course_id
        left join sys_user e on e.id=a.create_id
        <where>
            and c.del_flag=0 and b.del_flag=0
            <if test="phaseId!=null">
@@ -56,8 +62,8 @@
            <if test="studentName!=null and studentName!=''">
                and b.name like concat('%',#{studentName},'%')
            </if>
            <if test="phone!=null and phone!=''">
                and b.phone like concat('%',#{phone},'%')
            <if test="studentPhone!=null and studentPhone!=''">
                and b.phone like concat('%',#{studentPhone},'%')
            </if>
            <if test="studentId!=null">
                and a.student_id=#{studentId}
@@ -71,4 +77,19 @@
    </select>
    <select id="getCoursePeriod" resultType="java.lang.Long">
        select sum(b.resource_length) from ex_course_chapter_period a
        inner join ex_resource b on a.resource_id=b.id
        where a.course_id=#{courseId}
    </select>
    <select id="selectPhaseStudentByStudentId" resultType="com.gkhy.exam.system.domain.ExPhaseStudent"
            parameterType="java.lang.Long">
        select a.*,b.name as phase_name,c.id as company_id,c.name as company_name from ex_phase_student a
        left join ex_course_phase b on b.id=a.phase_id
        left join sys_company c on c.id=b.company_id
        where a.student_id=#{studentId}
    </select>
</mapper>