ValhallaGeneralApiServiceImpl.java
2.59 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
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.domain.dto.CustomerDetailDto;
import cn.fw.valhalla.sdk.api.ValhallaGeneralApiService;
import cn.fw.valhalla.sdk.param.CustomerQueryReq;
import cn.fw.valhalla.sdk.param.ReachLogReq;
import cn.fw.valhalla.sdk.result.CustomerSimpleInfoDto;
import cn.fw.valhalla.service.bus.ReachLogBizService;
import cn.fw.valhalla.service.bus.cust.CustomerBizService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
import static cn.fw.common.web.util.ResultBuilder.success;
/**
* @author : kurisu
* @className : ValhallaGeneralApiServiceImpl
* @description : 通用api实现
* @date: 2020-11-11 16:01
*/
@Slf4j
@RestController
@RequestMapping("/api/valhalla/general")
public class ValhallaGeneralApiServiceImpl implements ValhallaGeneralApiService {
private final ReachLogBizService reachLogBizService;
/**
* 保有客数据服务
*/
private final CustomerBizService customerBiz;
@Autowired
public ValhallaGeneralApiServiceImpl(final ReachLogBizService reachLogBizService,
final CustomerBizService customerBiz) {
this.reachLogBizService = reachLogBizService;
this.customerBiz = customerBiz;
}
@PostMapping("/reach/save")
@Override
@ControllerMethod("保存进站记录")
public Message<Void> saveReachLog(@Valid @RequestBody ReachLogReq reachLogReq) {
reachLogBizService.saveReachLog(reachLogReq);
return success();
}
@Override
@PostMapping("/query/customer/list")
@ControllerMethod("查询保有客档案列表")
public Message<List<CustomerSimpleInfoDto>> queryCustomList(@Valid @RequestBody CustomerQueryReq customerQueryReq) {
List<CustomerDetailDto> list = customerBiz.queryCustomList(customerQueryReq);
List<CustomerSimpleInfoDto> dtoList = new ArrayList<>();
for (CustomerDetailDto customer : list) {
CustomerSimpleInfoDto dto = new CustomerSimpleInfoDto();
BeanUtils.copyProperties(customer, dto);
dtoList.add(dto);
}
return success(dtoList);
}
}