<?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.lyms.talkonlineweb.mapper.LymsTkrecordMapper">

    <resultMap id="BaseResultMap" type="com.lyms.talkonlineweb.domain.LymsTkrecord">
            <id property="id" column="id" jdbcType="INTEGER"/>
            <result property="pid" column="pid" jdbcType="INTEGER"/>
            <result property="pcid" column="pcid" jdbcType="INTEGER"/>
            <result property="did" column="did" jdbcType="INTEGER"/>
            <result property="cid" column="cid" jdbcType="INTEGER"/>
            <result property="fid" column="fid" jdbcType="TINYINT"/>
            <result property="stat" column="stat" jdbcType="INTEGER"/>
            <result property="hxgroupid" column="hxgroupid" jdbcType="VARCHAR"/>
            <result property="createdby" column="createdby" jdbcType="INTEGER"/>
            <result property="createdtime" column="createdtime" jdbcType="TIMESTAMP"/>
            <result property="updatedby" column="updatedby" jdbcType="INTEGER"/>
            <result property="updatedtime" column="updatedtime" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        id,pid,pcid,
        did,cid,fid,
        stat,hxgroupid,createdby,createdtime,
        updatedby,updatedtime
    </sql>

    <update id="batchUpdateStatEnd">
        update lyms_tkrecode
        set stat = 1
        where stat = 0
    </update>

    <select id="getLeastRecordByHxgroupId" parameterType="java.lang.String" resultMap="BaseResultMap">
        select
            <include refid="Base_Column_List"></include>
        from lyms_tkrecord where hxgroupid =#{hxgroupId}
        order by createdtime desc
        limit 1
    </select>
</mapper>
