123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- <?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.zhongzheng.modules.user.mapper.UserCourseAnswerMapper">
- <resultMap type="com.zhongzheng.modules.user.domain.UserCourseAnswer" id="UserCourseAnswerResult">
- <result property="answerId" column="answer_id"/>
- <result property="userId" column="user_id"/>
- <result property="assignUserId" column="assign_user_id"/>
- <result property="answerText" column="answer_text"/>
- <result property="courseId" column="course_id"/>
- <result property="sectionId" column="section_id"/>
- <result property="moduleId" column="module_id"/>
- <result property="chapterId" column="chapter_id"/>
- <result property="createTime" column="create_time"/>
- <result property="updateTime" column="update_time"/>
- <result property="goodsId" column="goods_id"/>
- <result property="assignAnswerId" column="assign_answer_id"/>
- </resultMap>
- <resultMap type="com.zhongzheng.modules.user.vo.UserCourseAnswerVo" id="UserCourseAnswerVo">
- <result property="answerId" column="answer_id"/>
- <result property="userId" column="user_id"/>
- <result property="assignUserId" column="assign_user_id"/>
- <result property="answerText" column="answer_text"/>
- <result property="courseId" column="course_id"/>
- <result property="sectionId" column="section_id"/>
- <result property="moduleId" column="module_id"/>
- <result property="chapterId" column="chapter_id"/>
- <result property="realname" column="realname"/>
- <result property="avatar" column="avatar"/>
- <result property="assignRealname" column="assign_realname"/>
- <result property="assignAvatar" column="assign_avatar"/>
- <result property="createTime" column="create_time"/>
- <result property="goodsId" column="goods_id"/>
- <result property="educationName" column="education_name"/>
- <result property="projectName" column="project_name"/>
- <result property="businessName" column="business_name"/>
- <result property="goodsName" column="goods_name"/>
- <result property="courseName" column="course_name"/>
- <result property="assignAnswerId" column="assign_answer_id"/>
- <result property="assignAnswerText" column="assign_answer_text"/>
- </resultMap>
- <select id="selectAnswer" parameterType="com.zhongzheng.modules.user.bo.UserCourseAnswerQueryBo" resultMap="UserCourseAnswerVo">
- SELECT
- uca.*,
- u.realname,
- u.avatar,
- u2.realname assign_realname,
- u2.avatar assign_avatar
- <if test="msgType == 2">
- ,uca1.answer_text as assign_answer_text
- </if>
- <if test="msgType != null">
- ,g.goods_name,
- c.course_name,
- cet.education_name,
- cpt.project_name,
- cb.business_name
- </if>
- FROM
- user_course_answer uca
- <if test="msgType == 2">
- LEFT JOIN user_course_answer uca1 ON uca.assign_answer_id = uca1.answer_id
- </if>
- LEFT JOIN `user` u ON uca.user_id = u.user_id
- LEFT JOIN `user` u2 ON uca.assign_user_id = u2.user_id
- <if test="msgType != null">
- LEFT JOIN goods g on uca.goods_id = g.goods_id
- LEFT JOIN course c on c.course_id = uca.course_id
- LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
- LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
- LEFT JOIN course_business cb ON g.business_id = cb.id
- </if>
- WHERE
- 1 = 1
- AND uca.STATUS =1
- <if test="courseId != null and courseId != ''">
- AND uca.course_id = #{courseId}
- </if>
- <if test="moduleId != null and moduleId != ''">
- AND uca.module_id = #{moduleId}
- </if>
- <if test="chapterId != null and chapterId != ''">
- AND uca.chapter_id = #{chapterId}
- </if>
- <if test="sectionId != null and sectionId != ''">
- AND uca.section_id = #{sectionId}
- </if>
- <if test="goodsId != null and goodsId != ''">
- AND uca.goods_id = #{goodsId}
- </if>
- <if test="msgType != null and msgType == 1">
- AND ISNULL(uca.assign_user_id )
- </if>
- <if test="msgType != null and msgType == 2">
- AND uca.assign_user_id>0
- </if>
- <if test="searchKey != null and searchKey != '' ">
- and (g.goods_name like concat('%', #{searchKey}, '%') or uca.answer_text like concat('%', #{searchKey}, '%'))
- </if>
- <if test="msgType != null">
- <if test="educationTypeId != null and educationTypeId != ''">
- AND g.education_type_id = #{educationTypeId}
- </if>
- <if test="businessIds != null and businessIds.size()!=0 ">
- AND g.business_id in
- <foreach collection="businessIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="businessId != null and businessId != ''">
- AND g.business_id = #{businessId}
- </if>
- </if>
- order by uca.update_time
- </select>
- <update id="delChildAnswer" parameterType="com.zhongzheng.modules.user.bo.UserCourseAnswerQueryBo" >
- UPDATE user_course_answer
- SET `status` = - 1
- WHERE
- FIND_IN_SET(
- answer_id,(
- SELECT
- ischild
- FROM
- (
- SELECT
- t1.answer_id,
- t1.assign_answer_id,
- t1.create_time,
- t2.*,
- IF
- ( find_in_set( assign_answer_id, @pids ) > 0, @pids := concat( @pids, ',', answer_id ), 0 ) AS ischild
- FROM
- ( SELECT answer_id, assign_answer_id, create_time FROM user_course_answer t WHERE t.assign_answer_id > 0 and tenant_id = #{tenantId} ORDER BY t.create_time ) t1,
- ( SELECT @pids := #{answerId} ) t2
- ) t4
- WHERE
- t4.ischild > 0
- ORDER BY
- create_time DESC
- LIMIT 1
- ))
- </update>
- <update id="delChildAnswer2" parameterType="com.zhongzheng.modules.user.bo.UserCourseAnswerQueryBo" >
- UPDATE user_course_answer
- set `status` = - 1
- WHERE
- FIND_IN_SET(
- answer_id,(
- SELECT
- ischild
- FROM
- (
- SELECT
- t1.answer_id,
- t1.assign_answer_id,
- t1.create_time,
- t2.*,
- IF
- ( find_in_set( assign_answer_id, @pids ) > 0, @pids := concat( @pids, ',', answer_id ), 0 ) AS ischild
- FROM
- ( SELECT answer_id, assign_answer_id, create_time FROM user_course_answer t WHERE t.assign_answer_id > 0 ORDER BY t.create_time ) t1,
- ( SELECT @pids := #{answerId} ) t2
- ) t4
- WHERE
- t4.ischild > 0
- ORDER BY
- create_time DESC
- LIMIT 1
- ))
- </update>
- </mapper>
|