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