AttendanceRecordMapper.xml 2.36 KB
<?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="AttendanceRecordV1ServiceDaoImpl">

    <insert id="saveAttendanceRecord" parameterType="com.java110.po.property.AttendanceRecordPo">
        INSERT INTO attendance_record(id, user_id, user_name, work_type, punch_type, punch_time, punch_address, longitude, latitude, store_id, create_time)
        VALUES(#{id}, #{userId}, #{userName}, #{workType}, #{punchType}, #{punchTime}, #{punchAddress}, #{longitude}, #{latitude}, #{storeId}, NOW())
    </insert>

    <select id="queryAttendanceRecords" parameterType="map" resultType="map">
        SELECT * FROM attendance_record WHERE 1=1
        <if test="userId != null and userId != ''">AND user_id = #{userId}</if>
        <if test="workType != null and workType != ''">AND work_type = #{workType}</if>
        <if test="punchType != null and punchType != ''">AND punch_type = #{punchType}</if>
        <if test="startTime != null and startTime != ''">AND punch_time &gt;= #{startTime}</if>
        <if test="endTime != null and endTime != ''">AND punch_time &lt;= #{endTime}</if>
        <if test="storeId != null and storeId != ''">AND store_id = #{storeId}</if>
        ORDER BY punch_time DESC
        <if test="page != null and page != '' and row != null and row != ''">
            LIMIT #{page}, #{row}
        </if>
    </select>

    <select id="queryAttendanceRecordsCount" parameterType="map" resultType="map">
        SELECT COUNT(1) count FROM attendance_record WHERE 1=1
        <if test="userId != null and userId != ''">AND user_id = #{userId}</if>
        <if test="workType != null and workType != ''">AND work_type = #{workType}</if>
        <if test="punchType != null and punchType != ''">AND punch_type = #{punchType}</if>
        <if test="startTime != null and startTime != ''">AND punch_time &gt;= #{startTime}</if>
        <if test="endTime != null and endTime != ''">AND punch_time &lt;= #{endTime}</if>
        <if test="storeId != null and storeId != ''">AND store_id = #{storeId}</if>
    </select>

    <select id="queryTodayAttendanceByType" parameterType="map" resultType="map">
        SELECT * FROM attendance_record
        WHERE user_id = #{userId} AND punch_type = #{punchType}
        AND DATE(punch_time) = CURDATE()
        LIMIT 1
    </select>

</mapper>