entrust-data-mapper.xml
2.64 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
70
71
72
73
74
75
76
77
78
79
<?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.user.EntrustDataDao">
<sql id="entrust_data_field">
id, entrust_id, entrust_name, type, unit, storage_num, market_time, price, entrust_image, create_time, content, storage_total
</sql>
<sql id="searchCondition">
where 1 = 1
<if test="entrustId != null and entrustId != ''">
and entrust_id = #{entrustId}
</if>
<if test="entrustName !=null and entrustName!=''">
and entrust_name = #{entrustName}
</if>
<if test="type !=null and type!=''">
and type = #{type}
</if>
<if test="beginDate != null and endDate == null">
and market_time > = #{beginDate}
</if>
<if test="endDate != null and beginDate == null">
and DATE_ADD(#{endDate}, INTERVAL +1 day)> =
market_time
</if>
<if test="endDate != null and beginDate != null">
and market_time between #{beginDate} and
DATE_ADD(#{endDate}, INTERVAL +1 day)
</if>
</sql>
<insert id="addEntrustInfo" parameterType="EntrustDataInfo">
insert into
entrust_data(entrust_id, entrust_name, type, unit, storage_num, market_time, price, entrust_image, create_time, content, storage_total)
values(#{entrustId}, #{entrustName}, #{type}, #{unit}, #{storageNum}, #{marketTime}, #{price}, #{entrustImage}, now(), #{content}, #{storageTotal});
</insert>
<select id="searchList" parameterType="java.util.Map"
resultType="EntrustDataInfo">
select
<include refid="entrust_data_field" />
from entrust_data
<include refid="searchCondition" />
order by id desc
<include refid="common.pageLimit" />
</select>
<select id="searchListCount" parameterType="java.util.Map"
resultType="int">
select count(1) from entrust_data
<include refid="searchCondition" />
</select>
<select id="searchEntrust" parameterType="java.util.Map"
resultType="java.util.Map">
select entrust_id, entrust_name from entrust_data
</select>
<update id="addContent" parameterType="EntrustDataInfo">
update entrust_data set content = #{content} where id = #{id}
</update>
<update id="updateEntrustInfo" parameterType="EntrustDataInfo">
update entrust_data set
entrust_id = #{entrustId},entrust_name = #{entrustName},type = #{type},unit = #{unit},
storage_num = #{storageNum},market_time = #{marketTime},price = #{price},storage_total=#{storageTotal}
<if test="entrustImage != null and entrustImage != ''">
,entrust_image = #{entrustImage}
</if>
where id = #{id}
</update>
<delete id="deleteEntrust" parameterType="int">
delete from entrust_data where id = #{id}
</delete>
</mapper>