暂存
This commit is contained in:
		| @@ -48,7 +48,7 @@ | ||||
|                 ) AS user USING(user_id) | ||||
|             </otherwise> | ||||
|         </choose> | ||||
|         ORDER BY type ASC, update_time DESC | ||||
|         ORDER BY `read` ASC, update_time DESC | ||||
|     </select> | ||||
|  | ||||
|     <select id="selectSysServicesQuestionSessionByQueId" resultMap="SysServicesQuestionSessionResult" | ||||
| @@ -78,7 +78,7 @@ | ||||
|             <if test="cusId != null">cus_id,</if> | ||||
|             <if test="content != null">content,</if> | ||||
|             <if test="type != null">type,</if> | ||||
|             <if test="cusId != null">create_time,</if> | ||||
|             <if test="createTime != null">create_time,</if> | ||||
|             <if test="img != null">img,</if> | ||||
|         </trim> | ||||
|         <trim prefix="values (" suffix=")" suffixOverrides=","> | ||||
| @@ -86,7 +86,7 @@ | ||||
|             <if test="cusId != null">#{cusId},</if> | ||||
|             <if test="content != null">#{content},</if> | ||||
|             <if test="type != null">#{type},</if> | ||||
|             <if test="cusId != null">now(),</if> | ||||
|             <if test="createTime != null">#{createTime},</if> | ||||
|             <if test="img != null"> | ||||
|                 #{img,  jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ArrayJsonHandler}, | ||||
|             </if> | ||||
| @@ -94,10 +94,11 @@ | ||||
|     </insert> | ||||
|  | ||||
|     <!--    插入问题的四个角色:1,用户; 2,营养师; 3,售后; 4,助理--> | ||||
|     <insert id="insertSysServicesQuestionStatus" parameterType="java.util.List"> | ||||
|         insert into sys_services_question_status (que_id, user_id, role, create_time, update_time) values | ||||
|     <insert id="insertSysServicesQuestionStatus" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id" | ||||
|             keyColumn="id"> | ||||
|         insert into sys_services_question_status (que_id, user_id, role, `read`, create_time, update_time) values | ||||
|         <foreach collection="list" item="status" index="index" separator=","> | ||||
|             (#{status.queId}, #{status.userId}, #{status.role}, now(), now()) | ||||
|             (#{status.queId}, #{status.userId}, #{status.role}, #{status.read}, now(), now()) | ||||
|         </foreach> | ||||
|     </insert> | ||||
|  | ||||
| @@ -127,8 +128,7 @@ | ||||
|     </update> | ||||
|  | ||||
|     <!--    插入问题回复--> | ||||
|     <insert id="inserSysServicesQuestionReply" parameterType="SysServicesQuestion" useGeneratedKeys="true" | ||||
|             keyProperty="id" keyColumn="id"> | ||||
|     <insert id="inserSysServicesQuestionReply" parameterType="SysServicesQuestion"> | ||||
|         insert into sys_services_question_session | ||||
|         <trim prefix="(" suffix=")" suffixOverrides=","> | ||||
|             <if test="queId != null">que_id,</if> | ||||
|   | ||||
| @@ -0,0 +1,156 @@ | ||||
| <?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.stdiet.custom.mapper.SysServicesTopicMapper"> | ||||
|  | ||||
|     <resultMap type="SysServicesTopic" id="SysServicesTopicResult"> | ||||
|         <result column="id" property="id"/> | ||||
|         <result column="topic_id" property="topicId"/> | ||||
|         <result column="topic_type" property="topicType"/> | ||||
|         <result column="content" property="content"/> | ||||
|         <result column="role" property="role"/> | ||||
|         <result column="name" property="name"/> | ||||
|         <result column="read" property="read"/> | ||||
|         <result column="img" property="img" typeHandler="com.stdiet.custom.typehandler.ArrayJsonHandler"/> | ||||
|         <result column="create_time" property="createTime"/> | ||||
|         <result column="update_time" property="updateTime"/> | ||||
|     </resultMap> | ||||
|  | ||||
|     <resultMap id="SysServicesQuestionSessionResult" type="SysServicesQuestion"> | ||||
|         <result column="id" property="id"/> | ||||
|         <result column="type" property="type"/> | ||||
|         <result column="content" property="content"/> | ||||
|         <result column="img" property="img" typeHandler="com.stdiet.custom.typehandler.ArrayJsonHandler"/> | ||||
|         <result column="create_time" property="createTime"/> | ||||
|         <association property="name" column="{userId=user_id,role=role}" select="selectUserInfo"/> | ||||
|     </resultMap> | ||||
|  | ||||
|     <!--    根据userId和角色查询问题列表--> | ||||
|     <select id="selectSysServicesTopicByUserIdAndRole" parameterType="SysServicesTopic" | ||||
|             resultMap="SysServicesQuestionResult"> | ||||
|         SELECT * FROM ( | ||||
|         SELECT * FROM sys_services_topic_status WHERE role = #{role} AND uid = #{uid} | ||||
|         ) AS status | ||||
|         LEFT JOIN sys_services_question USING(topic_id) | ||||
|         <choose> | ||||
|             <when test="role == 'customer'"> | ||||
|                 LEFT JOIN ( | ||||
|                     SELECT name, id AS uid FROM sys_customer WHERE id = #{uid} | ||||
|                 ) AS customer USING(uid) | ||||
|             </when> | ||||
|             <otherwise> | ||||
|                 LEFT JOIN ( | ||||
|                     SELECT name, user_id AS uid, nick_name AS name FROM sys_user WHERE user_id = #{uid} | ||||
|                 ) AS user USING(uid) | ||||
|             </otherwise> | ||||
|         </choose> | ||||
|         ORDER BY `read` ASC, update_time DESC | ||||
|     </select> | ||||
|  | ||||
|     <select id="selectSysServicesQuestionSessionByQueId" resultMap="SysServicesQuestionSessionResult" | ||||
|             parameterType="String"> | ||||
|         select que_id, cus_id as user_id, 'customer' as role, content, img, create_time from sys_services_question where que_id = #{queId} | ||||
|         union select que_id, user_id, role, content, img, create_time from sys_services_question_session where que_id = #{queId} | ||||
|         order by create_time asc | ||||
|     </select> | ||||
|  | ||||
|     <select id="selectUserInfo" parameterType="java.util.Map" resultType="String"> | ||||
|         <choose> | ||||
|             <when test="_parameter.get('role') == 'customer'"> | ||||
|                 select name from sys_customer where id = #{userId} | ||||
|             </when> | ||||
|             <otherwise> | ||||
|                 select nick_name from sys_user where user_id = #{userId} | ||||
|             </otherwise> | ||||
|         </choose> | ||||
|     </select> | ||||
|  | ||||
|     <!--    插入问题--> | ||||
|     <insert id="insertSysServicesQuestion" parameterType="SysServicesQuestion" useGeneratedKeys="true" | ||||
|             keyProperty="queId" keyColumn="que_id"> | ||||
|         insert into sys_services_question | ||||
|         <trim prefix="(" suffix=")" suffixOverrides=","> | ||||
|             <if test="queId != null">que_id,</if> | ||||
|             <if test="cusId != null">cus_id,</if> | ||||
|             <if test="content != null">content,</if> | ||||
|             <if test="type != null">type,</if> | ||||
|             <if test="createTime != null">create_time,</if> | ||||
|             <if test="img != null">img,</if> | ||||
|         </trim> | ||||
|         <trim prefix="values (" suffix=")" suffixOverrides=","> | ||||
|             <if test="queId != null">#{queId},</if> | ||||
|             <if test="cusId != null">#{cusId},</if> | ||||
|             <if test="content != null">#{content},</if> | ||||
|             <if test="type != null">#{type},</if> | ||||
|             <if test="createTime != null">#{createTime},</if> | ||||
|             <if test="img != null"> | ||||
|                 #{img,  jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ArrayJsonHandler}, | ||||
|             </if> | ||||
|         </trim> | ||||
|     </insert> | ||||
|  | ||||
|     <!--    插入问题的四个角色:1,用户; 2,营养师; 3,售后; 4,助理--> | ||||
|     <insert id="insertSysServicesQuestionStatus" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id" | ||||
|             keyColumn="id"> | ||||
|         insert into sys_services_question_status (que_id, user_id, role, `read`, create_time, update_time) values | ||||
|         <foreach collection="list" item="status" index="index" separator=","> | ||||
|             (#{status.queId}, #{status.userId}, #{status.role}, #{status.read}, now(), now()) | ||||
|         </foreach> | ||||
|     </insert> | ||||
|  | ||||
|     <!--    根据状态id更新, role=customer 客户回复,这时更新另外三个角色未读;role != customer,更新客户未读--> | ||||
|     <update id="updateSysServicesQuestionStatus" parameterType="SysServicesQuestion"> | ||||
|         update sys_services_question_status | ||||
|         <trim prefix="SET" suffixOverrides=","> | ||||
|             <if test="read != null">`read` = #{read},</if> | ||||
|             <if test="read != null">update_time = now(),</if> | ||||
|         </trim> | ||||
|         <where> | ||||
|             <choose> | ||||
|                 <when test="id != null"> | ||||
|                     id = ${id} | ||||
|                 </when> | ||||
|                 <otherwise> | ||||
|                     <if test="role == 'customer'"> | ||||
|                         role != #{role} and | ||||
|                     </if> | ||||
|                     <if test="role != 'customer'"> | ||||
|                         role = 'customer' and | ||||
|                     </if> | ||||
|                     que_id = #{queId} | ||||
|                 </otherwise> | ||||
|             </choose> | ||||
|         </where> | ||||
|     </update> | ||||
|  | ||||
|     <!--    插入问题回复--> | ||||
|     <insert id="inserSysServicesQuestionReply" parameterType="SysServicesQuestion"> | ||||
|         insert into sys_services_question_session | ||||
|         <trim prefix="(" suffix=")" suffixOverrides=","> | ||||
|             <if test="queId != null">que_id,</if> | ||||
|             <if test="userId != null">user_id,</if> | ||||
|             <if test="content != null">content,</if> | ||||
|             <if test="read != null">`read`,</if> | ||||
|             <if test="role != null">role,</if> | ||||
|             <if test="img != null">img,</if> | ||||
|             <if test="queId != null">create_time,</if> | ||||
|             <if test="queId != null">update_time,</if> | ||||
|  | ||||
|         </trim> | ||||
|         <trim prefix="values (" suffix=")" suffixOverrides=","> | ||||
|             <if test="queId != null">#{queId},</if> | ||||
|             <if test="userId != null">#{userId},</if> | ||||
|             <if test="content != null">#{content},</if> | ||||
|             <if test="read != null">#{read},</if> | ||||
|             <if test="role != null">#{role},</if> | ||||
|             <if test="img != null"> | ||||
|                 #{img,  jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ArrayJsonHandler}, | ||||
|             </if> | ||||
|             <if test="queId != null">now(),</if> | ||||
|             <if test="queId != null">now(),</if> | ||||
|         </trim> | ||||
|     </insert> | ||||
|  | ||||
|  | ||||
| </mapper> | ||||
		Reference in New Issue
	
	Block a user