Blame view

resources/mybatis1/sunvote/QuestionMapper.xml 5.62 KB
bed6e1fc   孙向锦   添加其他功能
1
2
3
  <?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="QuestionMapper">
0aad4b6b   孙向锦   修复试题分页功能
4
  
bed6e1fc   孙向锦   添加其他功能
5
6
7
8
  	<!--表名 -->
  	<sql id="tableName">
  		SV_QUESTION
  	</sql>
0aad4b6b   孙向锦   修复试题分页功能
9
  
bed6e1fc   孙向锦   添加其他功能
10
11
  	<!-- 字段 -->
  	<sql id="Field">
0aad4b6b   孙向锦   修复试题分页功能
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  		P_ID,
  		SUBJECT_ID,
  		CHAPTER_ID,
  		PROBLEM_TYPE_ID,
  		TEACHER_ID,
  		SCHOOL_ID,
  		KNOWLEDGE_ID,
  		CONTENT,
  		OPTION_NUM,
  		OPTION_CONTENT,
  		ANSWER,
  		DIFFICULTY,
  		ANALYSIS,
  		QUESTION_FROM,
  		SUG_SCORE,
  		SUG_PART_SCORE,
  		USER_ID,
  		CREATE_DATE,
  		REMARK,
  		METHOD,
bed6e1fc   孙向锦   添加其他功能
32
33
  		QUESTION_ID
  	</sql>
0aad4b6b   孙向锦   修复试题分页功能
34
  
bed6e1fc   孙向锦   添加其他功能
35
36
  	<!-- 字段值 -->
  	<sql id="FieldValue">
0aad4b6b   孙向锦   修复试题分页功能
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
  		#{P_ID},
  		#{SUBJECT_ID},
  		#{CHAPTER_ID},
  		#{PROBLEM_TYPE_ID},
  		#{TEACHER_ID},
  		#{SCHOOL_ID},
  		#{KNOWLEDGE_ID},
  		#{CONTENT},
  		#{OPTION_NUM},
  		#{OPTION_CONTENT},
  		#{ANSWER},
  		#{DIFFICULTY},
  		#{ANALYSIS},
  		#{QUESTION_FROM},
  		#{SUG_SCORE},
  		#{SUG_PART_SCORE},
  		#{USER_ID},
  		#{CREATE_DATE},
  		#{REMARK},
  		#{METHOD},
bed6e1fc   孙向锦   添加其他功能
57
58
  		#{QUESTION_ID}
  	</sql>
0aad4b6b   孙向锦   修复试题分页功能
59
60
  
  	<!-- 新增 -->
bed6e1fc   孙向锦   添加其他功能
61
  	<insert id="save" parameterType="pd">
0aad4b6b   孙向锦   修复试题分页功能
62
63
  		insert into
  		<include refid="tableName"></include>
bed6e1fc   孙向锦   添加其他功能
64
  		(
0aad4b6b   孙向锦   修复试题分页功能
65
  		<include refid="Field"></include>
bed6e1fc   孙向锦   添加其他功能
66
  		) values (
0aad4b6b   孙向锦   修复试题分页功能
67
  		<include refid="FieldValue"></include>
bed6e1fc   孙向锦   添加其他功能
68
69
  		)
  	</insert>
0aad4b6b   孙向锦   修复试题分页功能
70
71
  
  	<!-- 删除 -->
bed6e1fc   孙向锦   添加其他功能
72
73
74
  	<delete id="delete" parameterType="pd">
  		delete from
  		<include refid="tableName"></include>
0aad4b6b   孙向锦   修复试题分页功能
75
76
  		where
  		QUESTION_ID = #{QUESTION_ID}
bed6e1fc   孙向锦   添加其他功能
77
  	</delete>
0aad4b6b   孙向锦   修复试题分页功能
78
  
bed6e1fc   孙向锦   添加其他功能
79
80
81
82
  	<!-- 修改 -->
  	<update id="edit" parameterType="pd">
  		update
  		<include refid="tableName"></include>
0aad4b6b   孙向锦   修复试题分页功能
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
  		set
  		P_ID = #{P_ID},
  		SUBJECT_ID = #{SUBJECT_ID},
  		CHAPTER_ID = #{CHAPTER_ID},
  		PROBLEM_TYPE_ID = #{PROBLEM_TYPE_ID},
  		TEACHER_ID = #{TEACHER_ID},
  		SCHOOL_ID = #{SCHOOL_ID},
  		KNOWLEDGE_ID = #{KNOWLEDGE_ID},
  		CONTENT = #{CONTENT},
  		OPTION_NUM = #{OPTION_NUM},
  		OPTION_CONTENT = #{OPTION_CONTENT},
  		ANSWER = #{ANSWER},
  		DIFFICULTY = #{DIFFICULTY},
  		ANALYSIS = #{ANALYSIS},
  		QUESTION_FROM = #{QUESTION_FROM},
  		SUG_SCORE = #{SUG_SCORE},
  		SUG_PART_SCORE = #{SUG_PART_SCORE},
  		USER_ID = #{USER_ID},
  		CREATE_DATE = #{CREATE_DATE},
  		REMARK = #{REMARK},
  		METHOD = #{METHOD},
bed6e1fc   孙向锦   添加其他功能
104
  		QUESTION_ID = QUESTION_ID
0aad4b6b   孙向锦   修复试题分页功能
105
  		where
bed6e1fc   孙向锦   添加其他功能
106
107
  		QUESTION_ID = #{QUESTION_ID}
  	</update>
0aad4b6b   孙向锦   修复试题分页功能
108
  
bed6e1fc   孙向锦   添加其他功能
109
110
  	<!-- 通过ID获取数据 -->
  	<select id="findById" parameterType="pd" resultType="pd">
0aad4b6b   孙向锦   修复试题分页功能
111
  		select
bed6e1fc   孙向锦   添加其他功能
112
  		<include refid="Field"></include>
0aad4b6b   孙向锦   修复试题分页功能
113
  		from
bed6e1fc   孙向锦   添加其他功能
114
  		<include refid="tableName"></include>
0aad4b6b   孙向锦   修复试题分页功能
115
116
  		where
  		QUESTION_ID = #{QUESTION_ID}
bed6e1fc   孙向锦   添加其他功能
117
  	</select>
0aad4b6b   孙向锦   修复试题分页功能
118
  
bed6e1fc   孙向锦   添加其他功能
119
120
121
122
  	<!-- 列表 -->
  	<select id="datalistPage" parameterType="page" resultType="pd">
  		select
  		<include refid="Field"></include>
0aad4b6b   孙向锦   修复试题分页功能
123
  		from
bed6e1fc   孙向锦   添加其他功能
124
125
126
127
  		<include refid="tableName"></include>
  		where 1=1
  		<if test="pd.keywords!= null and pd.keywords != ''"><!-- 关键词检索 -->
  			and
0aad4b6b   孙向锦   修复试题分页功能
128
129
130
131
  			(
  			<!-- 根据需求自己加检索条件 字段1 LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%') or 字段2 
  				LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%') -->
  			)
bed6e1fc   孙向锦   添加其他功能
132
133
  		</if>
  	</select>
0aad4b6b   孙向锦   修复试题分页功能
134
  
bed6e1fc   孙向锦   添加其他功能
135
136
137
138
  	<!-- 列表(全部) -->
  	<select id="listAll" parameterType="pd" resultType="pd">
  		select
  		<include refid="Field"></include>
0aad4b6b   孙向锦   修复试题分页功能
139
  		from
bed6e1fc   孙向锦   添加其他功能
140
141
  		<include refid="tableName"></include>
  	</select>
0aad4b6b   孙向锦   修复试题分页功能
142
  
ce70231e   孙向锦   增加接口
143
144
145
146
  	<!-- 列表(全部) -->
  	<select id="listAllquestion" parameterType="pd" resultType="pd">
  		select
  		<include refid="Field"></include>
0aad4b6b   孙向锦   修复试题分页功能
147
  		from
ce70231e   孙向锦   增加接口
148
  		<include refid="tableName"></include>
0aad4b6b   孙向锦   修复试题分页功能
149
150
  
  		where 1 =1
ce70231e   孙向锦   增加接口
151
  		<if test="CHAPTER_IDS != null and CHAPTER_IDS.size() > 0">
0aad4b6b   孙向锦   修复试题分页功能
152
153
154
155
156
  			and CHAPTER_ID in
  
  			<foreach item="item" index="index" collection="CHAPTER_IDS"
  				open="(" separator="," close=")">
  				#{item}
ce70231e   孙向锦   增加接口
157
  			</foreach>
0aad4b6b   孙向锦   修复试题分页功能
158
  
ce70231e   孙向锦   增加接口
159
160
  		</if>
  		<if test="KNOWLEDGE_IDS != null and KNOWLEDGE_IDS.size() > 0">
0aad4b6b   孙向锦   修复试题分页功能
161
162
163
164
  			and
  			<foreach item="item" index="index" collection="KNOWLEDGE_IDS"
  				open="(" separator=" or " close=")">
  				FIND_IN_SET(#{item},KNOWLEDGE_ID)
ce70231e   孙向锦   增加接口
165
  			</foreach>
0aad4b6b   孙向锦   修复试题分页功能
166
  
ce70231e   孙向锦   增加接口
167
168
169
170
171
172
173
174
175
176
177
178
179
  		</if>
  		<if test="QUESTION_FROM != null and QUESTION_FROM != ''">
  			and QUESTION_FROM = #{QUESTION_FROM}
  		</if>
  		<if test="USER_ID != null and USER_ID != ''">
  			and USER_ID = #{USER_ID}
  		</if>
  		<if test="PROBLEM_TYPE != null and PROBLEM_TYPE != ''">
  			and PROBLEM_TYPE = #{PROBLEM_TYPE}
  		</if>
  		<if test="SUBJECT_ID != null and SUBJECT_ID != ''">
  			and SUBJECT_ID = #{SUBJECT_ID}
  		</if>
0aad4b6b   孙向锦   修复试题分页功能
180
181
182
183
184
  
  		ORDER BY QUESTION_ID
  
  		<if test="PAGENUM != null and PAGENUM != '' and COUNT != null and COUNT != ''">
  			LIMIT ${PAGENUM}, ${COUNT}
ce70231e   孙向锦   增加接口
185
  		</if>
0aad4b6b   孙向锦   修复试题分页功能
186
187
  
  
ce70231e   孙向锦   增加接口
188
  	</select>
0aad4b6b   孙向锦   修复试题分页功能
189
  
ce70231e   孙向锦   增加接口
190
191
192
193
  	<!-- 列表(全部) -->
  	<select id="listAllRandquestion" parameterType="pd" resultType="pd">
  		select
  		<include refid="Field"></include>
0aad4b6b   孙向锦   修复试题分页功能
194
  		from
ce70231e   孙向锦   增加接口
195
  		<include refid="tableName"></include>
0aad4b6b   孙向锦   修复试题分页功能
196
197
  
  		where 1 =1
ce70231e   孙向锦   增加接口
198
  		<if test="CHAPTER_IDS != null and CHAPTER_IDS.size() > 0">
0aad4b6b   孙向锦   修复试题分页功能
199
200
201
202
203
  			and CHAPTER_ID in
  
  			<foreach item="item" index="index" collection="CHAPTER_IDS"
  				open="(" separator="," close=")">
  				#{item}
ce70231e   孙向锦   增加接口
204
  			</foreach>
0aad4b6b   孙向锦   修复试题分页功能
205
  
ce70231e   孙向锦   增加接口
206
207
  		</if>
  		<if test="KNOWLEDGE_IDS != null and KNOWLEDGE_IDS.size() > 0">
0aad4b6b   孙向锦   修复试题分页功能
208
209
210
211
  			and
  			<foreach item="item" index="index" collection="KNOWLEDGE_IDS"
  				open="(" separator=" or " close=")">
  				FIND_IN_SET(#{item},KNOWLEDGE_ID)
ce70231e   孙向锦   增加接口
212
  			</foreach>
0aad4b6b   孙向锦   修复试题分页功能
213
  
ce70231e   孙向锦   增加接口
214
215
216
217
218
219
220
221
222
223
224
225
226
  		</if>
  		<if test="QUESTION_FROM != null and QUESTION_FROM != ''">
  			and QUESTION_FROM = #{QUESTION_FROM}
  		</if>
  		<if test="USER_ID != null and USER_ID != ''">
  			and USER_ID = #{USER_ID}
  		</if>
  		<if test="PROBLEM_TYPE != null and PROBLEM_TYPE != ''">
  			and PROBLEM_TYPE = #{PROBLEM_TYPE}
  		</if>
  		<if test="SUBJECT_ID != null and SUBJECT_ID != ''">
  			and SUBJECT_ID = #{SUBJECT_ID}
  		</if>
0aad4b6b   孙向锦   修复试题分页功能
227
  
ce70231e   孙向锦   增加接口
228
  		ORDER BY rand()
0aad4b6b   孙向锦   修复试题分页功能
229
  
ce70231e   孙向锦   增加接口
230
231
232
  		<if test="COUNT != null and COUNT != ''">
  			limit ${COUNT}
  		</if>
c617106f   孙向锦   添加即时测功能
233
234
235
  		<if test="COUNT == null or COUNT == ''">
  			limit 30
  		</if>
0aad4b6b   孙向锦   修复试题分页功能
236
237
  
  
ce70231e   孙向锦   增加接口
238
  	</select>
0aad4b6b   孙向锦   修复试题分页功能
239
  
bed6e1fc   孙向锦   添加其他功能
240
241
242
243
  	<!-- 批量删除 -->
  	<delete id="deleteAll" parameterType="String">
  		delete from
  		<include refid="tableName"></include>
0aad4b6b   孙向锦   修复试题分页功能
244
245
246
247
248
  		where
  		QUESTION_ID in
  		<foreach item="item" index="index" collection="array" open="("
  			separator="," close=")">
  			#{item}
bed6e1fc   孙向锦   添加其他功能
249
250
  		</foreach>
  	</delete>
0aad4b6b   孙向锦   修复试题分页功能
251
  
bed6e1fc   孙向锦   添加其他功能
252
253
  	<!-- fh313596790qq(青苔) -->
  </mapper>