修复翻页
This commit is contained in:
parent
836f328c09
commit
8d7417f77e
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
}
|
@ -35,11 +35,11 @@ public class SysServicesTopic {
|
||||
/**
|
||||
* 角色
|
||||
*/
|
||||
Long uid;
|
||||
String uid;
|
||||
|
||||
Long fromUid;
|
||||
String fromUid;
|
||||
|
||||
Long toUid;
|
||||
String toUid;
|
||||
|
||||
/**
|
||||
* 问题内容
|
||||
|
@ -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);
|
||||
}
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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());
|
||||
|
@ -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>
|
@ -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=",">
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user