AccountController.java
1.91 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
package vion.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import vion.model.Account;
import vion.service.IAccountService;
/**
* 集团管理
*/
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class AccountController {
private final IAccountService accountService;
@GetMapping("/account")
@SaCheckPermission(value = "account:list", orRole = "admin")
public Page<Account> getAccountList(Account dto) {
return accountService.page(Page.of(dto.getPageNum(), dto.getPageSize()),
Wrappers.lambdaQuery(dto).orderByDesc(Account::getModifyTime));
}
@GetMapping("/onlyAccount")
@SaCheckPermission(value = "account:listAccount", orRole = "admin")
public Page<Account> getAccountNameList(Account dto) {
return accountService.lambdaQuery(dto)
.select(Account::getId, Account::getName)
.orderByDesc(Account::getModifyTime)
.page(Page.of(dto.getPageNum(),
dto.getPageSize()));
}
@GetMapping("/account/{id}")
@SaCheckPermission(value = "account:query", orRole = "admin")
public Account getAccountById(@PathVariable Long id) {
return accountService.getById(id);
}
@PostMapping("/account")
@SaCheckPermission(value = "account:editAndSave", orRole = "admin")
public Account saveOrUpdate(@RequestBody Account data) {
accountService.saveOrUpdate(data);
return data;
}
@DeleteMapping("/account/{id}")
@SaCheckPermission(value = "account:remove", orRole = "admin")
public String remove(@PathVariable(name = "id") Integer id) {
accountService.removeById(id);
return "集团删除成功";
}
}