quota-user-record-mapper.xml
1.94 KB
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
<?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">
<!-- @author kongmingke -->
<mapper namespace="com.cjs.cms.dao.quota.QuotaUserRecordDao">
<sql id="quota_user_record_field">
id, user_id, otc_code, otc_name, quota, post_quota, remark, source, create_at, create_by
</sql>
<insert id="insert" parameterType="QuotaUserRecordInfo">
insert into quota_user_record
(user_id, otc_code, otc_name, quota, post_quota, remark, source, create_at, create_by)
values (#{userId}, #{otcCode}, #{otcName}, #{quota}, #{postQuota}, #{remark}, #{source}, now(), #{createBy})
</insert>
<sql id="searchCondition">
where 1 = 1
<if test="otcCode != null and otcCode != ''">
and otc_code = #{otcCode}
</if>
<if test="userId !=null and userId !=''">
and user_id = #{userId}
</if>
<if test="source != null and source != ''">
and source = #{source}
</if>
<if test="quotaSource == 6 or quotaSource ==7">
and source = #{quotaSource}
</if>
<if test="quotaSource == 0">
and (source = 6 or source = 7)
</if>
<if test="beginDate != null and endDate == null">
and create_at >= #{beginDate}
</if>
<if test="endDate != null and beginDate == null">
and DATE_ADD(#{endDate}, INTERVAL +1 day) >=
create_at
</if>
<if test="endDate != null and beginDate != null">
and create_at between #{beginDate} and
DATE_ADD(#{endDate},INTERVAL +1 day)
</if>
</sql>
<select id="search" parameterType="map" resultType="QuotaUserRecordInfo">
select
<include refid="quota_user_record_field"/>
from quota_user_record
<include refid="searchCondition" />
order by id desc
<include refid="common.pageLimit" />
</select>
<select id="searchTotal" parameterType="map" resultType="int">
select count(1)
<include refid="quota_user_record_field"/>
from quota_user_record
<include refid="searchCondition" />
</select>
</mapper>