Merge branch 'develop' of https://gitee.com/darlk/ShengTangManage into xzj
This commit is contained in:
commit
01fd29f2ec
@ -2,11 +2,15 @@ package com.stdiet.web.controller.custom;
|
|||||||
|
|
||||||
import com.stdiet.common.core.controller.BaseController;
|
import com.stdiet.common.core.controller.BaseController;
|
||||||
import com.stdiet.common.core.domain.AjaxResult;
|
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.domain.SysServicesQuestion;
|
||||||
import com.stdiet.custom.service.ISysServicesQuestionService;
|
import com.stdiet.custom.service.ISysServicesQuestionService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/services/question")
|
@RequestMapping("/services/question")
|
||||||
public class SysServiceQuestionController extends BaseController {
|
public class SysServiceQuestionController extends BaseController {
|
||||||
@ -14,18 +18,38 @@ public class SysServiceQuestionController extends BaseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ISysServicesQuestionService sysServicesQuestionService;
|
private ISysServicesQuestionService sysServicesQuestionService;
|
||||||
|
|
||||||
@PostMapping("/list")
|
@GetMapping("/list")
|
||||||
public AjaxResult list(@RequestBody SysServicesQuestion sysServicesQuestion) {
|
public TableDataInfo list(SysServicesQuestion sysServicesQuestion) {
|
||||||
return AjaxResult.success(sysServicesQuestionService.selectSysServicesQuestionByUserIdAndRole(sysServicesQuestion));
|
startPage();
|
||||||
|
return getDataTable(sysServicesQuestionService.selectSysServicesQuestionByUserIdAndRole(sysServicesQuestion));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/updateStatus")
|
// @PutMapping("/update/status")
|
||||||
public AjaxResult status(@RequestBody SysServicesQuestion sysServicesQuestion) {
|
// public AjaxResult status(@RequestBody SysServicesQuestion sysServicesQuestion) {
|
||||||
return toAjax(sysServicesQuestionService.updateSysServicesQuestionStatus(sysServicesQuestion));
|
// return toAjax(sysServicesQuestionService.updateSysServicesQuestionStatus(sysServicesQuestion));
|
||||||
}
|
// }
|
||||||
|
|
||||||
@PostMapping("/reply")
|
@PostMapping("/reply")
|
||||||
public AjaxResult reply(@RequestBody SysServicesQuestion servicesQuestion) {
|
public AjaxResult reply(@RequestBody SysServicesQuestion servicesQuestion) {
|
||||||
return toAjax(sysServicesQuestionService.inserSysServicesQuestionReply(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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
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.SysServicesTopic;
|
||||||
|
import com.stdiet.custom.service.ISysServicesTopicService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/services/topic")
|
||||||
|
public class SysServiceTopicController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysServicesTopicService servicesTopicService;
|
||||||
|
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(SysServicesTopic topic) {
|
||||||
|
startPage();
|
||||||
|
return getDataTable(servicesTopicService.selectSysServicesTopicByUserIdAndRole(topic));
|
||||||
|
}
|
||||||
|
|
||||||
|
// @PutMapping("/update/status")
|
||||||
|
// public AjaxResult status(@RequestBody SysServicesQuestion sysServicesQuestion) {
|
||||||
|
// return toAjax(sysServicesQuestionService.updateSysServicesQuestionStatus(sysServicesQuestion));
|
||||||
|
// }
|
||||||
|
|
||||||
|
@PostMapping("/reply")
|
||||||
|
public AjaxResult reply(@RequestBody SysServicesTopic topic) {
|
||||||
|
return AjaxResult.success(servicesTopicService.inserSysServicesTopicReply(topic));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/comment")
|
||||||
|
public AjaxResult comment(@RequestBody SysServicesTopic topic) {
|
||||||
|
return AjaxResult.success(servicesTopicService.inserSysServicesTopicComment(topic));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/detail")
|
||||||
|
public AjaxResult detail(@RequestParam String topicId, @RequestParam String id) {
|
||||||
|
List<SysServicesTopic> questions = servicesTopicService.selectSysServicesTopicSessionByTopicId(topicId);
|
||||||
|
if (StringUtils.isNotNull(questions)) {
|
||||||
|
// 更新问题对应角色的状态
|
||||||
|
SysServicesTopic status = new SysServicesTopic();
|
||||||
|
status.setRead(1);
|
||||||
|
status.setId(id);
|
||||||
|
servicesTopicService.updateSysServicesTopicStatus(status);
|
||||||
|
}
|
||||||
|
return AjaxResult.success(questions);
|
||||||
|
}
|
||||||
|
}
|
@ -70,6 +70,8 @@ public class WechatAppletController extends BaseController {
|
|||||||
private IWechatAppletService iWechatAppletService;
|
private IWechatAppletService iWechatAppletService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysServicesQuestionService iSysServicesQuestionService;
|
private ISysServicesQuestionService iSysServicesQuestionService;
|
||||||
|
@Autowired
|
||||||
|
private ISysServicesTopicService iSysServicesTopicService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询微信小程序中展示的客户案例
|
* 查询微信小程序中展示的客户案例
|
||||||
@ -593,7 +595,7 @@ public class WechatAppletController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/services/list")
|
@GetMapping("/services/list")
|
||||||
public AjaxResult fetchServiceQuestion(@RequestParam String customerId, @RequestParam Integer pageNum, @RequestParam Integer pageSize) {
|
public TableDataInfo fetchServiceQuestion(@RequestParam String customerId, @RequestParam Integer pageNum, @RequestParam Integer pageSize) {
|
||||||
startPage();
|
startPage();
|
||||||
|
|
||||||
Long cusId = StringUtils.isNotEmpty(customerId) ? Long.parseLong(AesUtils.decrypt(customerId)) : 0L;
|
Long cusId = StringUtils.isNotEmpty(customerId) ? Long.parseLong(AesUtils.decrypt(customerId)) : 0L;
|
||||||
@ -602,11 +604,30 @@ public class WechatAppletController extends BaseController {
|
|||||||
servicesQuestion.setRole("customer");
|
servicesQuestion.setRole("customer");
|
||||||
servicesQuestion.setUserId(cusId);
|
servicesQuestion.setUserId(cusId);
|
||||||
|
|
||||||
return AjaxResult.success(iSysServicesQuestionService.selectSysServicesQuestionByUserIdAndRole(servicesQuestion));
|
return getDataTable(iSysServicesQuestionService.selectSysServicesQuestionByUserIdAndRole(servicesQuestion));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户添加问题
|
* 客户添加问题
|
||||||
|
*
|
||||||
|
* @param topic
|
||||||
|
* @param customerId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@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) {
|
||||||
|
return toAjax(0);
|
||||||
|
}
|
||||||
|
topic.setUid(cusId);
|
||||||
|
|
||||||
|
return AjaxResult.success(iSysServicesTopicService.insertSysServicesTopic(topic));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户添加问题
|
||||||
|
*
|
||||||
* @param servicesQuestion
|
* @param servicesQuestion
|
||||||
* @param customerId
|
* @param customerId
|
||||||
* @return
|
* @return
|
||||||
@ -614,42 +635,69 @@ public class WechatAppletController extends BaseController {
|
|||||||
@PostMapping("/services/post")
|
@PostMapping("/services/post")
|
||||||
public AjaxResult postServiceQuestion(@RequestBody SysServicesQuestion servicesQuestion, @RequestParam String customerId) {
|
public AjaxResult postServiceQuestion(@RequestBody SysServicesQuestion servicesQuestion, @RequestParam String customerId) {
|
||||||
Long cusId = StringUtils.isNotEmpty(customerId) ? Long.parseLong(AesUtils.decrypt(customerId)) : 0L;
|
Long cusId = StringUtils.isNotEmpty(customerId) ? Long.parseLong(AesUtils.decrypt(customerId)) : 0L;
|
||||||
if(cusId == 0L) {
|
if (cusId == 0L) {
|
||||||
return toAjax(0);
|
return toAjax(0);
|
||||||
}
|
}
|
||||||
servicesQuestion.setCusId(cusId);
|
servicesQuestion.setCusId(cusId);
|
||||||
return toAjax(iSysServicesQuestionService.insertSysServicesQuestion(servicesQuestion));
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/services/reply")
|
return AjaxResult.success(iSysServicesQuestionService.insertSysServicesQuestion(servicesQuestion));
|
||||||
public AjaxResult serviceQuestionReply(@RequestParam String queId) {
|
|
||||||
return AjaxResult.success(iSysServicesQuestionService.selectSysServicesQuestionSessionByQueId(queId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置已读
|
* 回答问题
|
||||||
* @param id
|
*
|
||||||
|
* @param servicesQuestion
|
||||||
|
* @param customerId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/services/post/update")
|
|
||||||
public AjaxResult updateServiceQuestion(@RequestParam Long id) {
|
|
||||||
SysServicesQuestion servicesQuestion = new SysServicesQuestion();
|
|
||||||
servicesQuestion.setRead(1);
|
|
||||||
servicesQuestion.setId(id);
|
|
||||||
|
|
||||||
return toAjax(iSysServicesQuestionService.updateSysServicesQuestionStatus(servicesQuestion));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/services/post/reply")
|
@PostMapping("/services/post/reply")
|
||||||
public AjaxResult replyServiceQuestion(@RequestBody SysServicesQuestion servicesQuestion, @RequestParam String customerId) {
|
public AjaxResult replyServiceQuestion(@RequestBody SysServicesQuestion servicesQuestion, @RequestParam String customerId) {
|
||||||
Long cusId = StringUtils.isNotEmpty(customerId) ? Long.parseLong(AesUtils.decrypt(customerId)) : 0L;
|
Long cusId = StringUtils.isNotEmpty(customerId) ? Long.parseLong(AesUtils.decrypt(customerId)) : 0L;
|
||||||
|
if (cusId == 0L) {
|
||||||
|
return toAjax(0);
|
||||||
|
}
|
||||||
servicesQuestion.setRole("customer");
|
servicesQuestion.setRole("customer");
|
||||||
servicesQuestion.setUserId(cusId);
|
servicesQuestion.setUserId(cusId);
|
||||||
|
|
||||||
return toAjax(iSysServicesQuestionService.inserSysServicesQuestionReply(servicesQuestion));
|
int row = iSysServicesQuestionService.inserSysServicesQuestionReply(servicesQuestion);
|
||||||
|
if (row > 0) {
|
||||||
|
// 更新三个觉得未读,id不能有值
|
||||||
|
servicesQuestion.setRead(0);
|
||||||
|
iSysServicesQuestionService.updateSysServicesQuestionStatus(servicesQuestion);
|
||||||
|
}
|
||||||
|
|
||||||
|
return toAjax(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取问题详情
|
||||||
|
*
|
||||||
|
* @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();
|
||||||
|
status.setId(id);
|
||||||
|
status.setRead(1);
|
||||||
|
iSysServicesQuestionService.updateSysServicesQuestionStatus(status);
|
||||||
|
}
|
||||||
|
return AjaxResult.success(questions);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// @GetMapping("/services/post/update")
|
||||||
|
// public AjaxResult updateServiceQuestion(@RequestParam Long id) {
|
||||||
|
// SysServicesQuestion servicesQuestion = new SysServicesQuestion();
|
||||||
|
// servicesQuestion.setRead(1);
|
||||||
|
// servicesQuestion.setId(id);
|
||||||
|
//
|
||||||
|
// return toAjax(iSysServicesQuestionService.updateSysServicesQuestionStatus(servicesQuestion));
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,12 +1,5 @@
|
|||||||
package com.stdiet.common.core.controller;
|
package com.stdiet.common.core.controller;
|
||||||
|
|
||||||
import java.beans.PropertyEditorSupport;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.web.bind.WebDataBinder;
|
|
||||||
import org.springframework.web.bind.annotation.InitBinder;
|
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.stdiet.common.constant.HttpStatus;
|
import com.stdiet.common.constant.HttpStatus;
|
||||||
@ -17,28 +10,33 @@ import com.stdiet.common.core.page.TableSupport;
|
|||||||
import com.stdiet.common.utils.DateUtils;
|
import com.stdiet.common.utils.DateUtils;
|
||||||
import com.stdiet.common.utils.StringUtils;
|
import com.stdiet.common.utils.StringUtils;
|
||||||
import com.stdiet.common.utils.sql.SqlUtil;
|
import com.stdiet.common.utils.sql.SqlUtil;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.bind.WebDataBinder;
|
||||||
|
import org.springframework.web.bind.annotation.InitBinder;
|
||||||
|
|
||||||
|
import java.beans.PropertyEditorSupport;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* web层通用数据处理
|
* web层通用数据处理
|
||||||
*
|
*
|
||||||
* @author stdiet
|
* @author stdiet
|
||||||
*/
|
*/
|
||||||
public class BaseController
|
public class BaseController {
|
||||||
{
|
|
||||||
protected final Logger logger = LoggerFactory.getLogger(BaseController.class);
|
protected final Logger logger = LoggerFactory.getLogger(BaseController.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
|
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
|
||||||
*/
|
*/
|
||||||
@InitBinder
|
@InitBinder
|
||||||
public void initBinder(WebDataBinder binder)
|
public void initBinder(WebDataBinder binder) {
|
||||||
{
|
|
||||||
// Date 类型转换
|
// Date 类型转换
|
||||||
binder.registerCustomEditor(Date.class, new PropertyEditorSupport()
|
binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public void setAsText(String text)
|
public void setAsText(String text) {
|
||||||
{
|
|
||||||
setValue(DateUtils.parseDate(text));
|
setValue(DateUtils.parseDate(text));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -47,13 +45,11 @@ public class BaseController
|
|||||||
/**
|
/**
|
||||||
* 设置请求分页数据
|
* 设置请求分页数据
|
||||||
*/
|
*/
|
||||||
protected void startPage()
|
protected void startPage() {
|
||||||
{
|
|
||||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
Integer pageNum = pageDomain.getPageNum();
|
Integer pageNum = pageDomain.getPageNum();
|
||||||
Integer pageSize = pageDomain.getPageSize();
|
Integer pageSize = pageDomain.getPageSize();
|
||||||
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
|
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
|
||||||
{
|
|
||||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||||
PageHelper.startPage(pageNum, pageSize, orderBy);
|
PageHelper.startPage(pageNum, pageSize, orderBy);
|
||||||
}
|
}
|
||||||
@ -62,33 +58,37 @@ public class BaseController
|
|||||||
/**
|
/**
|
||||||
* 响应请求分页数据
|
* 响应请求分页数据
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
protected TableDataInfo getDataTable(List<?> list)
|
protected TableDataInfo getDataTable(List<?> list) {
|
||||||
{
|
|
||||||
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
|
Integer pageNum = pageDomain.getPageNum();
|
||||||
|
Integer pageSize = pageDomain.getPageSize();
|
||||||
|
|
||||||
|
long total = new PageInfo(list).getTotal();
|
||||||
|
|
||||||
TableDataInfo rspData = new TableDataInfo();
|
TableDataInfo rspData = new TableDataInfo();
|
||||||
rspData.setCode(HttpStatus.SUCCESS);
|
rspData.setCode(HttpStatus.SUCCESS);
|
||||||
rspData.setMsg("查询成功");
|
rspData.setMsg("查询成功");
|
||||||
rspData.setRows(list);
|
rspData.setRows(total > pageSize * (pageNum - 1) ? list : new ArrayList<>());
|
||||||
rspData.setTotal(new PageInfo(list).getTotal());
|
rspData.setTotal(total);
|
||||||
return rspData;
|
return rspData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 响应返回结果
|
* 响应返回结果
|
||||||
*
|
*
|
||||||
* @param rows 影响行数
|
* @param rows 影响行数
|
||||||
* @return 操作结果
|
* @return 操作结果
|
||||||
*/
|
*/
|
||||||
protected AjaxResult toAjax(int rows)
|
protected AjaxResult toAjax(int rows) {
|
||||||
{
|
|
||||||
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
|
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页面跳转
|
* 页面跳转
|
||||||
*/
|
*/
|
||||||
public String redirect(String url)
|
public String redirect(String url) {
|
||||||
{
|
|
||||||
return StringUtils.format("redirect:{}", url);
|
return StringUtils.format("redirect:{}", url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,92 @@
|
|||||||
|
package com.stdiet.custom.domain;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public class SysServicesTopic {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 问题id
|
||||||
|
*/
|
||||||
|
String topicId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 问题类型
|
||||||
|
*/
|
||||||
|
Integer topicType;
|
||||||
|
|
||||||
|
String commentId;
|
||||||
|
|
||||||
|
String replyId;
|
||||||
|
|
||||||
|
Integer replyType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色
|
||||||
|
*/
|
||||||
|
Long uid;
|
||||||
|
|
||||||
|
Long fromUid;
|
||||||
|
|
||||||
|
Long toUid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 问题内容
|
||||||
|
*/
|
||||||
|
String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片地址
|
||||||
|
*/
|
||||||
|
JSONArray img;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@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 fromRole;
|
||||||
|
|
||||||
|
String toRole;
|
||||||
|
|
||||||
|
// 非持久化字段
|
||||||
|
/**
|
||||||
|
* 角色名字
|
||||||
|
*/
|
||||||
|
String fromName;
|
||||||
|
String toName;
|
||||||
|
String name;
|
||||||
|
|
||||||
|
List<SysServicesTopic> comments;
|
||||||
|
|
||||||
|
List<SysServicesTopic> replys;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.stdiet.custom.mapper;
|
||||||
|
|
||||||
|
import com.stdiet.custom.domain.SysServicesQuestion;
|
||||||
|
import com.stdiet.custom.domain.SysServicesTopic;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface SysServicesTopicMapper {
|
||||||
|
List<SysServicesTopic> selectSysServicesTopicByUserIdAndRole(SysServicesTopic topic);
|
||||||
|
|
||||||
|
int insertSysServicesTopic(SysServicesTopic topic);
|
||||||
|
|
||||||
|
int insertSysServicesTopicStatus(List<SysServicesTopic> topics);
|
||||||
|
|
||||||
|
int updateSysServicesTopicStatus(SysServicesTopic topic);
|
||||||
|
|
||||||
|
int inserSysServicesTopicComment(SysServicesTopic topic);
|
||||||
|
|
||||||
|
int inserSysServicesTopicReply(SysServicesTopic topic);
|
||||||
|
|
||||||
|
List<SysServicesTopic> selectSysServicesTopicSessionByTopicId(String topicId);
|
||||||
|
}
|
@ -8,7 +8,7 @@ public interface ISysServicesQuestionService {
|
|||||||
|
|
||||||
List<SysServicesQuestion> selectSysServicesQuestionByUserIdAndRole(SysServicesQuestion servicesQuestion);
|
List<SysServicesQuestion> selectSysServicesQuestionByUserIdAndRole(SysServicesQuestion servicesQuestion);
|
||||||
|
|
||||||
int insertSysServicesQuestion(SysServicesQuestion servicesQuestion);
|
SysServicesQuestion insertSysServicesQuestion(SysServicesQuestion servicesQuestion);
|
||||||
|
|
||||||
int updateSysServicesQuestionStatus(SysServicesQuestion sysServicesQuestion);
|
int updateSysServicesQuestionStatus(SysServicesQuestion sysServicesQuestion);
|
||||||
|
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.stdiet.custom.service;
|
||||||
|
|
||||||
|
import com.stdiet.custom.domain.SysServicesQuestion;
|
||||||
|
import com.stdiet.custom.domain.SysServicesTopic;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ISysServicesTopicService {
|
||||||
|
|
||||||
|
List<SysServicesTopic> selectSysServicesTopicByUserIdAndRole(SysServicesTopic topic);
|
||||||
|
|
||||||
|
SysServicesTopic insertSysServicesTopic(SysServicesTopic topic);
|
||||||
|
|
||||||
|
int updateSysServicesTopicStatus(SysServicesTopic topic);
|
||||||
|
|
||||||
|
SysServicesTopic inserSysServicesTopicReply(SysServicesTopic topic);
|
||||||
|
|
||||||
|
SysServicesTopic inserSysServicesTopicComment(SysServicesTopic topic);
|
||||||
|
|
||||||
|
List<SysServicesTopic> selectSysServicesTopicSessionByTopicId(String topicId);
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.stdiet.custom.service.impl;
|
package com.stdiet.custom.service.impl;
|
||||||
|
|
||||||
|
import com.stdiet.common.utils.DateUtils;
|
||||||
import com.stdiet.common.utils.uuid.UUID;
|
import com.stdiet.common.utils.uuid.UUID;
|
||||||
import com.stdiet.custom.domain.SysCustomer;
|
import com.stdiet.custom.domain.SysCustomer;
|
||||||
import com.stdiet.custom.domain.SysServicesQuestion;
|
import com.stdiet.custom.domain.SysServicesQuestion;
|
||||||
@ -26,9 +27,11 @@ public class SysServicesQuestionServiceImp implements ISysServicesQuestionServic
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insertSysServicesQuestion(SysServicesQuestion servicesQuestion) {
|
public SysServicesQuestion insertSysServicesQuestion(SysServicesQuestion servicesQuestion) {
|
||||||
// 生成uuid
|
// 生成uuid
|
||||||
servicesQuestion.setQueId(UUID.randomUUID().toString().replaceAll("-", ""));
|
servicesQuestion.setQueId(UUID.randomUUID().toString().replaceAll("-", ""));
|
||||||
|
servicesQuestion.setRead(1);
|
||||||
|
servicesQuestion.setCreateTime(DateUtils.getNowDate());
|
||||||
|
|
||||||
servicesQuestionMapper.insertSysServicesQuestion(servicesQuestion);
|
servicesQuestionMapper.insertSysServicesQuestion(servicesQuestion);
|
||||||
|
|
||||||
@ -45,25 +48,31 @@ public class SysServicesQuestionServiceImp implements ISysServicesQuestionServic
|
|||||||
SysServicesQuestion dieticianStatus = new SysServicesQuestion();
|
SysServicesQuestion dieticianStatus = new SysServicesQuestion();
|
||||||
dieticianStatus.setUserId(customer.getMainDietitian());
|
dieticianStatus.setUserId(customer.getMainDietitian());
|
||||||
dieticianStatus.setRole("dietician");
|
dieticianStatus.setRole("dietician");
|
||||||
customerStatus.setRead(0);
|
dieticianStatus.setRead(0);
|
||||||
dieticianStatus.setQueId(servicesQuestion.getQueId());
|
dieticianStatus.setQueId(servicesQuestion.getQueId());
|
||||||
statusList.add(dieticianStatus);
|
statusList.add(dieticianStatus);
|
||||||
|
|
||||||
SysServicesQuestion afterSaleStatus = new SysServicesQuestion();
|
SysServicesQuestion afterSaleStatus = new SysServicesQuestion();
|
||||||
afterSaleStatus.setUserId(customer.getAfterDietitian());
|
afterSaleStatus.setUserId(customer.getAfterDietitian());
|
||||||
afterSaleStatus.setRole("after_sale");
|
afterSaleStatus.setRole("after_sale");
|
||||||
customerStatus.setRead(0);
|
afterSaleStatus.setRead(0);
|
||||||
afterSaleStatus.setQueId(servicesQuestion.getQueId());
|
afterSaleStatus.setQueId(servicesQuestion.getQueId());
|
||||||
statusList.add(afterSaleStatus);
|
statusList.add(afterSaleStatus);
|
||||||
|
|
||||||
SysServicesQuestion dieticianAssistantStatus = new SysServicesQuestion();
|
SysServicesQuestion dieticianAssistantStatus = new SysServicesQuestion();
|
||||||
dieticianAssistantStatus.setUserId(customer.getAssistantDietitian());
|
dieticianAssistantStatus.setUserId(customer.getAssistantDietitian());
|
||||||
dieticianAssistantStatus.setRole("dietician_assistant");
|
dieticianAssistantStatus.setRole("dietician_assistant");
|
||||||
customerStatus.setRead(0);
|
dieticianAssistantStatus.setRead(0);
|
||||||
dieticianAssistantStatus.setQueId(servicesQuestion.getQueId());
|
dieticianAssistantStatus.setQueId(servicesQuestion.getQueId());
|
||||||
|
|
||||||
statusList.add(dieticianAssistantStatus);
|
statusList.add(dieticianAssistantStatus);
|
||||||
|
|
||||||
return servicesQuestionMapper.insertSysServicesQuestionStatus(statusList);
|
servicesQuestionMapper.insertSysServicesQuestionStatus(statusList);
|
||||||
|
|
||||||
|
servicesQuestion.setId(customerStatus.getId());
|
||||||
|
servicesQuestion.setCusId(null);
|
||||||
|
|
||||||
|
return servicesQuestion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,121 @@
|
|||||||
|
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.SysServicesTopic;
|
||||||
|
import com.stdiet.custom.mapper.SysCustomerMapper;
|
||||||
|
import com.stdiet.custom.mapper.SysServicesTopicMapper;
|
||||||
|
import com.stdiet.custom.service.ISysServicesTopicService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SysServicesTopicServiceImp implements ISysServicesTopicService {
|
||||||
|
@Autowired
|
||||||
|
SysServicesTopicMapper servicesTopicMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SysCustomerMapper sysCustomerMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysServicesTopic> selectSysServicesTopicByUserIdAndRole(SysServicesTopic topic) {
|
||||||
|
return servicesTopicMapper.selectSysServicesTopicByUserIdAndRole(topic);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysServicesTopic insertSysServicesTopic(SysServicesTopic topic) {
|
||||||
|
// 生成uuid
|
||||||
|
topic.setTopicId(UUID.randomUUID().toString().replaceAll("-", ""));
|
||||||
|
topic.setRead(1);
|
||||||
|
topic.setCreateTime(DateUtils.getNowDate());
|
||||||
|
|
||||||
|
servicesTopicMapper.insertSysServicesTopic(topic);
|
||||||
|
|
||||||
|
SysCustomer customer = sysCustomerMapper.selectSysCustomerById(topic.getUid());
|
||||||
|
|
||||||
|
List<SysServicesTopic> statusList = new ArrayList<>();
|
||||||
|
|
||||||
|
SysServicesTopic customerStatus = new SysServicesTopic();
|
||||||
|
customerStatus.setUid(customer.getId());
|
||||||
|
customerStatus.setRole("customer");
|
||||||
|
customerStatus.setRead(1);
|
||||||
|
customerStatus.setTopicId(topic.getTopicId());
|
||||||
|
statusList.add(customerStatus);
|
||||||
|
|
||||||
|
SysServicesTopic dieticianStatus = new SysServicesTopic();
|
||||||
|
dieticianStatus.setUid(customer.getMainDietitian());
|
||||||
|
dieticianStatus.setRole("dietician");
|
||||||
|
dieticianStatus.setRead(0);
|
||||||
|
dieticianStatus.setTopicId(topic.getTopicId());
|
||||||
|
statusList.add(dieticianStatus);
|
||||||
|
|
||||||
|
SysServicesTopic afterSaleStatus = new SysServicesTopic();
|
||||||
|
afterSaleStatus.setUid(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.setRole("dietician_assistant");
|
||||||
|
dieticianAssistantStatus.setRead(0);
|
||||||
|
dieticianAssistantStatus.setTopicId(topic.getTopicId());
|
||||||
|
statusList.add(dieticianAssistantStatus);
|
||||||
|
|
||||||
|
servicesTopicMapper.insertSysServicesTopicStatus(statusList);
|
||||||
|
|
||||||
|
topic.setId(customerStatus.getId());
|
||||||
|
topic.setUid(null);
|
||||||
|
|
||||||
|
return topic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateSysServicesTopicStatus(SysServicesTopic topic) {
|
||||||
|
return servicesTopicMapper.updateSysServicesTopicStatus(topic);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysServicesTopic inserSysServicesTopicReply(SysServicesTopic topic) {
|
||||||
|
String uuid = java.util.UUID.randomUUID().toString().replace("-", "");
|
||||||
|
topic.setId(uuid);
|
||||||
|
int row = servicesTopicMapper.inserSysServicesTopicReply(topic);
|
||||||
|
if (row > 0) {
|
||||||
|
// 设置未读
|
||||||
|
SysServicesTopic status = new SysServicesTopic();
|
||||||
|
status.setRead(0);
|
||||||
|
status.setTopicId(topic.getTopicId());
|
||||||
|
status.setRole(topic.getRole());
|
||||||
|
servicesTopicMapper.updateSysServicesTopicStatus(status);
|
||||||
|
}
|
||||||
|
return topic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysServicesTopic inserSysServicesTopicComment(SysServicesTopic topic) {
|
||||||
|
String uuid = java.util.UUID.randomUUID().toString().replace("-", "");
|
||||||
|
topic.setId(uuid);
|
||||||
|
int row = servicesTopicMapper.inserSysServicesTopicComment(topic);
|
||||||
|
if (row > 0) {
|
||||||
|
// 设置未读
|
||||||
|
SysServicesTopic status = new SysServicesTopic();
|
||||||
|
status.setRead(0);
|
||||||
|
status.setTopicId(topic.getTopicId());
|
||||||
|
status.setRole(topic.getRole());
|
||||||
|
servicesTopicMapper.updateSysServicesTopicStatus(status);
|
||||||
|
}
|
||||||
|
return topic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysServicesTopic> selectSysServicesTopicSessionByTopicId(String topicId) {
|
||||||
|
return servicesTopicMapper.selectSysServicesTopicSessionByTopicId(topicId);
|
||||||
|
}
|
||||||
|
}
|
@ -48,7 +48,7 @@
|
|||||||
) AS user USING(user_id)
|
) AS user USING(user_id)
|
||||||
</otherwise>
|
</otherwise>
|
||||||
</choose>
|
</choose>
|
||||||
ORDER BY type ASC, update_time DESC
|
ORDER BY `read` ASC, update_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectSysServicesQuestionSessionByQueId" resultMap="SysServicesQuestionSessionResult"
|
<select id="selectSysServicesQuestionSessionByQueId" resultMap="SysServicesQuestionSessionResult"
|
||||||
@ -78,7 +78,7 @@
|
|||||||
<if test="cusId != null">cus_id,</if>
|
<if test="cusId != null">cus_id,</if>
|
||||||
<if test="content != null">content,</if>
|
<if test="content != null">content,</if>
|
||||||
<if test="type != null">type,</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>
|
<if test="img != null">img,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
@ -86,7 +86,7 @@
|
|||||||
<if test="cusId != null">#{cusId},</if>
|
<if test="cusId != null">#{cusId},</if>
|
||||||
<if test="content != null">#{content},</if>
|
<if test="content != null">#{content},</if>
|
||||||
<if test="type != null">#{type},</if>
|
<if test="type != null">#{type},</if>
|
||||||
<if test="cusId != null">now(),</if>
|
<if test="createTime != null">#{createTime},</if>
|
||||||
<if test="img != null">
|
<if test="img != null">
|
||||||
#{img, jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ArrayJsonHandler},
|
#{img, jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ArrayJsonHandler},
|
||||||
</if>
|
</if>
|
||||||
@ -94,10 +94,11 @@
|
|||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<!-- 插入问题的四个角色:1,用户; 2,营养师; 3,售后; 4,助理-->
|
<!-- 插入问题的四个角色:1,用户; 2,营养师; 3,售后; 4,助理-->
|
||||||
<insert id="insertSysServicesQuestionStatus" parameterType="java.util.List">
|
<insert id="insertSysServicesQuestionStatus" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id"
|
||||||
insert into sys_services_question_status (que_id, user_id, role, create_time, update_time) values
|
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=",">
|
<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>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@ -127,8 +128,7 @@
|
|||||||
</update>
|
</update>
|
||||||
|
|
||||||
<!-- 插入问题回复-->
|
<!-- 插入问题回复-->
|
||||||
<insert id="inserSysServicesQuestionReply" parameterType="SysServicesQuestion" useGeneratedKeys="true"
|
<insert id="inserSysServicesQuestionReply" parameterType="SysServicesQuestion">
|
||||||
keyProperty="id" keyColumn="id">
|
|
||||||
insert into sys_services_question_session
|
insert into sys_services_question_session
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="queId != null">que_id,</if>
|
<if test="queId != null">que_id,</if>
|
||||||
|
@ -0,0 +1,240 @@
|
|||||||
|
<?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="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>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 根据userId和角色查询问题列表-->
|
||||||
|
<select id="selectSysServicesTopicByUserIdAndRole" parameterType="SysServicesTopic"
|
||||||
|
resultMap="SysServicesTopicResult">
|
||||||
|
SELECT * FROM (
|
||||||
|
SELECT * FROM sys_services_topic_status WHERE role = #{role} AND uid = #{uid}
|
||||||
|
) AS status
|
||||||
|
LEFT JOIN sys_services_topic USING(topic_id)
|
||||||
|
<choose>
|
||||||
|
<when test="role == 'customer'">
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT name, id AS uid FROM sys_customer WHERE id = #{uid}
|
||||||
|
) AS customer ON status.uid = customer.uid
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT user_id AS uid, nick_name AS name FROM sys_user WHERE user_id = #{uid}
|
||||||
|
) AS user ON status.uid = user.uid
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
ORDER BY `read` ASC, update_time DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 查询主题-->
|
||||||
|
|
||||||
|
<resultMap id="SysServicesTopicSessionResult" type="SysServicesTopic">
|
||||||
|
<result column="id" property="id"/>
|
||||||
|
<result column="uid" property="uid"/>
|
||||||
|
<result column="topic_id" property="topicId"/>
|
||||||
|
<result column="topic_type" property="topicType"/>
|
||||||
|
<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="{uid=uid,role=role}" select="selectUserInfo"/>
|
||||||
|
<collection property="comments" column="topic_id" select="selectServicesTopicCommentByTopicId"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<resultMap id="ServicesTopicCommentResult" type="SysServicesTopic">
|
||||||
|
<result column="id" property="id"/>
|
||||||
|
<result column="topic_id" property="topicId"/>
|
||||||
|
<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="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"/>
|
||||||
|
<collection property="replys" column="id" ofType="ServicesTopicCommentReplyResult"
|
||||||
|
select="selectServicesTopicCommentReplyByCommentId"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<resultMap id="ServicesTopicCommentReplyResult" type="SysServicesTopic">
|
||||||
|
<result column="id" property="id"/>
|
||||||
|
<result column="topic_id" property="topicId"/>
|
||||||
|
<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="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}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectServicesTopicCommentByTopicId" resultMap="ServicesTopicCommentResult">
|
||||||
|
select * from sys_services_topic_comment where topic_id = #{topic_id}
|
||||||
|
</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>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 查询人名-->
|
||||||
|
<select id="selectUserInfo" parameterType="java.util.Map" resultType="String">
|
||||||
|
<choose>
|
||||||
|
<when test="_parameter.get('role') == 'customer'">
|
||||||
|
select name from sys_customer where id = #{uid}
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
select nick_name from sys_user where user_id = #{uid}
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 插入问题-->
|
||||||
|
<insert id="insertSysServicesTopic" parameterType="SysServicesTopic" useGeneratedKeys="true"
|
||||||
|
keyProperty="id" keyColumn="id">
|
||||||
|
insert into sys_services_topic
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="topicId != null">topic_id,</if>
|
||||||
|
<if test="uid != null">uid,</if>
|
||||||
|
<if test="content != null">content,</if>
|
||||||
|
<if test="topicType != null">topic_type,</if>
|
||||||
|
<if test="createTime != null">create_time,</if>
|
||||||
|
<if test="img != null">img,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="topicId != null">#{topicId},</if>
|
||||||
|
<if test="uid != null">#{uid},</if>
|
||||||
|
<if test="content != null">#{content},</if>
|
||||||
|
<if test="topicType != null">#{topicType},</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="insertSysServicesTopicStatus" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id"
|
||||||
|
keyColumn="id">
|
||||||
|
insert into sys_services_topic_status (topic_id, uid, role, `read`, create_time, update_time) values
|
||||||
|
<foreach collection="list" item="status" index="index" separator=",">
|
||||||
|
(#{status.topicId}, #{status.uid}, #{status.role}, #{status.read}, now(), now())
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 根据状态id更新, role=customer 客户回复,这时更新另外三个角色未读;role != customer,更新客户未读-->
|
||||||
|
<update id="updateSysServicesTopicStatus" parameterType="SysServicesTopic">
|
||||||
|
update sys_services_topic_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>
|
||||||
|
topic_id = #{topicId}
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</where>
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 插入问题回复-->
|
||||||
|
<insert id="inserSysServicesTopicComment" parameterType="SysServicesTopic">
|
||||||
|
insert into sys_services_topic_comment
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="id != null">id,</if>
|
||||||
|
<if test="topicId != null">topic_id,</if>
|
||||||
|
<if test="fromUid != null">from_uid,</if>
|
||||||
|
<if test="fromRole != null">from_role,</if>
|
||||||
|
<if test="toUid != null">to_uid,</if>
|
||||||
|
<if test="toRole != null">to_role,</if>
|
||||||
|
<if test="content != null">content,</if>
|
||||||
|
<if test="img != null">img,</if>
|
||||||
|
<if test="topicId != null">create_time,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="id != null">#{id},</if>
|
||||||
|
<if test="topicId != null">#{topicId},</if>
|
||||||
|
<if test="fromUid != null">#{fromUid},</if>
|
||||||
|
<if test="fromRole != null">#{fromRole},</if>
|
||||||
|
<if test="toUid != null">#{toUid},</if>
|
||||||
|
<if test="toRole != null">#{toRole},</if>
|
||||||
|
<if test="content != null">#{content},</if>
|
||||||
|
<if test="img != null">
|
||||||
|
#{img, jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ArrayJsonHandler},
|
||||||
|
</if>
|
||||||
|
<if test="topicId != null">now(),</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 插入问题回复-->
|
||||||
|
<insert id="inserSysServicesTopicReply" parameterType="SysServicesQuestion" useGeneratedKeys="true" keyColumn="id"
|
||||||
|
keyProperty="id">
|
||||||
|
insert into sys_services_topic_reply
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="id != null">id,</if>
|
||||||
|
<if test="commentId != null">comment_id,</if>
|
||||||
|
<if test="replyId != null">reply_id,</if>
|
||||||
|
<if test="replyType != null">reply_type,</if>
|
||||||
|
<if test="content != null">content,</if>
|
||||||
|
<if test="fromUid != null">from_uid,</if>
|
||||||
|
<if test="toUid != null">to_uid,</if>
|
||||||
|
<if test="img != null">img,</if>
|
||||||
|
<if test="fromRole != null">from_role,</if>
|
||||||
|
<if test="toRole != null">to_role,</if>
|
||||||
|
<if test="content != null">create_time,</if>
|
||||||
|
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="id != null">#{id},</if>
|
||||||
|
<if test="commentId != null">#{commentId},</if>
|
||||||
|
<if test="replyId != null">#{replyId},</if>
|
||||||
|
<if test="replyType != null">#{replyType},</if>
|
||||||
|
<if test="content != null">#{content},</if>
|
||||||
|
<if test="fromUid != null">#{fromUid},</if>
|
||||||
|
<if test="toUid != null">#{toUid},</if>
|
||||||
|
<if test="img != null">
|
||||||
|
#{img, jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ArrayJsonHandler},
|
||||||
|
</if>
|
||||||
|
<if test="fromRole != null">#{fromRole},</if>
|
||||||
|
<if test="toRole != null">#{toRole},</if>
|
||||||
|
<if test="content != null">now(),</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
@ -72,6 +72,9 @@ public class DruidProperties
|
|||||||
datasource.setTestOnBorrow(testOnBorrow);
|
datasource.setTestOnBorrow(testOnBorrow);
|
||||||
/** 归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。 */
|
/** 归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。 */
|
||||||
datasource.setTestOnReturn(testOnReturn);
|
datasource.setTestOnReturn(testOnReturn);
|
||||||
|
|
||||||
|
datasource.setRemoveAbandoned(true);
|
||||||
|
datasource.setRemoveAbandonedTimeout(180);
|
||||||
return datasource;
|
return datasource;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user