龚焕茏
2024-07-03 3ec909b27b3eba956aa9d00cc7a94c179bd04bbf
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
<?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="com.mindskip.xzs.repository.ExamPaperQuestionCustomerAnswerMapper">
  <resultMap id="BaseResultMap" type="com.mindskip.xzs.domain.ExamPaperQuestionCustomerAnswer">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="question_id" jdbcType="INTEGER" property="questionId" />
    <result column="exam_paper_id" jdbcType="INTEGER" property="examPaperId" />
    <result column="exam_paper_answer_id" jdbcType="INTEGER" property="examPaperAnswerId" />
    <result column="question_type" jdbcType="INTEGER" property="questionType" />
    <result column="subject_id" jdbcType="INTEGER" property="subjectId" />
    <result column="customer_score" jdbcType="INTEGER" property="customerScore" />
    <result column="question_score" jdbcType="INTEGER" property="questionScore" />
    <result column="question_text_content_id" jdbcType="INTEGER" property="questionTextContentId" />
    <result column="answer" jdbcType="VARCHAR" property="answer" />
    <result column="text_content_id" jdbcType="INTEGER" property="textContentId" />
    <result column="do_right" jdbcType="BIT" property="doRight" />
    <result column="create_user" jdbcType="INTEGER" property="createUser" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="item_order" jdbcType="INTEGER" property="itemOrder" />
  </resultMap>
  <sql id="Base_Column_List">
    id, question_id, exam_paper_id, exam_paper_answer_id, question_type, subject_id,
    customer_score, question_score, question_text_content_id, answer, text_content_id,
    do_right, create_user, create_time, item_order
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from t_exam_paper_question_customer_answer
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from t_exam_paper_question_customer_answer
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.mindskip.xzs.domain.ExamPaperQuestionCustomerAnswer" useGeneratedKeys="true" keyProperty="id">
    insert into t_exam_paper_question_customer_answer (id, question_id, exam_paper_id,
      exam_paper_answer_id, question_type, subject_id,
      customer_score, question_score, question_text_content_id,
      answer, text_content_id, do_right,
      create_user, create_time, item_order
      )
    values (#{id,jdbcType=INTEGER}, #{questionId,jdbcType=INTEGER}, #{examPaperId,jdbcType=INTEGER},
      #{examPaperAnswerId,jdbcType=INTEGER}, #{questionType,jdbcType=INTEGER}, #{subjectId,jdbcType=INTEGER},
      #{customerScore,jdbcType=INTEGER}, #{questionScore,jdbcType=INTEGER}, #{questionTextContentId,jdbcType=INTEGER},
      #{answer,jdbcType=VARCHAR}, #{textContentId,jdbcType=INTEGER}, #{doRight,jdbcType=BIT},
      #{createUser,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{itemOrder,jdbcType=INTEGER}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.mindskip.xzs.domain.ExamPaperQuestionCustomerAnswer" useGeneratedKeys="true" keyProperty="id">
    insert into t_exam_paper_question_customer_answer
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="questionId != null">
        question_id,
      </if>
      <if test="examPaperId != null">
        exam_paper_id,
      </if>
      <if test="examPaperAnswerId != null">
        exam_paper_answer_id,
      </if>
      <if test="questionType != null">
        question_type,
      </if>
      <if test="subjectId != null">
        subject_id,
      </if>
      <if test="customerScore != null">
        customer_score,
      </if>
      <if test="questionScore != null">
        question_score,
      </if>
      <if test="questionTextContentId != null">
        question_text_content_id,
      </if>
      <if test="answer != null">
        answer,
      </if>
      <if test="textContentId != null">
        text_content_id,
      </if>
      <if test="doRight != null">
        do_right,
      </if>
      <if test="createUser != null">
        create_user,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="itemOrder != null">
        item_order,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="questionId != null">
        #{questionId,jdbcType=INTEGER},
      </if>
      <if test="examPaperId != null">
        #{examPaperId,jdbcType=INTEGER},
      </if>
      <if test="examPaperAnswerId != null">
        #{examPaperAnswerId,jdbcType=INTEGER},
      </if>
      <if test="questionType != null">
        #{questionType,jdbcType=INTEGER},
      </if>
      <if test="subjectId != null">
        #{subjectId,jdbcType=INTEGER},
      </if>
      <if test="customerScore != null">
        #{customerScore,jdbcType=INTEGER},
      </if>
      <if test="questionScore != null">
        #{questionScore,jdbcType=INTEGER},
      </if>
      <if test="questionTextContentId != null">
        #{questionTextContentId,jdbcType=INTEGER},
      </if>
      <if test="answer != null">
        #{answer,jdbcType=VARCHAR},
      </if>
      <if test="textContentId != null">
        #{textContentId,jdbcType=INTEGER},
      </if>
      <if test="doRight != null">
        #{doRight,jdbcType=BIT},
      </if>
      <if test="createUser != null">
        #{createUser,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="itemOrder != null">
        #{itemOrder,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.mindskip.xzs.domain.ExamPaperQuestionCustomerAnswer">
    update t_exam_paper_question_customer_answer
    <set>
      <if test="questionId != null">
        question_id = #{questionId,jdbcType=INTEGER},
      </if>
      <if test="examPaperId != null">
        exam_paper_id = #{examPaperId,jdbcType=INTEGER},
      </if>
      <if test="examPaperAnswerId != null">
        exam_paper_answer_id = #{examPaperAnswerId,jdbcType=INTEGER},
      </if>
      <if test="questionType != null">
        question_type = #{questionType,jdbcType=INTEGER},
      </if>
      <if test="subjectId != null">
        subject_id = #{subjectId,jdbcType=INTEGER},
      </if>
      <if test="customerScore != null">
        customer_score = #{customerScore,jdbcType=INTEGER},
      </if>
      <if test="questionScore != null">
        question_score = #{questionScore,jdbcType=INTEGER},
      </if>
      <if test="questionTextContentId != null">
        question_text_content_id = #{questionTextContentId,jdbcType=INTEGER},
      </if>
      <if test="answer != null">
        answer = #{answer,jdbcType=VARCHAR},
      </if>
      <if test="textContentId != null">
        text_content_id = #{textContentId,jdbcType=INTEGER},
      </if>
      <if test="doRight != null">
        do_right = #{doRight,jdbcType=BIT},
      </if>
      <if test="createUser != null">
        create_user = #{createUser,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="itemOrder != null">
        item_order = #{itemOrder,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.mindskip.xzs.domain.ExamPaperQuestionCustomerAnswer">
    update t_exam_paper_question_customer_answer
    set question_id = #{questionId,jdbcType=INTEGER},
      exam_paper_id = #{examPaperId,jdbcType=INTEGER},
      exam_paper_answer_id = #{examPaperAnswerId,jdbcType=INTEGER},
      question_type = #{questionType,jdbcType=INTEGER},
      subject_id = #{subjectId,jdbcType=INTEGER},
      customer_score = #{customerScore,jdbcType=INTEGER},
      question_score = #{questionScore,jdbcType=INTEGER},
      question_text_content_id = #{questionTextContentId,jdbcType=INTEGER},
      answer = #{answer,jdbcType=VARCHAR},
      text_content_id = #{textContentId,jdbcType=INTEGER},
      do_right = #{doRight,jdbcType=BIT},
      create_user = #{createUser,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      item_order = #{itemOrder,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
 
 
 
 
 
 
 
 
 
  <select id="selectListByPaperAnswerId" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from t_exam_paper_question_customer_answer
    where exam_paper_answer_id = #{id,jdbcType=INTEGER}
    order by item_order
  </select>
 
 
  <select id="studentPage" resultType="com.mindskip.xzs.viewmodel.student.question.answer.QuestionPageStudentResponseVM" parameterType="com.mindskip.xzs.viewmodel.student.question.answer.QuestionPageStudentRequestVM">
    select a.id,
           a.question_type,
           JSON_VALUE(d.content, '$.titleContent') as shortTitle,
           GROUP_CONCAT(DISTINCT c.name)                    as subjectName,
           a.create_time
    from t_exam_paper_question_customer_answer a
           inner join t_question_subject b on a.question_id = b.question_id and b.deleted = 0
           inner join t_subject c on b.subject_id = c.id and c.deleted = 0
           inner join t_text_content d on a.question_text_content_id = d.id
    where
      a.do_right = FALSE
      and a.create_user = #{createUser}
      and JSON_VALUE(d.content, '$.titleContent') like concat('%', #{shortTitle}, '%')
    group by a.question_id, question_type
    HAVING GROUP_CONCAT(c.name) like concat('%',  #{subjectName}, '%')
    order by a.question_id desc
  </select>
 
 
  <insert id="insertList" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id" >
    insert into t_exam_paper_question_customer_answer ( question_id, question_score,
    subject_id, create_time, create_user,
    text_content_id, exam_paper_id, question_type,
    answer, customer_score, exam_paper_answer_id ,
    do_right,question_text_content_id,item_order)
    values
    <foreach collection="list" item="item" index="index"
             separator=",">
      ( #{item.questionId,jdbcType=INTEGER}, #{item.questionScore,jdbcType=INTEGER},
      #{item.subjectId,jdbcType=INTEGER}, #{item.createTime,jdbcType=TIMESTAMP}, #{item.createUser,jdbcType=INTEGER},
      #{item.textContentId,jdbcType=INTEGER}, #{item.examPaperId,jdbcType=INTEGER}, #{item.questionType,jdbcType=INTEGER},
      #{item.answer,jdbcType=VARCHAR}, #{item.customerScore,jdbcType=INTEGER}, #{item.examPaperAnswerId,jdbcType=INTEGER},
      #{item.doRight,jdbcType=BIT},#{item.questionTextContentId,jdbcType=INTEGER},#{item.itemOrder,jdbcType=INTEGER})
    </foreach>
  </insert>
 
 
  <select id="selectAllCount"  resultType="java.lang.Integer">
        SELECT count(*) from t_exam_paper_question_customer_answer a
        inner join
        (select user_id from t_user_department
        <if test="deptIds != null and deptIds.size() > 0">
          where department_id in
          <foreach collection="deptIds" item="item" open="(" separator="," close=")">
            #{item}
          </foreach>
        </if>
        group by user_id)
        b on a.create_user = b.user_id
  </select>
 
 
  <select id="selectCountByDate"  resultType="com.mindskip.xzs.domain.other.KeyValue">
        SELECT create_time as name,COUNT(create_time) as value from
                (
                  SELECT DATE_FORMAT(create_time,'%Y-%m-%d') as create_time from t_exam_paper_question_customer_answer a
                  inner join
                  (select user_id from t_user_department
                  <if test="deptIds != null and deptIds.size() > 0">
                    where department_id in
                    <foreach collection="deptIds" item="item" open="(" separator="," close=")">
                      #{item}
                    </foreach>
                  </if>
                  group by user_id)
                  b on a.create_user = b.user_id
                    WHERE  create_time  between  #{startTime}  and  #{endTime}
                ) a
        GROUP BY create_time
  </select>
 
  <update id="updateScore" parameterType="java.util.List">
    <foreach collection="list" item="item" >
        update t_exam_paper_question_customer_answer
        set customer_score=#{item.customerScore} , do_right=#{item.doRight}
        where id=#{item.id} ;
    </foreach>
  </update>
 
</mapper>