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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?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.VolunteerMapper">
<resultMap id="userMap" type="cn.wisenergy.model.app.Volunteer">
<id column="id" property="id"/>
<result column="type" property="type"/>
<result column="scheme_id" property="schemeId"/>
<result column="major_name" property="majorName"/>
<result column="academy" property="academy"/>
<result column="course_demand" property="courseDemand"/>
<result column="nature" property="nature"/>
<result column="year_limit" property="yearLimit"/>
<result column="plan_num" property="planNum"/>
<result column="cast_archives_num" property="castArchivesNum"/>
<result column="launch_num" property="launchNum"/>
<result column="lowest_mark" property="lowestMark"/>
<result column="lowest_rank" property="lowestRank"/>
<result column="is_delete" property="isDelete"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<sql id="table">
volunteer
</sql>
<sql id="cols_all">
id,
<include refid="cols_exclude_id"/>
</sql>
<sql id="cols_exclude_id">
type,scheme_id,major_name,academy, course_demand,nature,year_limit,plan_num,
cast_archives_num,launch_num,lowest_mark,
lowest_rank,is_delete,create_time,update_time
</sql>
<sql id="vals">
#{type},#{scheme},#{majorName},#{academy},#{courseDemand},#{nature},#{yearLimit},#{planNum},#{castArchivesNum},
#{launchNum},
#{lowestMark}, #{lowestRank},#{isDelete},now(),now()
</sql>
<sql id="updateCondition">
<if test="type != null">type = #{type},</if>
<if test="scheme != null">scheme = #{scheme},</if>
<if test="majorName != null">major_name = #{majorName},</if>
<if test="academy != null">academy =#{academy},</if>
<if test="courseDemand != null">course_demand =#{courseDemand},</if>
<if test="nature != null">nature =#{nature},</if>
<if test="yearLimit != null">year_limit =#{yearLimit},</if>
<if test="planNum != null">plan_num =#{planNum},</if>
<if test="castArchivesNum != null">cast_archives_num = #{castArchivesNum},</if>
<if test="launchNum != null">launch_num = #{launchNum},</if>
<if test="lowestMark != null">lowest_mark = #{lowestMark},</if>
<if test="lowestRank != null">lowestMark = #{lowestRank},</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="type != null">and type = #{type}</if>
<if test="scheme != null">and scheme = #{scheme}</if>
<if test="majorName != null">and major_name = #{majorName}</if>
<if test="academy != null">and academy =#{academy}</if>
<if test="courseDemand != null">and course_demand =#{courseDemand}</if>
<if test="nature != null">and nature =#{nature}</if>
<if test="yearLimit != null">and year_limit =#{yearLimit}</if>
<if test="planNum != null">and plan_num =#{planNum}</if>
<if test="castArchivesNum != null">and cast_archives_num = #{castArchivesNum}</if>
<if test="launchNum != null">and launch_num = #{launchNum}</if>
<if test="lowestMark != null">and lowest_mark = #{lowestMark}</if>
<if test="lowestRank != null">and lowestMark = #{lowestRank}</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.Volunteer" keyProperty="id" useGeneratedKeys="true">
insert into
<include refid="table"/>
(<include refid="cols_exclude_id"/>)
value(
<include refid="vals"/>
)
</insert>
<update id="updateBySchemeId">
UPDATE
<include refid="table"/>
<set>
is_delete=1
</set>
<where>
scheme_id = #{schemeId}
and is_delete=0
</where>
</update>
<select id="getFillList" resultType="cn.wisenergy.model.app.Volunteer">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
is_delete =0
<if test="upGrade != null">
and #{upGrade} > lowest_mark
</if>
<if test="downGrade != null">
and lowest_mark >#{downGrade}
</if>
<if test="volunteerIds != null and volunteerIds.size > 0 ">
and id NOT IN
<foreach collection="volunteerIds" index="index" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</if>
order by lowest_mark desc
limit #{number}
</where>
</select>
<select id="getListByIds" resultType="cn.wisenergy.model.app.Volunteer">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
id IN
<foreach collection="list" index="index" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</where>
</select>
<select id="getVolunteerList" resultType="cn.wisenergy.model.app.Volunteer">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
is_delete =0
<if test="upGrade != null">
and #{upGrade} > lowest_mark
</if>
<if test="downGrade != null">
and lowest_mark >#{downGrade}
</if>
<if test="classNames != null">
and
<foreach collection="classNames" index="index" item="id" separator="or" open="(" close=")">
course_demand LIKE CONCAT('%',#{id},'%')
</foreach>
</if>
<if test="professionNames != null">
and
<foreach collection="professionNames" index="index" item="id" separator="or" open="(" close=")">
major_name LIKE CONCAT('%',#{id},'%')
</foreach>
</if>
order by lowest_mark desc
</where>
</select>
</mapper>