mybatis 批量新增 跟修改

<!--修改-->    

<update id="delStudentAttendanceBatch"  parameterType="java.util.List">  
        <foreach collection="studentAttendanceList" item="item" index="index" open="" close="" separator=";">
            UPDATE emp_student_attendance
            <set>
                stat = 0 
            </set>
            WHERE stat = 1 
            AND student_id = #{item.studentId}
            AND class_id = #{item.classId}
        </foreach>      
    </update>


    <!--新增--> 
    <insert id="addStudentAttendanceBatch" parameterType="java.util.List">
        INSERT INTO emp_student_attendance
        (id, student_id,
        class_id,class_course_arrange_id,employee_id,school_id,attendance_status,attendence_time,
        consume_hour_counts,remark,create_time,last_update_time,stat)
        values
        <foreach collection="studentAttendanceList" item="studentAttendance"
            index="index" separator=",">
            (
            #{studentAttendance.id,jdbcType=VARCHAR},
            #{studentAttendance.studentId,jdbcType=VARCHAR},
            #{studentAttendance.classId,jdbcType=VARCHAR},
            #{studentAttendance.classCourseArrangeId,jdbcType=VARCHAR},
            #{studentAttendance.employeeId,jdbcType=VARCHAR},
            #{studentAttendance.schoolId,jdbcType=VARCHAR},
            #{studentAttendance.attendanceStatus,jdbcType=INTEGER},
            #{studentAttendance.attendenceTime,jdbcType=TIMESTAMP},
            #{studentAttendance.consumeHourCounts,jdbcType=DOUBLE},
            #{studentAttendance.remark,jdbcType=VARCHAR},
            #{studentAttendance.createTime,jdbcType=TIMESTAMP},
            #{studentAttendance.lastUpdateTime,jdbcType=TIMESTAMP},
            #{studentAttendance.stat,jdbcType=INTEGER}
            )
        </foreach>
    </insert>

 <!--查询--> 

    <select id="findListCount" resultType="java.lang.Integer">
        SELECT
        count(1)

        FROM
        app_class a
        LEFT JOIN app_lesson_school b ON a.school_id = b.school_id
        AND a.lession_id = b.lesson_id
        LEFT JOIN app_school c ON a.school_id=c.id
        LEFT JOIN common_employee d ON a.teacher_emoloyee_id =d.id
        LEFT JOIN (SELECT * FROM app_dictionary e WHERE e.parent_id IN (SELECT
        f.id FROM app_dictionary f WHERE f.param_name='attend_class_times' ))
        g ON g.param_value=a.attend_class_times
        WHERE a.stat=1 AND b.stat=1 AND c.stat=1 AND d.stat=1
        <include refid="where_conditions"></include>        
    </select>    
    
    <sql id="where_conditions">
        <if test="cla.schoolId  == null and cla.schoolIdList !=null"  >
        AND a.school_id in
    
          <foreach collection="cla.schoolIdList" item="item" open="(" close=")" separator="," >
                    #{item}
            </foreach>
        </if>
            <if test="cla.schoolId  != null and cla.schoolIdList ==null"  >
        AND a.school_id =#{cla.schoolId}
        </if>
        <if test="cla.gradeId != '' and cla.gradeId  != null">
            AND a.grade_id = #{cla.gradeId}
        </if>
        <if test="cla.season != '' and cla.season  != null">
            AND a.season = #{cla.season}
        </if>
    </sql>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值