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
<?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.UserVolunteerMapper">
<resultMap id="userMap" type="cn.wisenergy.model.app.UserVolunteer">
<id column="id" property="id"/>
<result column="scheme_record_id" property="schemeRecordId"/>
<result column="user_id" property="userId"/>
<result column="volunteer_id" property="volunteerId"/>
</resultMap>
<sql id="table">
user_volunteer
</sql>
<sql id="cols_all">
id,
<include refid="cols_exclude_id"/>
</sql>
<sql id="cols_exclude_id">
scheme_record_id,user_id, volunteer_id
</sql>
<sql id="createsVal">
#{i.scheme_record_id},#{i.user_id},#{i.volunteer_id},now(), now()
</sql>
<sql id="vals">
#{schemeRecordId},#{userId},#{volunteerId}
</sql>
<sql id="updateCondition">
<if test="schemeRecordId != null">scheme_record_id = #{schemeRecordId},</if>
<if test="userId != null">user_id =#{userId},</if>
<if test="volunteerId != null">volunteer_id =#{volunteerId},</if>
</sql>
<sql id="criteria">
<if test="id != null">id = #{id}</if>
<if test="schemeRecordId != null">and scheme_record_id = #{schemeRecordId}</if>
<if test="userId != null">and user_id =#{userId}</if>
<if test="volunteerId != null">and volunteer_id =#{volunteerId}</if>
</sql>
<insert id="add" parameterType="cn.wisenergy.model.app.UserVolunteer" keyProperty="id" useGeneratedKeys="true">
insert into
<include refid="table"/>
(<include refid="cols_exclude_id"/>)
value(
<include refid="vals"/>
)
</insert>
<!-- 批量创建接口 -->
<insert id="creates" parameterType="list">
INSERT INTO
<include refid="table"/>
(<include refid="cols_exclude_id"/>)
VALUES
<foreach collection="list" item="i" index="index" separator=",">
(<include refid="createsVal"/>)
</foreach>
</insert>
<update id="edit" parameterType="cn.wisenergy.model.app.UserVolunteer">
UPDATE
<include refid="table"/>
<set>
<include refid="updateCondition"/>
</set>
<where>
id = #{id}
</where>
</update>
<delete id="delById" parameterType="java.lang.Integer">
delete from
<include refid="table"/>
where id = #{id}
</delete>
<select id="listById" resultType="cn.wisenergy.model.app.UserVolunteer">
select * from
<include refid="table"/>
where scheme_record_id = #{schemeRecordId}
</select>
</mapper>