<?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.srs.stureg.mapper.SrsStuCheckMapper">

    <resultMap type="SrsStuCheck" id="SrsStuCheckResult">
        <result property="id"    column="id"    />
        <result property="ksh"    column="ksh"    />
        <result property="isCheck"    column="is_check"    />
        <result property="checkTime"    column="check_time"    />
        <result property="status"    column="status"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectSrsStuCheckVo">
        select id, ksh, is_check, check_time, status, create_by, create_time, update_by, update_time from srs_stu_check
    </sql>

    <select id="selectSrsStuCheckList" parameterType="SrsStuCheck" resultMap="SrsStuCheckResult">
        <include refid="selectSrsStuCheckVo"/>
        <where>
            <if test="ksh != null  and ksh != ''"> and ksh = #{ksh}</if>
            <if test="isCheck != null  and isCheck != ''"> and is_check = #{isCheck}</if>
            <if test="checkTime != null "> and check_time = #{checkTime}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>
    <select id="countCheckTotal" resultType="Map">
        SELECT COUNT(CASE WHEN is_check = 1 THEN 1 END) AS checktotal
        FROM srs_stu_check
    </select>

    <select id="selectSrsStuCheckById" parameterType="Long" resultMap="SrsStuCheckResult">
        <include refid="selectSrsStuCheckVo"/>
        where id = #{id}
    </select>

    <select id="getowmByksh" parameterType="string" resultMap="SrsStuCheckResult">
        <include refid="selectSrsStuCheckVo"/>
        where ksh = #{ksh}
    </select>

    <insert id="insertSrsStuCheck" parameterType="SrsStuCheck" useGeneratedKeys="true" keyProperty="id">
        insert into srs_stu_check
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="ksh != null">ksh,</if>
            <if test="isCheck != null">is_check,</if>
            <if test="checkTime != null">check_time,</if>
            <if test="status != null">status,</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>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="ksh != null">#{ksh},</if>
            <if test="isCheck != null">#{isCheck},</if>
            <if test="checkTime != null">#{checkTime},</if>
            <if test="status != null">#{status},</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>
        </trim>
    </insert>

    <update id="updateSrsStuCheck" parameterType="SrsStuCheck">
        update srs_stu_check
        <trim prefix="SET" suffixOverrides=",">
            <if test="ksh != null">ksh = #{ksh},</if>
            <if test="isCheck != null">is_check = #{isCheck},</if>
            <if test="checkTime != null">check_time = #{checkTime},</if>
            <if test="status != null">status = #{status},</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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSrsStuCheckById" parameterType="Long">
        delete from srs_stu_check where id = #{id}
    </delete>

    <delete id="deleteSrsStuCheckByIds" parameterType="String">
        delete from srs_stu_check where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
