FollowApiServiceImpl.java
3.76 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
package cn.fw.valhalla.controller.api;
import cn.fw.common.web.annotation.ControllerMethod;
import cn.fw.data.base.domain.common.Message;
import cn.fw.valhalla.common.utils.StringUtils;
import cn.fw.valhalla.domain.dto.OriginalDataDTO;
import cn.fw.valhalla.domain.enums.FollowTypeEnum;
import cn.fw.valhalla.sdk.api.FollowApiService;
import cn.fw.valhalla.sdk.enums.DataTypeEnum;
import cn.fw.valhalla.sdk.param.FollowOriginalParam;
import cn.fw.valhalla.sdk.param.ShouldBeCompletedQuery;
import cn.fw.valhalla.sdk.result.ShouldBeCompletedResult;
import cn.fw.valhalla.service.bus.follow.FollowApiBizService;
import cn.fw.valhalla.service.bus.follow.OriginalDataBizService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
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 : FollowApiServiceImpl
* @description : 跟进api
* @date: 2020-08-14 17:53
*/
@Slf4j
@RestController
@RequestMapping("/api/valhalla/follow")
public class FollowApiServiceImpl implements FollowApiService {
private final OriginalDataBizService originalDataBizService;
private final FollowApiBizService followApiBizService;
@Autowired
public FollowApiServiceImpl(final OriginalDataBizService originalDataBizService,
final FollowApiBizService followApiBizService) {
this.originalDataBizService = originalDataBizService;
this.followApiBizService = followApiBizService;
}
@Override
@PostMapping("/origin/save")
@ControllerMethod("业务元数据保存")
public Message<Void> saveOriginal(@Valid @RequestBody FollowOriginalParam originalParam) {
log.info("跟进元数据:[customerId: {} vin:{} plateNo:{} generateTime:{}]",
originalParam.getCustomerId(), originalParam.getFrameNo(), originalParam.getPlateNo(), originalParam.getGenerateTime());
String frameNo = originalParam.getFrameNo();
Long customerId = originalParam.getCustomerId();
boolean bool = Objects.nonNull(customerId) || StringUtils.isValid(frameNo);
BV.isTrue(bool, () -> "档案id或者车架号不能为空");
OriginalDataDTO dataDTO = new OriginalDataDTO();
BeanUtils.copyProperties(originalParam, dataDTO);
originalDataBizService.saveOrigin(dataDTO);
return success();
}
@Override
@GetMapping("/origin/remove")
@ControllerMethod("业务元数据删除")
public Message<Void> removeData(@RequestParam("type") Integer type, @RequestParam("detailId") String detailId) {
DataTypeEnum typeEnum = DataTypeEnum.ofValue(type);
BV.notNull(typeEnum, "业务类型不正确");
originalDataBizService.remove(typeEnum, detailId);
return success();
}
@Override
@GetMapping("/should/ins/completed")
@ControllerMethod("查询续保跟进应成交台数")
public Message<List<ShouldBeCompletedResult>> queryInsShouldBeCompleted(@Validated @SpringQueryMap ShouldBeCompletedQuery query) {
return success(followApiBizService.queryShouldBeCompleted(query, FollowTypeEnum.IR));
}
@Override
@GetMapping("/ins/completed_arr")
@ControllerMethod("查询续保跟进应成交台数")
public Message<List<ShouldBeCompletedResult>> queryInsCompletedGuys(@Validated @SpringQueryMap ShouldBeCompletedQuery query) {
return success(followApiBizService.queryCompletedGuys(query, FollowTypeEnum.IR));
}
}