diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysServiceQuestionController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysServiceQuestionController.java deleted file mode 100644 index 4f7cf6fb7..000000000 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysServiceQuestionController.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.stdiet.web.controller.custom; - -import com.stdiet.common.core.controller.BaseController; -import com.stdiet.common.core.domain.AjaxResult; -import com.stdiet.common.core.page.TableDataInfo; -import com.stdiet.common.utils.StringUtils; -import com.stdiet.custom.domain.SysServicesQuestion; -import com.stdiet.custom.service.ISysServicesQuestionService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -@RestController -@RequestMapping("/services/question") -public class SysServiceQuestionController extends BaseController { - - @Autowired - private ISysServicesQuestionService sysServicesQuestionService; - - @GetMapping("/list") - public TableDataInfo list(SysServicesQuestion sysServicesQuestion) { - startPage(); - return getDataTable(sysServicesQuestionService.selectSysServicesQuestionByUserIdAndRole(sysServicesQuestion)); - } - -// @PutMapping("/update/status") -// public AjaxResult status(@RequestBody SysServicesQuestion sysServicesQuestion) { -// return toAjax(sysServicesQuestionService.updateSysServicesQuestionStatus(sysServicesQuestion)); -// } - - @PostMapping("/reply") - public AjaxResult reply(@RequestBody SysServicesQuestion servicesQuestion) { - int row = sysServicesQuestionService.inserSysServicesQuestionReply(servicesQuestion); - if (row > 0) { - // 更新customer未读,id不能有值 - servicesQuestion.setRead(0); - sysServicesQuestionService.updateSysServicesQuestionStatus(servicesQuestion); - } - return toAjax(row); - } - - @GetMapping("/detail") - public AjaxResult detail(@RequestParam String queId, @RequestParam Long id) { - List<SysServicesQuestion> questions = sysServicesQuestionService.selectSysServicesQuestionSessionByQueId(queId); - if (StringUtils.isNotNull(questions)) { - // 更新问题对应角色的状态 - SysServicesQuestion servicesQuestion = new SysServicesQuestion(); - servicesQuestion.setRead(1); - servicesQuestion.setId(id); - sysServicesQuestionService.updateSysServicesQuestionStatus(servicesQuestion); - } - return AjaxResult.success(questions); - } -} diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java index f012f7582..6a3add4a0 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java @@ -69,8 +69,6 @@ public class WechatAppletController extends BaseController { @Autowired private IWechatAppletService iWechatAppletService; @Autowired - private ISysServicesQuestionService iSysServicesQuestionService; - @Autowired private ISysServicesTopicService iSysServicesTopicService; /** @@ -594,17 +592,33 @@ public class WechatAppletController extends BaseController { return AjaxResult.success(sysRecipesPlanService.updateSysRecipesPlan(info)); } - @GetMapping("/services/list") + + /** + * 主题列表 + * + * @param customerId + * @param pageNum + * @param pageSize + * @return + */ + @GetMapping("/services/topic/list") public TableDataInfo fetchServiceQuestion(@RequestParam String customerId, @RequestParam Integer pageNum, @RequestParam Integer pageSize) { startPage(); - Long cusId = StringUtils.isNotEmpty(customerId) ? Long.parseLong(AesUtils.decrypt(customerId)) : 0L; + String cusId = StringUtils.isNotEmpty(customerId) ? AesUtils.decrypt(customerId) : "0"; - SysServicesQuestion servicesQuestion = new SysServicesQuestion(); - servicesQuestion.setRole("customer"); - servicesQuestion.setUserId(cusId); + SysServicesTopic topic = new SysServicesTopic(); + topic.setRole("customer"); + topic.setUid(cusId); - return getDataTable(iSysServicesQuestionService.selectSysServicesQuestionByUserIdAndRole(servicesQuestion)); + List<SysServicesTopic> list = iSysServicesTopicService.selectSysServicesTopicByUserIdAndRole(topic); + if (StringUtils.isNotNull(list)) { + for (SysServicesTopic tTopic : list) { + tTopic.setUid(AesUtils.encrypt(tTopic.getUid())); + } + } + + return getDataTable(list); } /** @@ -616,8 +630,8 @@ public class WechatAppletController extends BaseController { */ @PostMapping("/services/topic/post") public AjaxResult postServiceTopic(@RequestBody SysServicesTopic topic, @RequestParam String customerId) { - Long cusId = StringUtils.isNotEmpty(customerId) ? Long.parseLong(AesUtils.decrypt(customerId)) : 0L; - if (cusId == 0L) { + String cusId = StringUtils.isNotEmpty(customerId) ? AesUtils.decrypt(customerId) : "0"; + if (StringUtils.isEmpty(cusId)) { return toAjax(0); } topic.setUid(cusId); @@ -625,48 +639,22 @@ public class WechatAppletController extends BaseController { return AjaxResult.success(iSysServicesTopicService.insertSysServicesTopic(topic)); } - /** - * 客户添加问题 - * - * @param servicesQuestion - * @param customerId - * @return - */ - @PostMapping("/services/post") - public AjaxResult postServiceQuestion(@RequestBody SysServicesQuestion servicesQuestion, @RequestParam String customerId) { - Long cusId = StringUtils.isNotEmpty(customerId) ? Long.parseLong(AesUtils.decrypt(customerId)) : 0L; - if (cusId == 0L) { - return toAjax(0); - } - servicesQuestion.setCusId(cusId); - - return AjaxResult.success(iSysServicesQuestionService.insertSysServicesQuestion(servicesQuestion)); - } /** * 回答问题 * - * @param servicesQuestion - * @param customerId + * @param topic * @return */ - @PostMapping("/services/post/reply") - public AjaxResult replyServiceQuestion(@RequestBody SysServicesQuestion servicesQuestion, @RequestParam String customerId) { - Long cusId = StringUtils.isNotEmpty(customerId) ? Long.parseLong(AesUtils.decrypt(customerId)) : 0L; - if (cusId == 0L) { - return toAjax(0); - } - servicesQuestion.setRole("customer"); - servicesQuestion.setUserId(cusId); + @PostMapping("/services/topic/reply") + public AjaxResult replyServiceTopic(@RequestBody SysServicesTopic topic, @RequestParam Integer type) { - int row = iSysServicesQuestionService.inserSysServicesQuestionReply(servicesQuestion); - if (row > 0) { - // 更新三个觉得未读,id不能有值 - servicesQuestion.setRead(0); - iSysServicesQuestionService.updateSysServicesQuestionStatus(servicesQuestion); - } + topic.setFromUid(AesUtils.decrypt(topic.getFromUid())); + topic.setToUid(AesUtils.decrypt(topic.getToUid())); - return toAjax(row); + SysServicesTopic servicesTopic = type == 0 ? iSysServicesTopicService.inserSysServicesTopicComment(topic) : iSysServicesTopicService.inserSysServicesTopicReply(topic); + + return AjaxResult.success(servicesTopic); } /** @@ -675,16 +663,32 @@ public class WechatAppletController extends BaseController { * @param id * @return */ - @GetMapping("/services/detail") - public AjaxResult serviceQuestionDetail(@RequestParam String queId, @RequestParam Long id) { - List<SysServicesQuestion> questions = iSysServicesQuestionService.selectSysServicesQuestionSessionByQueId(queId); - if (StringUtils.isNotNull(questions)) { - SysServicesQuestion status = new SysServicesQuestion(); + @GetMapping("/services/topic/detail") + public AjaxResult serviceTopicDetail(@RequestParam String topicId, @RequestParam String id) { + List<SysServicesTopic> topics = iSysServicesTopicService.selectSysServicesTopicSessionByTopicId(topicId); + if (StringUtils.isNotNull(topics)) { + SysServicesTopic status = new SysServicesTopic(); status.setId(id); status.setRead(1); - iSysServicesQuestionService.updateSysServicesQuestionStatus(status); + iSysServicesTopicService.updateSysServicesTopicStatus(status); + + for (SysServicesTopic topic : topics) { + topic.setUid(AesUtils.encrypt(topic.getUid())); + if (StringUtils.isNotNull(topic.getComments())) { + for (SysServicesTopic cTopic : topic.getComments()) { + cTopic.setFromUid(AesUtils.encrypt(cTopic.getFromUid())); + cTopic.setToUid(AesUtils.encrypt(cTopic.getToUid())); + if (StringUtils.isNotNull(cTopic.getReplys())) { + for (SysServicesTopic rTopic : cTopic.getReplys()) { + rTopic.setFromUid(AesUtils.encrypt(rTopic.getFromUid())); + rTopic.setToUid(AesUtils.encrypt(rTopic.getToUid())); + } + } + } + } + } } - return AjaxResult.success(questions); + return AjaxResult.success(topics); } diff --git a/stdiet-common/src/main/java/com/stdiet/common/core/controller/BaseController.java b/stdiet-common/src/main/java/com/stdiet/common/core/controller/BaseController.java index 250614f38..7a4643171 100644 --- a/stdiet-common/src/main/java/com/stdiet/common/core/controller/BaseController.java +++ b/stdiet-common/src/main/java/com/stdiet/common/core/controller/BaseController.java @@ -64,13 +64,18 @@ public class BaseController { PageDomain pageDomain = TableSupport.buildPageRequest(); Integer pageNum = pageDomain.getPageNum(); Integer pageSize = pageDomain.getPageSize(); - long total = new PageInfo(list).getTotal(); + List<?> rows; + if (StringUtils.isNull(pageNum) || StringUtils.isNull(pageSize)) { + rows = list; + } else { + rows = total > pageSize * (pageNum - 1) ? list : new ArrayList<>(); + } TableDataInfo rspData = new TableDataInfo(); rspData.setCode(HttpStatus.SUCCESS); rspData.setMsg("查询成功"); - rspData.setRows(total > pageSize * (pageNum - 1) ? list : new ArrayList<>()); + rspData.setRows(rows); rspData.setTotal(total); return rspData; } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysServicesQuestion.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysServicesQuestion.java deleted file mode 100644 index 5e94155ef..000000000 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysServicesQuestion.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.stdiet.custom.domain; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.fasterxml.jackson.annotation.JsonFormat; -import lombok.Data; - -import java.util.Date; - -@Data -public class SysServicesQuestion { - /** - * 问题状态id - */ - Long id; - - /** - * 问题id(搜索用) - */ - String queId; - - /** - * 客户id - */ - Long cusId; - - /** - * 问题内容 - */ - String content; - - - /** - * 图片地址 - */ - JSONArray img; - - /** - * 问题类型 - */ - Integer type; - - /** - * 创建时间 - */ - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - Date createTime; - - /** - * 0-未读 1-已读 - */ - Integer read; - - /** - * 更新时间 - */ - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - Date updateTime; - - /** - * 角色 - */ - String role; - - // 非持久化字段 - /** - * 角色名字 - */ - String name; - - /** - * 角色id - */ - Long userId; - -} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysServicesTopic.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysServicesTopic.java index d76cf691a..f465d7522 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysServicesTopic.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysServicesTopic.java @@ -35,11 +35,11 @@ public class SysServicesTopic { /** * 角色 */ - Long uid; + String uid; - Long fromUid; + String fromUid; - Long toUid; + String toUid; /** * 问题内容 diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysServicesQuestionMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysServicesQuestionMapper.java deleted file mode 100644 index f38e1d949..000000000 --- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysServicesQuestionMapper.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.stdiet.custom.mapper; - -import com.stdiet.custom.domain.SysServicesQuestion; - -import java.util.List; - -public interface SysServicesQuestionMapper { - List<SysServicesQuestion> selectSysServicesQuestionByUserIdAndRole(SysServicesQuestion servicesQuestion); - - int insertSysServicesQuestion(SysServicesQuestion servicesQuestion); - - int insertSysServicesQuestionStatus(List<SysServicesQuestion> servicesQuestion); - - int updateSysServicesQuestionStatus(SysServicesQuestion servicesQuestion); - - int inserSysServicesQuestionReply(SysServicesQuestion servicesQuestion); - - List<SysServicesQuestion> selectSysServicesQuestionSessionByQueId(String queId); -} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysServicesTopicMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysServicesTopicMapper.java index 29ecaadaa..333417f81 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysServicesTopicMapper.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysServicesTopicMapper.java @@ -1,6 +1,5 @@ package com.stdiet.custom.mapper; -import com.stdiet.custom.domain.SysServicesQuestion; import com.stdiet.custom.domain.SysServicesTopic; import java.util.List; diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysServicesQuestionService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysServicesQuestionService.java deleted file mode 100644 index f671b9268..000000000 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysServicesQuestionService.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.stdiet.custom.service; - -import com.stdiet.custom.domain.SysServicesQuestion; - -import java.util.List; - -public interface ISysServicesQuestionService { - - List<SysServicesQuestion> selectSysServicesQuestionByUserIdAndRole(SysServicesQuestion servicesQuestion); - - SysServicesQuestion insertSysServicesQuestion(SysServicesQuestion servicesQuestion); - - int updateSysServicesQuestionStatus(SysServicesQuestion sysServicesQuestion); - - int inserSysServicesQuestionReply(SysServicesQuestion sysServicesQuestion); - - List<SysServicesQuestion> selectSysServicesQuestionSessionByQueId(String queId); -} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysServicesTopicService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysServicesTopicService.java index dedfe3873..1b9b14291 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysServicesTopicService.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysServicesTopicService.java @@ -1,6 +1,5 @@ package com.stdiet.custom.service; -import com.stdiet.custom.domain.SysServicesQuestion; import com.stdiet.custom.domain.SysServicesTopic; import java.util.List; diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysServicesQuestionServiceImp.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysServicesQuestionServiceImp.java deleted file mode 100644 index fbaca72b1..000000000 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysServicesQuestionServiceImp.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.stdiet.custom.service.impl; - -import com.stdiet.common.utils.DateUtils; -import com.stdiet.common.utils.uuid.UUID; -import com.stdiet.custom.domain.SysCustomer; -import com.stdiet.custom.domain.SysServicesQuestion; -import com.stdiet.custom.mapper.SysCustomerMapper; -import com.stdiet.custom.mapper.SysServicesQuestionMapper; -import com.stdiet.custom.service.ISysServicesQuestionService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.List; - -@Service -public class SysServicesQuestionServiceImp implements ISysServicesQuestionService { - @Autowired - SysServicesQuestionMapper servicesQuestionMapper; - - @Autowired - SysCustomerMapper sysCustomerMapper; - - @Override - public List<SysServicesQuestion> selectSysServicesQuestionByUserIdAndRole(SysServicesQuestion servicesQuestion) { - return servicesQuestionMapper.selectSysServicesQuestionByUserIdAndRole(servicesQuestion); - } - - @Override - public SysServicesQuestion insertSysServicesQuestion(SysServicesQuestion servicesQuestion) { - // 生成uuid - servicesQuestion.setQueId(UUID.randomUUID().toString().replaceAll("-", "")); - servicesQuestion.setRead(1); - servicesQuestion.setCreateTime(DateUtils.getNowDate()); - - servicesQuestionMapper.insertSysServicesQuestion(servicesQuestion); - - SysCustomer customer = sysCustomerMapper.selectSysCustomerById(servicesQuestion.getCusId()); - - List<SysServicesQuestion> statusList = new ArrayList<>(); - SysServicesQuestion customerStatus = new SysServicesQuestion(); - customerStatus.setUserId(customer.getId()); - customerStatus.setRole("customer"); - customerStatus.setRead(1); - customerStatus.setQueId(servicesQuestion.getQueId()); - statusList.add(customerStatus); - - SysServicesQuestion dieticianStatus = new SysServicesQuestion(); - dieticianStatus.setUserId(customer.getMainDietitian()); - dieticianStatus.setRole("dietician"); - dieticianStatus.setRead(0); - dieticianStatus.setQueId(servicesQuestion.getQueId()); - statusList.add(dieticianStatus); - - SysServicesQuestion afterSaleStatus = new SysServicesQuestion(); - afterSaleStatus.setUserId(customer.getAfterDietitian()); - afterSaleStatus.setRole("after_sale"); - afterSaleStatus.setRead(0); - afterSaleStatus.setQueId(servicesQuestion.getQueId()); - statusList.add(afterSaleStatus); - - SysServicesQuestion dieticianAssistantStatus = new SysServicesQuestion(); - dieticianAssistantStatus.setUserId(customer.getAssistantDietitian()); - dieticianAssistantStatus.setRole("dietician_assistant"); - dieticianAssistantStatus.setRead(0); - dieticianAssistantStatus.setQueId(servicesQuestion.getQueId()); - - statusList.add(dieticianAssistantStatus); - - servicesQuestionMapper.insertSysServicesQuestionStatus(statusList); - - servicesQuestion.setId(customerStatus.getId()); - servicesQuestion.setCusId(null); - - return servicesQuestion; - } - - - @Override - public int updateSysServicesQuestionStatus(SysServicesQuestion sysServicesQuestion) { - return servicesQuestionMapper.updateSysServicesQuestionStatus(sysServicesQuestion); - } - - @Override - public int inserSysServicesQuestionReply(SysServicesQuestion sysServicesQuestion) { - int row = servicesQuestionMapper.inserSysServicesQuestionReply(sysServicesQuestion); - if (row > 0) { - // 设置未读 - SysServicesQuestion status = new SysServicesQuestion(); - status.setRead(0); - status.setQueId(sysServicesQuestion.getQueId()); - status.setRole(sysServicesQuestion.getRole()); - servicesQuestionMapper.updateSysServicesQuestionStatus(status); - } - return row; - } - - @Override - public List<SysServicesQuestion> selectSysServicesQuestionSessionByQueId(String queId) { - return servicesQuestionMapper.selectSysServicesQuestionSessionByQueId(queId); - } -} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysServicesTopicServiceImp.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysServicesTopicServiceImp.java index a66a0b3dd..dcecfdd49 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysServicesTopicServiceImp.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysServicesTopicServiceImp.java @@ -36,33 +36,33 @@ public class SysServicesTopicServiceImp implements ISysServicesTopicService { servicesTopicMapper.insertSysServicesTopic(topic); - SysCustomer customer = sysCustomerMapper.selectSysCustomerById(topic.getUid()); + SysCustomer customer = sysCustomerMapper.selectSysCustomerById(Long.parseLong(topic.getUid())); List<SysServicesTopic> statusList = new ArrayList<>(); SysServicesTopic customerStatus = new SysServicesTopic(); - customerStatus.setUid(customer.getId()); + customerStatus.setUid(String.valueOf(customer.getId())); customerStatus.setRole("customer"); customerStatus.setRead(1); customerStatus.setTopicId(topic.getTopicId()); statusList.add(customerStatus); SysServicesTopic dieticianStatus = new SysServicesTopic(); - dieticianStatus.setUid(customer.getMainDietitian()); + dieticianStatus.setUid(String.valueOf(customer.getMainDietitian())); dieticianStatus.setRole("dietician"); dieticianStatus.setRead(0); dieticianStatus.setTopicId(topic.getTopicId()); statusList.add(dieticianStatus); SysServicesTopic afterSaleStatus = new SysServicesTopic(); - afterSaleStatus.setUid(customer.getAfterDietitian()); + afterSaleStatus.setUid(String.valueOf(customer.getAfterDietitian())); afterSaleStatus.setRole("after_sale"); afterSaleStatus.setRead(0); afterSaleStatus.setTopicId(topic.getTopicId()); statusList.add(afterSaleStatus); SysServicesTopic dieticianAssistantStatus = new SysServicesTopic(); - dieticianAssistantStatus.setUid(customer.getAssistantDietitian()); + dieticianAssistantStatus.setUid(String.valueOf(customer.getAssistantDietitian())); dieticianAssistantStatus.setRole("dietician_assistant"); dieticianAssistantStatus.setRead(0); dieticianAssistantStatus.setTopicId(topic.getTopicId()); diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysServicesQuestionMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysServicesQuestionMapper.xml deleted file mode 100644 index 964e6d196..000000000 --- a/stdiet-custom/src/main/resources/mapper/custom/SysServicesQuestionMapper.xml +++ /dev/null @@ -1,159 +0,0 @@ -<?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.SysServicesQuestionMapper"> - - <resultMap type="SysServicesQuestion" id="SysServicesQuestionResult"> - <result column="id" property="id"/> - <result column="que_id" property="queId"/> - <result column="content" property="content"/> - <result column="role" property="role"/> - <result column="name" property="name"/> - <result column="type" property="type"/> - <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="selectSysServicesQuestionByUserIdAndRole" parameterType="SysServicesQuestion" - resultMap="SysServicesQuestionResult"> - SELECT * FROM ( - SELECT * FROM sys_services_question_status WHERE role = #{role} AND user_id = #{userId} - ) AS status - LEFT JOIN sys_services_question USING(que_id) - <choose> - <when test="role == 'customer'"> - LEFT JOIN ( - SELECT name, id AS user_id FROM sys_customer WHERE id = #{userId} - ) AS customer USING(user_id) - </when> - <otherwise> - LEFT JOIN ( - SELECT role_key, sys_role.role_id, sys_user_role.user_id, sys_user.nick_name AS name FROM sys_role - INNER JOIN sys_user_role USING(role_id) - INNER JOIN sys_user USING(user_id) - WHERE role_key = #{role} AND user_id = #{userId} - ) AS user USING(user_id) - </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> \ No newline at end of file diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysServicesTopicMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysServicesTopicMapper.xml index d309926c4..947d75729 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysServicesTopicMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysServicesTopicMapper.xml @@ -40,7 +40,6 @@ </select> <!-- 查询主题--> - <resultMap id="SysServicesTopicSessionResult" type="SysServicesTopic"> <result column="id" property="id"/> <result column="uid" property="uid"/> @@ -50,7 +49,7 @@ <result column="img" property="img" typeHandler="com.stdiet.custom.typehandler.ArrayJsonHandler"/> <result column="create_time" property="createTime"/> <association property="name" column="{uid=uid,role=role}" select="selectUserInfo"/> - <collection property="comments" column="topic_id" select="selectServicesTopicCommentByTopicId"/> + <association property="comments" column="topic_id" select="selectServicesTopicCommentByTopicId"/> </resultMap> <resultMap id="ServicesTopicCommentResult" type="SysServicesTopic"> @@ -65,25 +64,27 @@ <result column="create_time" property="createTime"/> <association property="fromName" column="{uid=from_uid,role=from_role}" select="selectUserInfo"/> <association property="toName" column="{uid=to_uid,role=to_role}" select="selectUserInfo"/> - <collection property="replys" column="id" ofType="ServicesTopicCommentReplyResult" - select="selectServicesTopicCommentReplyByCommentId"/> + <association property="replys" column="id" + select="selectServicesTopicCommentReplyByCommentId"/> </resultMap> <resultMap id="ServicesTopicCommentReplyResult" type="SysServicesTopic"> <result column="id" property="id"/> <result column="topic_id" property="topicId"/> + <result column="comment_id" property="commentId"/> <result column="content" property="content"/> <result column="from_uid" property="fromUid"/> <result column="from_role" property="fromRole"/> <result column="to_uid" property="toUid"/> <result column="to_role" property="toRole"/> + <result column="reply_id" property="replyId"/> <result column="img" property="img" typeHandler="com.stdiet.custom.typehandler.ArrayJsonHandler"/> <result column="create_time" property="createTime"/> <association property="fromName" column="{uid=from_uid,role=from_role}" select="selectUserInfo"/> <association property="toName" column="{uid=to_uid,role=to_role}" select="selectUserInfo"/> - </resultMap> + <select id="selectSysServicesTopicSessionByTopicId" resultMap="SysServicesTopicSessionResult" parameterType="String"> select topic_id, uid, 'customer' as role, content, img, create_time from sys_services_topic where topic_id = #{topicId} @@ -94,11 +95,7 @@ </select> <select id="selectServicesTopicCommentReplyByCommentId" resultMap="ServicesTopicCommentReplyResult"> - select * from sys_services_topic_reply where reply_type = 0 and reply_id = #{id} - </select> - - <select id="selectServicesTopicCommentReplyReplyByCommentId" resultMap="ServicesTopicCommentReplyResult"> - select * from sys_services_topic_reply where reply_type = 1 and reply_id = #{id} + select * from sys_services_topic_reply where comment_id = #{id} order by create_time asc </select> @@ -202,7 +199,7 @@ </insert> <!-- 插入问题回复--> - <insert id="inserSysServicesTopicReply" parameterType="SysServicesQuestion" useGeneratedKeys="true" keyColumn="id" + <insert id="inserSysServicesTopicReply" parameterType="SysServicesTopic" useGeneratedKeys="true" keyColumn="id" keyProperty="id"> insert into sys_services_topic_reply <trim prefix="(" suffix=")" suffixOverrides=","> diff --git a/stdiet-framework/src/main/java/com/stdiet/framework/config/properties/DruidProperties.java b/stdiet-framework/src/main/java/com/stdiet/framework/config/properties/DruidProperties.java index cbe94f040..07aaf2739 100644 --- a/stdiet-framework/src/main/java/com/stdiet/framework/config/properties/DruidProperties.java +++ b/stdiet-framework/src/main/java/com/stdiet/framework/config/properties/DruidProperties.java @@ -73,8 +73,8 @@ public class DruidProperties /** 归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。 */ datasource.setTestOnReturn(testOnReturn); - datasource.setRemoveAbandoned(true); - datasource.setRemoveAbandonedTimeout(180); +// datasource.setRemoveAbandoned(true); +// datasource.setRemoveAbandonedTimeout(180); return datasource; } }