quota-record-mapper.xml
1.87 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
<?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.ConfigRecordDao">
<sql id="searchCondition">
<if test="otcCode != null and otcCode != ''">
and config.otc_code = #{otcCode}
</if>
<if test="userId !=null and userId!=''">
and record.user_id = #{userId}
</if>
<if test="beginDate != null and endDate == null">
and record.update_at >= #{beginDate}
</if>
<if test="endDate != null and beginDate == null">
and DATE_ADD(#{endDate}, INTERVAL +1 day)> =
record.update_at
</if>
<if test="endDate != null and beginDate != null">
and record.update_at between #{beginDate} and
DATE_ADD(#{endDate},INTERVAL +1 day)
</if>
</sql>
<sql id="record_field">
record.id, user_id, position, buy_total, quota, record.update_at, record.update_by
</sql>
<select id="searchRecord" parameterType="map" resultType="QuotaRecordInfo">
select <include refid="record_field"/>,otc_code ,otc_name, valid_end_date, percent
from quota_config config, quota_record record
where config.Id = record.quota_config_id
<include refid="searchCondition" />
order by record.id desc
<include refid="common.pageLimit" />
</select>
<select id="serchRecordTotal" parameterType="map" resultType="int">
select count(1) from
quota_config config, quota_record record
where config.Id = record.quota_config_id
<include refid="searchCondition" />
</select>
<insert id="insert" parameterType="QuotaRecordInfo">
insert into quota_record (quota_config_id, user_id, position, buy_total,
quota, create_at, create_by, update_at, update_by)
values (#{quotaConfigId}, #{userId}, #{position}, #{buyTotal},
#{quota}, CURRENT_TIMESTAMP, #{createBy}, CURRENT_TIMESTAMP, #{updateBy})
</insert>
</mapper>