liuxiaolong
2019-05-09 0d1d88cdb668e75ea8609417ac18ae19947e9525
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?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.jeeplus.modules.sportsign.dao.SportSignDao">
    
    <sql id="sportSignColumns">
        a.id AS "id",
        a.create_by AS "createBy.id",
        a.create_date AS "createDate",
        a.update_by AS "updateBy.id",
        a.update_date AS "updateDate",
        a.remarks AS "remarks",
        a.del_flag AS "delFlag",
        a.sign_card_id AS "signCardID",
        a.sign_entertime AS "signEnterTime",
        a.sign_outtime AS "signOutTime",
        a.transferid AS "TransferId",
        a.schoolid AS "schoolId",
        a.accesskey AS "accessKey",
        a.locationid AS "locationId",
        a.sign_other AS "signOther",
        a.timecount AS "timeCount"
    </sql>
    
    <sql id="sportSignJoins">
    </sql>
    
    <select id="get" resultType="SportSign">
        SELECT 
            <include refid="sportSignColumns"/>
        FROM sport_sign a
        <include refid="sportSignJoins"/>
        WHERE a.id = #{id}
    </select>
    
    <select id="findList" resultType="SportSign">
    SELECT
        a.id AS "id",
        a.create_by AS "createBy.id",
        a.create_date AS "createDate",
        a.update_by AS "updateBy.id",
        a.update_date AS "updateDate",
        a.remarks AS "remarks",
        a.del_flag AS "delFlag",
        a.sign_card_id AS "signCardID",
        a.sign_entertime AS "signEnterTime",
        a.sign_outtime AS "signOutTime",
        a.transferid AS "TransferId",
        a.schoolid AS "schoolId",
        a.accesskey AS "accessKey",
        a.locationid AS "locationId",
        a.sign_other AS "signOther",
        a.timecount AS "timeCount", 
        
        u.user_id AS "userId",
        u.card_id AS "cardId",
        u.user_name AS "userName",
        u.dep_id AS "depId",
        u.user_sex AS "usersex",
        u.user_type AS "userType",
        u.user_status AS "userStatus",
        u.user_duty AS "userDuty",
        u.user_other AS "userOther"
        
        FROM sport_sign a
        left JOIN user_register u ON u.card_id = a.sign_card_id
        
        WHERE 1=1 
    <if test="signCardID != null and signCardID != ''">
            AND sign_card_id like CONCAT('%', #{signCardID}, '%')
 
        </if>
            <if test="signEnterTime != null and signEnterTime != ''">
              <![CDATA[AND sign_entertime >= CONCAT(DATE_FORMAT(#{signEnterTime}, '%Y-%m-%d'),' 00:00:00')]]>
 
        </if>
            <if test="signOutTime!= null and signOutTime!= ''">
              <![CDATA[AND sign_outtime <= CONCAT(DATE_FORMAT(#{signOutTime}, '%Y-%m-%d'),' 23:59:59')]]>
 
        </if>
        <if test="userName != null and userName != ''">
            AND user_name like CONCAT('%', #{userName}, '%')
 
        </if>
        
            
        <if test="UserDepIDList!= null ">
           
              <foreach collection="UserDepIDList" index="index" item="tag" open="  and u.dep_id in ("
                separator="," close=")">
                
              #{tag}  
              
              </foreach>
             
 
        </if>
        
        ORDER BY a.timeCount DESC
    </select>
    
    <select id="findAllList" resultType="SportSign">
        SELECT 
            <include refid="sportSignColumns"/>
        FROM sport_sign a
        <include refid="sportSignJoins"/>
        <where>
            a.del_flag = #{DEL_FLAG_NORMAL}
        </where>        
        <choose>
            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
                ORDER BY ${page.orderBy}
            </when>
            <otherwise>
                ORDER BY a.update_date DESC
            </otherwise>
        </choose>
    </select>
    
    <insert id="insert">
        INSERT INTO sport_sign(
            id,
            create_by,
            create_date,
            update_by,
            update_date,
            remarks,
            del_flag,
            sign_card_id,
            sign_entertime,
            sign_outtime,
            transferid,
            schoolid,
            accesskey,
            locationid,
            sign_other,
            timecount
        ) VALUES (
            #{id},
            #{createBy.id},
            #{createDate},
            #{updateBy.id},
            #{updateDate},
            #{remarks},
            #{delFlag},
            #{signCardID},
            #{signEnterTime},
            #{signOutTime},
            #{TransferId},
            #{schoolId},
            #{accessKey},
            #{locationId},
            #{signOther},
            #{timeCount}
        )
    </insert>
    
    <update id="update">
        UPDATE sport_sign SET     
            update_by = #{updateBy.id},
            update_date = #{updateDate},
            remarks = #{remarks},
            sign_card_id = #{signCardID},
            sign_entertime = #{signEnterTime},
            sign_outtime = #{signOutTime},
            transferid = #{TransferId},
            schoolid = #{schoolId},
            accesskey = #{accessKey},
            locationid = #{locationId},
            sign_other = #{signOther},
            timecount = #{timeCount}
        WHERE id = #{id}
    </update>
    
    
    <!--物理删除-->
    <update id="delete">
        DELETE FROM sport_sign
        WHERE id = #{id}
    </update>
    
    <!--逻辑删除-->
    <update id="deleteByLogic">
        UPDATE sport_sign SET 
            del_flag = #{DEL_FLAG_DELETE}
        WHERE id = #{id}
    </update>
    
    
    <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
    <select id="findUniqueByProperty" resultType="SportSign" statementType="STATEMENT">
        select * FROM sport_sign  where ${propertyName} = '${value}'
    </select>
</mapper>