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
<?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.SchemeMapper">
<resultMap id="userMap" type="cn.wisenergy.model.app.SchemeInfo">
<id column="id" property="id"/>
<result column="scheme_name" property="schemeName"/>
<result column="upload_time" property="uploadTime"/>
<result column="file_url" property="fileUrl"/>
<result column="type" property="type"/>
<result column="is_delete" property="isDelete"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<sql id="table">
scheme
</sql>
<sql id="cols_all">
id,
<include refid="cols_exclude_id"/>
</sql>
<sql id="cols_exclude_id">
scheme_name,upload_time,file_url, type,is_delete,create_time,update_time
</sql>
<sql id="vals">
#{schemeName},#{uploadTime},#{fileUrl},#{type},#{isDelete},now(),now()
</sql>
<sql id="updateCondition">
<if test="schemeName != null">scheme_name = #{schemeName},</if>
<if test="uploadTime != null">upload_time =#{uploadTime},</if>
<if test="fileUrl != null">file_url =#{fileUrl},</if>
<if test="type != null">type =#{type},</if>
<if test="isDelete != null">is_delete =#{isDelete},</if>
update_time =now()
</sql>
<sql id="criteria">
<if test="id != null">id = #{id}</if>
<if test="schemeName != null">and scheme_name = #{schemeName}</if>
<if test="uploadTime != null">and upload_time =#{uploadTime}</if>
<if test="fileUrl != null">and file_url =#{fileUrl}</if>
<if test="type != null">and type =#{type}</if>
<if test="isDelete != null">and is_delete =#{isDelete}</if>
<if test="createTime != null">and create_time >= #{createTime}</if>
<if test="updateTime != null">and #{updateTime} >= update_time</if>
</sql>
<insert id="add" parameterType="cn.wisenergy.model.app.SchemeInfo" keyProperty="id"
keyColumn="id" useGeneratedKeys="true">
insert into
<include refid="table"/>
(<include refid="cols_exclude_id"/>)
value(
<include refid="vals"/>
)
</insert>
<select id="getList" parameterType="map" resultType="cn.wisenergy.model.app.SchemeInfo">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
is_delete=0
order by create_time desc
limit #{startNum},#{endNum}
</where>
</select>
<update id="edit" parameterType="cn.wisenergy.model.app.SchemeInfo">
UPDATE
<include refid="table"/>
<set>
<include refid="updateCondition"/>
</set>
<where>
id = #{id}
</where>
</update>
<select id="count" resultType="java.lang.Integer">
select count(1)
from
<include refid="table"/>
<where>
is_delete=0
</where>
</select>
<select id="getById" resultType="cn.wisenergy.model.app.SchemeInfo">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
id=#{id}
</where>
</select>
<select id="getByType" resultType="int">
select count(1)
from
<include refid="table"/>
<where>
type=#{type}
and is_delete=0
</where>
</select>
</mapper>