FollowController.java
5.74 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package cn.fw.valhalla.controller.app;
import cn.fw.common.page.AppPage;
import cn.fw.common.web.annotation.ControllerMethod;
import cn.fw.common.web.auth.LoginAuthBean;
import cn.fw.common.web.auth.annotation.CurrentUser;
import cn.fw.data.base.domain.common.Message;
import cn.fw.security.auth.client.annotation.Authorization;
import cn.fw.security.auth.client.annotation.IgnoreAuth;
import cn.fw.security.auth.client.enums.AuthType;
import cn.fw.valhalla.domain.dto.FollowAttachmentDTO;
import cn.fw.valhalla.domain.enums.FollowTypeEnum;
import cn.fw.valhalla.domain.query.FollowQueryVO;
import cn.fw.valhalla.domain.vo.follow.CustomerClueHistoryVO;
import cn.fw.valhalla.domain.vo.follow.FollowDetailVO;
import cn.fw.valhalla.domain.vo.follow.FollowRecordVO;
import cn.fw.valhalla.domain.vo.follow.FollowTodoListVO;
import cn.fw.valhalla.service.bus.follow.FollowBizService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Objects;
import static cn.fw.common.businessvalidator.Validator.BV;
import static cn.fw.common.web.util.ResultBuilder.success;
/**
* @author : kurisu
* @className : FollowController
* @description : 跟进控制器
* @date: 2020-08-15 16:23
*/
@Slf4j
@RestController
@Authorization(AuthType.APP)
@Validated
@RequestMapping("/app/follow")
public class FollowController {
private final FollowBizService followBizService;
@Autowired
public FollowController(final FollowBizService followBizService) {
this.followBizService = followBizService;
}
@GetMapping("/todo/list")
@ControllerMethod("分页查询跟进待办列表")
@Deprecated
public Message<AppPage<FollowTodoListVO>> todoList(@CurrentUser LoginAuthBean currentUser, final FollowQueryVO queryVO) {
BV.notNull(queryVO.getType(), "跟进类型不正确");
AppPage<FollowTodoListVO> page = followBizService.todoList(queryVO, currentUser);
return success(page);
}
@GetMapping("/todo/detail")
@ControllerMethod("查询跟进待办详情")
public Message<FollowDetailVO> todoDetail(@NotNull(message = "跟进记录id不能为空") final Long id) {
FollowDetailVO detailVO = followBizService.todoDetail(id);
return success(detailVO);
}
@GetMapping("/approve/detail")
@IgnoreAuth
@ControllerMethod("查询跟进战败审批详情")
public Message<FollowDetailVO> approveDetail(final Long recordId, final Long taskId, final Integer type) {
FollowDetailVO detailVO = followBizService.approveDetail(recordId, taskId, type);
return success(detailVO);
}
@GetMapping("/todo/record")
@IgnoreAuth
@ControllerMethod("查询跟进历史记录")
public Message<List<FollowRecordVO>> todoRecord(@NotNull(message = "跟进任务id不能为空") final Long taskId) {
return success(followBizService.todoRecord(taskId));
}
@GetMapping("/sms/template")
@IgnoreAuth
@ControllerMethod("查询短信模板")
public Message<String> getSmsTemplate(@CurrentUser LoginAuthBean currentUser, @NotNull(message = "跟进类型不能为空") final Integer type) {
Message<String> message = success();
message.setData(followBizService.smsTemplate(currentUser.getUserId(), type));
return message;
}
@PostMapping("/defeat")
@ControllerMethod("主动战败")
public Message<Void> defeat(@CurrentUser LoginAuthBean currentUser,
final Long id,
final String reason,
final Long taskId) {
if (Objects.isNull(id)) {
followBizService.defeat(taskId, currentUser, reason);
} else {
followBizService.defeat(currentUser, reason, id, null);
}
return success();
}
@PostMapping("/todo/complete")
@ControllerMethod("完成跟进待办")
public Message<Void> complete(@CurrentUser LoginAuthBean currentUser,
@NotNull(message = "跟进记录id不能为空") final Long id,
@NotNull(message = "跟进类型不能为空") final Integer type) {
FollowTypeEnum typeEnum = FollowTypeEnum.ofValue(type);
BV.notNull(typeEnum, "跟进类型不正确");
followBizService.completeRecord(id, typeEnum, currentUser);
return success();
}
@PostMapping("/todo/upload")
@ControllerMethod("上传跟进凭证")
public Message<Void> upload(@CurrentUser LoginAuthBean currentUser, @RequestBody @Valid final FollowAttachmentDTO dto) {
BV.notNull(dto.getFollowType(), "跟进类型不正确");
followBizService.uploadAtt(dto, currentUser);
return success();
}
@GetMapping("/customer/clue/list")
@IgnoreAuth
@ControllerMethod("查询档案跟进线索历史列表")
public Message<List<CustomerClueHistoryVO>> clueHistory(@CurrentUser LoginAuthBean currentUser,
@NotNull(message = "档案id不能为空") final Long customerId) {
List<CustomerClueHistoryVO> list = followBizService.clueHistoryList(currentUser.getGroupId(), customerId);
return success(list);
}
@GetMapping("/customer/clue/record")
@IgnoreAuth
@ControllerMethod("查询跟进线索的跟进历史记录")
public Message<List<FollowRecordVO>> clueRecord(@NotNull(message = "线索id不能为空") final Long clueId, @NotNull(message = "跟进类型不能为空") final Integer type) {
return success(followBizService.queryHistoryByClueId(clueId, type));
}
}