接口开发完成
This commit is contained in:
parent
416189781f
commit
ee4f3c29d5
@ -14,13 +14,18 @@ public class SysServiceQuestionController extends BaseController {
|
||||
@Autowired
|
||||
private ISysServicesQuestionService sysServicesQuestionService;
|
||||
|
||||
@PostMapping(value = "/list")
|
||||
@PostMapping("/list")
|
||||
public AjaxResult list(@RequestBody SysServicesQuestion sysServicesQuestion) {
|
||||
return AjaxResult.success(sysServicesQuestionService.selectSysServicesQuestionByUserIdAndRole(sysServicesQuestion));
|
||||
}
|
||||
|
||||
@PutMapping(value = "/updateStatus")
|
||||
public AjaxResult reply(@RequestBody SysServicesQuestion sysServicesQuestion) {
|
||||
@PutMapping("/updateStatus")
|
||||
public AjaxResult status(@RequestBody SysServicesQuestion sysServicesQuestion) {
|
||||
return toAjax(sysServicesQuestionService.updateSysServicesQuestionStatus(sysServicesQuestion));
|
||||
}
|
||||
|
||||
@PostMapping("/reply")
|
||||
public AjaxResult reply(@RequestBody SysServicesQuestion servicesQuestion) {
|
||||
return toAjax(sysServicesQuestionService.inserSysServicesQuestionReply(servicesQuestion));
|
||||
}
|
||||
}
|
||||
|
@ -592,7 +592,7 @@ public class WechatAppletController extends BaseController {
|
||||
return AjaxResult.success(sysRecipesPlanService.updateSysRecipesPlan(info));
|
||||
}
|
||||
|
||||
@GetMapping("/fetchServiceQuestion")
|
||||
@GetMapping("/services/list")
|
||||
public AjaxResult fetchServiceQuestion(@RequestParam String customerId, @RequestParam Integer pageNum, @RequestParam Integer pageSize) {
|
||||
startPage();
|
||||
|
||||
@ -605,6 +605,50 @@ public class WechatAppletController extends BaseController {
|
||||
return AjaxResult.success(iSysServicesQuestionService.selectSysServicesQuestionByUserIdAndRole(servicesQuestion));
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户添加问题
|
||||
* @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 toAjax(iSysServicesQuestionService.insertSysServicesQuestion(servicesQuestion));
|
||||
}
|
||||
|
||||
@GetMapping("/services/reply")
|
||||
public AjaxResult serviceQuestionReply(@RequestParam String queId) {
|
||||
return AjaxResult.success(iSysServicesQuestionService.selectSysServicesQuestionSessionByQueId(queId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置已读
|
||||
* @param id
|
||||
* @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")
|
||||
public AjaxResult replyServiceQuestion(@RequestBody SysServicesQuestion servicesQuestion, @RequestParam String customerId) {
|
||||
Long cusId = StringUtils.isNotEmpty(customerId) ? Long.parseLong(AesUtils.decrypt(customerId)) : 0L;
|
||||
|
||||
servicesQuestion.setRole("customer");
|
||||
servicesQuestion.setUserId(cusId);
|
||||
|
||||
return toAjax(iSysServicesQuestionService.inserSysServicesQuestionReply(servicesQuestion));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.stdiet.custom.domain;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
@ -11,7 +12,7 @@ public class SysServicesQuestion {
|
||||
/**
|
||||
* 问题状态id
|
||||
*/
|
||||
String id;
|
||||
Long id;
|
||||
|
||||
/**
|
||||
* 问题id(搜索用)
|
||||
@ -72,4 +73,6 @@ public class SysServicesQuestion {
|
||||
*/
|
||||
Long userId;
|
||||
|
||||
SysServicesQuestionUserInfo userInfo;
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,11 @@ public interface SysServicesQuestionMapper {
|
||||
|
||||
int insertSysServicesQuestion(SysServicesQuestion servicesQuestion);
|
||||
|
||||
int insertSysServicesQuestionStatus(List<SysServicesQuestion> sysServicesQuestion);
|
||||
int insertSysServicesQuestionStatus(List<SysServicesQuestion> servicesQuestion);
|
||||
|
||||
int updateSysServicesQuestionStatus(SysServicesQuestion sysServicesQuestion);
|
||||
int updateSysServicesQuestionStatus(SysServicesQuestion servicesQuestion);
|
||||
|
||||
int inserSysServicesQuestionReply(SysServicesQuestion servicesQuestion);
|
||||
|
||||
List<SysServicesQuestion> selectSysServicesQuestionSessionByQueId(String queId);
|
||||
}
|
||||
|
@ -11,4 +11,8 @@ public interface ISysServicesQuestionService {
|
||||
int insertSysServicesQuestion(SysServicesQuestion servicesQuestion);
|
||||
|
||||
int updateSysServicesQuestionStatus(SysServicesQuestion sysServicesQuestion);
|
||||
|
||||
int inserSysServicesQuestionReply(SysServicesQuestion sysServicesQuestion);
|
||||
|
||||
List<SysServicesQuestion> selectSysServicesQuestionSessionByQueId(String queId);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.stdiet.custom.service.impl;
|
||||
|
||||
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;
|
||||
@ -26,6 +27,9 @@ public class SysServicesQuestionServiceImp implements ISysServicesQuestionServic
|
||||
|
||||
@Override
|
||||
public int insertSysServicesQuestion(SysServicesQuestion servicesQuestion) {
|
||||
// 生成uuid
|
||||
servicesQuestion.setQueId(UUID.randomUUID().toString().replaceAll("-", ""));
|
||||
|
||||
servicesQuestionMapper.insertSysServicesQuestion(servicesQuestion);
|
||||
|
||||
SysCustomer customer = sysCustomerMapper.selectSysCustomerById(servicesQuestion.getCusId());
|
||||
@ -34,25 +38,29 @@ public class SysServicesQuestionServiceImp implements ISysServicesQuestionServic
|
||||
SysServicesQuestion customerStatus = new SysServicesQuestion();
|
||||
customerStatus.setUserId(customer.getId());
|
||||
customerStatus.setRole("customer");
|
||||
customerStatus.setQueId(servicesQuestion.getId());
|
||||
customerStatus.setRead(1);
|
||||
customerStatus.setQueId(servicesQuestion.getQueId());
|
||||
statusList.add(customerStatus);
|
||||
|
||||
SysServicesQuestion dieticianStatus = new SysServicesQuestion();
|
||||
dieticianStatus.setUserId(customer.getMainDietitian());
|
||||
dieticianStatus.setRole("dietician");
|
||||
dieticianStatus.setQueId(servicesQuestion.getId());
|
||||
customerStatus.setRead(0);
|
||||
dieticianStatus.setQueId(servicesQuestion.getQueId());
|
||||
statusList.add(dieticianStatus);
|
||||
|
||||
SysServicesQuestion afterSaleStatus = new SysServicesQuestion();
|
||||
afterSaleStatus.setUserId(customer.getAfterDietitian());
|
||||
afterSaleStatus.setRole("after_sale");
|
||||
afterSaleStatus.setQueId(servicesQuestion.getId());
|
||||
customerStatus.setRead(0);
|
||||
afterSaleStatus.setQueId(servicesQuestion.getQueId());
|
||||
statusList.add(afterSaleStatus);
|
||||
|
||||
SysServicesQuestion dieticianAssistantStatus = new SysServicesQuestion();
|
||||
dieticianAssistantStatus.setUserId(customer.getAssistantDietitian());
|
||||
dieticianAssistantStatus.setRole("dietician_assistant");
|
||||
dieticianAssistantStatus.setQueId(servicesQuestion.getId());
|
||||
customerStatus.setRead(0);
|
||||
dieticianAssistantStatus.setQueId(servicesQuestion.getQueId());
|
||||
statusList.add(dieticianAssistantStatus);
|
||||
|
||||
return servicesQuestionMapper.insertSysServicesQuestionStatus(statusList);
|
||||
@ -63,4 +71,23 @@ public class SysServicesQuestionServiceImp implements ISysServicesQuestionServic
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,15 @@
|
||||
<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">
|
||||
@ -42,42 +51,109 @@
|
||||
ORDER BY type 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="id">
|
||||
<insert id="insertSysServicesQuestion" parameterType="SysServicesQuestion" useGeneratedKeys="true"
|
||||
keyProperty="queId" keyColumn="que_id">
|
||||
insert into sys_services_question
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
id,
|
||||
<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="cusId != null">create_time,</if>
|
||||
<if test="img != null">img,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
replace(uuid(), '-', ''),
|
||||
<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="cusId != null">now(),</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">
|
||||
insert into sys_services_question (que_id, user_id, role, create_time, update_time) values
|
||||
insert into sys_services_question_status (que_id, user_id, role, create_time, update_time) values
|
||||
<foreach collection="list" item="status" index="index" separator=",">
|
||||
(#{status.queId}, #{status.userId}, #{status.role}, now(), now())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 根据状态id更新-->
|
||||
<!-- 根据状态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>
|
||||
<if test="read != null">`read` = #{read},</if>
|
||||
<if test="read != null">update_time = now(),</if>
|
||||
</trim>
|
||||
where id = ${id}
|
||||
<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" useGeneratedKeys="true"
|
||||
keyProperty="id" keyColumn="id">
|
||||
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>
|
Loading…
x
Reference in New Issue
Block a user