<?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.ylx.massage.mapper.TSignMapper">

    <resultMap type="com.ylx.massage.domain.TSign" id="TSignMap">
        <result property="id" column="id" jdbcType="VARCHAR"/>
        <result property="dutyStatus" column="duty_status" jdbcType="INTEGER"/>
        <result property="jsId" column="js_id" jdbcType="VARCHAR"/>
        <result property="openId" column="open_id" jdbcType="VARCHAR"/>
        <result property="singTime" column="sing_time" jdbcType="TIMESTAMP"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="onlineTime" column="online_time" jdbcType="VARCHAR"/>
        <result property="deptName" column="dept_name" jdbcType="VARCHAR"/>
        <result property="deptId" column="dept_id" jdbcType="VARCHAR"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
        <result property="isDelete" column="is_delete" jdbcType="INTEGER"/>
    </resultMap>

    <!-- 批量插入 -->
    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into t_sign(duty_status,js_id,open_id,sing_time,name,create_time,update_time,is_delete)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.dutyStatus}#{entity.jsId}#{entity.openId}#{entity.singTime}#{entity.name}#{entity.createTime}#{entity.updateTime}#{entity.isDelete})
        </foreach>
    </insert>
    <!-- 批量插入或按主键更新 -->
    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into ry-vue.t_sign(duty_status,js_id,open_id,sing_time,name,create_time,update_time,is_delete)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.dutyStatus}#{entity.jsId}#{entity.openId}#{entity.singTime}#{entity.name}#{entity.createTime}#{entity.updateTime}#{entity.isDelete})
        </foreach>
        on duplicate key update
        duty_status = values(duty_status) js_id = values(js_id) open_id = values(open_id)
        sing_time = values(sing_time) name = values(name) create_time = values(create_time) update_time =
        values(update_time) is_delete = values(is_delete)
    </insert>

    <select id="getOnLineTime" resultType="java.lang.Integer">
        select sum(online_time) onlineTime from t_sign where is_delete = 0
        and js_id = #{jsId} and sing_time between #{startDate} and #{endDate}
    </select>

</mapper>

