WeCommunityH5Controller.java 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. package com.linkwechat.controller;
  2. import com.linkwechat.common.core.controller.BaseController;
  3. import com.linkwechat.common.core.domain.AjaxResult;
  4. import com.linkwechat.common.core.page.TableDataInfo;
  5. import com.linkwechat.common.enums.MessageNoticeType;
  6. import com.linkwechat.domain.community.WeKeywordGroupTask;
  7. import com.linkwechat.domain.community.vo.WeEmplTaskVo;
  8. import com.linkwechat.service.IWeCommunityKeywordToGroupService;
  9. import com.linkwechat.service.IWeGroupSopService;
  10. import com.linkwechat.service.IWePresTagGroupTaskService;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.web.bind.annotation.*;
  13. import java.util.ArrayList;
  14. import java.util.List;
  15. /**
  16. * 社区运营H5接口
  17. *
  18. * @Author Hang
  19. * @Date 2021/3/24 10:54
  20. */
  21. @RestController
  22. @RequestMapping(value = "/community/h5")
  23. public class WeCommunityH5Controller extends BaseController {
  24. @Autowired
  25. private IWeCommunityKeywordToGroupService keywordToGroupService;
  26. @Autowired
  27. private IWeGroupSopService iWeGroupSopService;
  28. @Autowired
  29. private IWePresTagGroupTaskService iWePresTagGroupTaskService;
  30. /**
  31. * 获取任务对应的执行人列表
  32. * @param taskId 任务id
  33. * @param type 任务类型 1:标签建群任务 2:sop任务
  34. * @return
  35. */
  36. @GetMapping("/scope/{taskId}")
  37. public AjaxResult getTaskScopeList(@PathVariable("taskId") Long taskId, @RequestParam(value = "type") Integer type) {
  38. if (type.equals(MessageNoticeType.TAG.getType())) {
  39. return AjaxResult.success(iWePresTagGroupTaskService.getScopeListByTaskId(taskId));
  40. } else {
  41. return AjaxResult.success(iWeGroupSopService.getScopeListByRuleId(taskId));
  42. }
  43. }
  44. /**
  45. * h5页面根据员工id获取老客标签建群和群sop任务信息
  46. *
  47. * @param emplId 员工id
  48. * @param type 数据类型,0:全部数据 1:老客标签建群数据 2:群SOP数据
  49. * @return
  50. */
  51. @GetMapping("/{emplId}")
  52. public AjaxResult<WeEmplTaskVo> getEmplTask(@PathVariable("emplId") String emplId, @RequestParam(value = "type") Integer type) {
  53. WeEmplTaskVo weEmplTaskVo=new WeEmplTaskVo();
  54. if (type.equals(MessageNoticeType.TAG.getType())) {
  55. // 老客标签建群数据
  56. weEmplTaskVo.setDone(iWePresTagGroupTaskService.getFollowerTaskList(emplId, 1));
  57. weEmplTaskVo.setTodo(iWePresTagGroupTaskService.getFollowerTaskList(emplId, 0));
  58. } else if (type.equals(MessageNoticeType.SOP.getType())) {
  59. // 群SOP数据
  60. weEmplTaskVo.setTodo(iWeGroupSopService.getEmplTaskList(emplId, false));
  61. weEmplTaskVo.setDone(iWeGroupSopService.getEmplTaskList(emplId, true));
  62. } else {
  63. // 全部数据
  64. List todoList = new ArrayList();
  65. List doneList = new ArrayList();
  66. todoList.addAll(iWePresTagGroupTaskService.getFollowerTaskList(emplId, 0));
  67. todoList.addAll(iWeGroupSopService.getEmplTaskList(emplId, false));
  68. weEmplTaskVo.setTodo(todoList);
  69. doneList.addAll(iWePresTagGroupTaskService.getFollowerTaskList(emplId, 1));
  70. doneList.addAll(iWeGroupSopService.getEmplTaskList(emplId, true));
  71. weEmplTaskVo.setDone(doneList);
  72. }
  73. return AjaxResult.success(
  74. weEmplTaskVo
  75. );
  76. }
  77. /**
  78. * 员工发送老客标签建群任务信息或者发送sop到其客户群之后,变更其任务状态
  79. *
  80. * @param taskId 老客标签建群时代表任务id,sop时,代表规则id
  81. * @param emplId 老客标签建群时代表员工id,sop时,代表群主
  82. * @param type 类型 0:老客标签建群 1:sop
  83. * @return 结果
  84. */
  85. @GetMapping("/changeStatus")
  86. public AjaxResult changeStatus(@RequestParam("taskId") Long taskId, @RequestParam("emplId") String emplId, @RequestParam("type") Integer type) {
  87. if (type.equals(0)) {
  88. return toAjax(iWePresTagGroupTaskService.updateFollowerTaskStatus(taskId, emplId));
  89. } else {
  90. return toAjax(iWeGroupSopService.updateChatSopStatus(taskId, emplId));
  91. }
  92. }
  93. /**
  94. * 用于支持H5页面的名称和关键字检索
  95. *
  96. * @param word 过滤字符
  97. * @return 结果
  98. */
  99. @GetMapping(path = "/filter")
  100. public TableDataInfo filter(@RequestParam("taskNameOrKeys") String word) {
  101. startPage();
  102. List<WeKeywordGroupTask> taskList = keywordToGroupService.filterByNameOrKeyword(word);
  103. return getDataTable(taskList);
  104. }
  105. }