1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?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.wisenergy.mapper.WorkCollectMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.wisenergy.model.app.WorkCollect">
<id column="id" property="id" />
<result column="user_id" property="userId" />
<result column="work_day" property="workDay" />
<result column="total_time" property="totalTime" />
<result column="status" property="status" />
<result column="create_time" property="createTime" />
<result column="modify_time" property="modifyTime" />
<result column="reject_time" property="rejectTime" />
</resultMap>
<sql id="vals">
#{userId},#{workDay},#{totalTime},#{status},#{rejectTime},now(),now()
</sql>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, user_id, work_day, total_time, status,reject_time, create_time, modify_time,
</sql>
<sql id="cols_exclude_id">
user_id, work_day, total_time, status,reject_time, create_time, modify_time
</sql>
<sql id="table">
work_collect
</sql>
<sql id="CalendarDto_List" >
user_id, work_day,status
</sql>
<insert id="insertWorkCollect">
INSERT INTO
<include refid="table"/>
(<include refid="cols_exclude_id"/>)
VALUES (
<include refid="vals"/>
)
</insert>
<update id="updateStatusOrTotalTime">
UPDATE
<include refid="table"/>
<set>
<if test="null != status">
status=#{status},
</if>
<if test="null !=totalTime">
total_time = #{totalTime},
</if>
<if test="3 ==status ">
reject_time = now(),
</if>
modify_time = now()
</set>
WHERE id = #{id}
</update>
<select id="getWorkMonth" resultType="cn.wisenergy.model.dto.CalendarDto">
SELECT
<include refid="Base_Column_List"/>
FROM
<include refid="table"/>
<where>
<if test="null != userId">
AND user_id = #{userId}
</if>
<if test="null != workMonth">
AND DATE_FORMAT(work_day, '%Y%m') = DATE_FORMAT(#{workMonth} ,'%Y%m')
</if>
</where>
</select>
</mapper>