AccountController.java
2.83 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
package cn.fw.dalaran.server.controller.web;
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.dalaran.domain.dto.AccountDTO;
import cn.fw.dalaran.domain.dto.AccountQueryDTO;
import cn.fw.dalaran.domain.dto.UpdateAccountParam;
import cn.fw.dalaran.domain.vo.AccountStatusVo;
import cn.fw.dalaran.domain.vo.AccountVO;
import cn.fw.dalaran.service.biz.AccountBizService;
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 lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.util.List;
import static cn.fw.common.web.util.ResultBuilder.success;
/**
* @author kurisu
* @date 2021-11-17 15:02
* @description 账号控制器
*/
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
@Authorization(AuthType.ERP)
@RequestMapping("/web/account")
@IgnoreAuth
public class AccountController {
private final AccountBizService accountBizService;
@PostMapping("/add")
public Message<Boolean> add(@CurrentUser LoginAuthBean user, @RequestBody @Validated final AccountDTO accountDTO) {
accountDTO.setGroupId(user.getGroupId());
return success(accountBizService.saveAccount(accountDTO));
}
@PutMapping("/authorized/report")
@ControllerMethod("上报账号状态")
public Message<Boolean> report(@NotNull(message = "账号id不能为空") Long accountId, @NotNull(message = "账号状态不能为空") Boolean valid) {
return success(accountBizService.reportAccount(accountId, valid));
}
@DeleteMapping("/delete")
@ControllerMethod("删除账号")
public Message<Boolean> delete(@NotNull(message = "id不能为空") Long id) {
return success(accountBizService.deleteAccount(id));
}
@GetMapping("/list")
@ControllerMethod("查询账号列表")
public Message<AppPage<AccountVO>> list(@CurrentUser LoginAuthBean user, AccountQueryDTO query) {
return success(accountBizService.page(user.getGroupId(), query));
}
@GetMapping("/status")
@ControllerMethod("查询门店账号状态详情列表")
public Message<List<AccountStatusVo.ShopDetails>> status(@CurrentUser LoginAuthBean user) {
return success(accountBizService.status(user.getGroupId()));
}
@PostMapping("/alert")
@ControllerMethod("批量修改账号")
public Message<Boolean> alert(@RequestBody @Validated final UpdateAccountParam param) {
return success(accountBizService.alert(param));
}
}