<?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="cn.com.ty.lift.business.capital.dao.mapper.SignInMapper" >
    <resultMap id="BaseResultMap" type="cn.com.ty.lift.business.capital.dao.entity.SignIn" >
        <id column="id" property="id" jdbcType="BIGINT" />
        <result column="mt_company_id" property="mtCompanyId" jdbcType="BIGINT" />
        <result column="project_id" property="projectId" jdbcType="BIGINT" />
        <result column="user_id" property="userId" jdbcType="BIGINT" />
        <result column="coordinate" property="coordinate" jdbcType="VARCHAR" />
        <result column="address" property="address" jdbcType="VARCHAR" />
        <result column="approach_time" property="approachTime" jdbcType="DATE" />
        <result column="leaving_time" property="leavingTime" jdbcType="DATE" />
        <result column="creator_id" property="creatorId" jdbcType="BIGINT" />
        <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
        <result column="update_id" property="updateId" jdbcType="TIMESTAMP" />
        <result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />
    </resultMap>

    <sql id="Base_Column_List" >
        id, mt_company_id, project_id, user_id, coordinate, address, approach_time, leaving_time,
		creator_id, create_date, update_id, update_date, region_id
    </sql>

    <select id="getSignDate" resultType="java.time.LocalDate"
            parameterType="cn.com.ty.lift.business.capital.dao.entity.model.request.CapitalRepairRequest">
        SELECT sign_date AS signDate
        FROM sign_in
        WHERE mt_company_id =  #{request.mtCompanyId,jdbcType=BIGINT}
         AND project_id = #{request.id,jdbcType=BIGINT}
        <if test="request.signDate!=null and request.signDate!=''">
            AND sign_date = #{request.signDate,jdbcType=DATE}
        </if>
        GROUP BY sign_date
        ORDER BY sign_date
    </select>

    <select id="findByCondition" resultType="cn.com.ty.lift.business.capital.dao.entity.model.response.SignRecord"
            parameterType="java.util.Map" >
        SELECT
               sign_date     AS signDate,
               approach_time AS approachTime,
               leaving_time  AS leavingTime,
               ui.name       AS userName
        FROM sign_in si
        LEFT JOIN user_info ui ON si.user_id = ui.user_id
        WHERE si.mt_company_id = #{paramMap.mtCompanyId,jdbcType=BIGINT}
        AND project_id = #{paramMap.projectId,jdbcType=BIGINT}
        AND si.sign_date BETWEEN #{paramMap.minDate} AND #{paramMap.maxDate}
        <if test="paramMap.userId!=null and paramMap.userId!=''">
            AND si.user_id = #{paramMap.userId,jdbcType=BIGINT}
        </if>
    </select>
</mapper>
