StoreController.java
2.29 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
package vion.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import vion.Global;
import vion.dto.StatusDTO;
import vion.dto.StoreDTO;
import vion.model.Store;
import vion.service.IStoreService;
import vion.vo.StoreVO;
import vion.vo.UserVO;
import java.util.List;
@RestController
@RequestMapping(Global.BASE_URL)
@RequiredArgsConstructor
@Slf4j
public class StoreController {
private final IStoreService storeService;
private final Converter converter;
@GetMapping("/stores")
@SaCheckPermission(value = "store:list", orRole="admin")
public Page<StoreVO> getStoreList(StoreDTO data) {
return storeService.getStoreList(data);
}
@GetMapping("/store")
@SaCheckPermission(value = "store:query", orRole="admin")
public StoreVO getStoreById(@RequestParam Integer id) {
Store store = storeService.getById(id);
return converter.convert(store, StoreVO.class);
}
@GetMapping("/storeList")
@SaCheckPermission(value = "store:list1", orRole="admin")
public List<StoreVO> getStoreList(Integer accountId) {
List<Store> storeList = storeService.lambdaQuery()
.eq(accountId != null, Store::getAccountId, accountId)
.list();
return converter.convert(storeList, StoreVO.class);
}
@PostMapping("/stores")
@SaCheckPermission(value = "store:editAndSave", orRole="admin")
public String saveOrUpdate(@RequestBody StoreDTO data, @RequestHeader String token) {
UserVO user = Global.USERNAME_MAP.get(token);
Store store = converter.convert(data, Store.class);
if (data.getId() != null) {
store.setModifyUser(user.getId());
} else {
store.setCreateUser(user.getId());
}
return storeService.saveOrUpdate(store) ? "成功" : "失败";
}
@PostMapping("/updateStoreStatus")
@SaCheckPermission(value = "store:editStatus", orRole="admin")
public Object updateStoreStage(StatusDTO statusDTO, @RequestHeader String token) {
return storeService.updateStoreStage(statusDTO, token);
}
}