AccountController.java
1.18 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
package vion.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import vion.Global;
import vion.dto.BaseDTO;
import vion.model.Account;
import vion.service.IAccountService;
@RestController
@RequestMapping(Global.BASE_URL)
@RequiredArgsConstructor
@Slf4j
public class AccountController {
private final IAccountService accountService;
@GetMapping("/accounts")
@SaCheckPermission(value = "account:list", orRole = "admin")
public Page<Account> getAccountList(BaseDTO dto) {
return accountService.page(Page.of(dto.getPageNum(), dto.getPageSize()));
}
@GetMapping("/account")
@SaCheckPermission(value = "account:query", orRole = "admin")
public Account getProductById(Integer id) {
return accountService.getById(id);
}
@PostMapping("/accounts")
@SaCheckPermission(value = "account:editAndSave", orRole = "admin")
public Account saveOrUpdate(@RequestBody Account data) {
accountService.save(data);
return data;
}
}