SpInfoController.java
4.87 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package com.bs.web.controller.sp;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.domain.entity.sp.SpInfo;
import com.bs.common.core.page.PageDomain;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.core.page.TableSupport;
import com.bs.common.enums.BusinessType;
import com.bs.common.enums.OperatorType;
import com.bs.web.service.sp.ISpInfoService;
import com.bs.common.core.domain.entity.store.BusinessStore;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/sp/info")
@Tag(name = "服务商信息")
public class SpInfoController extends BaseController {
@Resource
private ISpInfoService spInfoService;
@PostMapping("/list")
@Operation(summary = "列表")
public AjaxResult<List<SpInfo>> list(SpInfo query) {
List<SpInfo> list = spInfoService.list(query);
return AjaxResult.success(list);
}
@GetMapping(value = "/page")
@Operation(summary = "分页列表")
public TableDataInfo page(SpInfo query) {
com.bs.common.core.page.PageDomain pageDomain = com.bs.common.core.page.TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
if (pageNum == null && query != null && query.getParams() != null && query.getParams().get("pageNum") != null) {
pageNum = Integer.parseInt(query.getParams().get("pageNum").toString());
}
if (pageSize == null && query != null && query.getParams() != null && query.getParams().get("pageSize") != null) {
pageSize = Integer.parseInt(query.getParams().get("pageSize").toString());
}
if (pageNum == null) pageNum = 1;
if (pageSize == null) pageSize = 10;
com.baomidou.mybatisplus.core.metadata.IPage<SpInfo> pageResult = spInfoService.page(query, pageNum, pageSize);
TableDataInfo rspData = new TableDataInfo();
rspData.setCode(com.bs.common.constant.HttpStatus.SUCCESS);
rspData.setMsg("查询成功");
rspData.setRows(pageResult.getRecords());
rspData.setTotal(pageResult.getTotal());
return rspData;
}
@PostMapping("/{id}")
@Operation(summary = "详情")
public AjaxResult<SpInfo> get(@PathVariable("id") Long id) {
return AjaxResult.success(spInfoService.get(id));
}
@Log(title = "服务商信息", businessType = BusinessType.INSERT,operatorType = OperatorType.MANAGE)
@PostMapping("/add")
@Operation(summary = "新增")
public AjaxResult add(@RequestBody @Validated SpInfo info, BindingResult br) {
if (br.hasErrors()) {
return AjaxResult.error(br.getFieldError().getDefaultMessage());
}
spInfoService.add(info);
return AjaxResult.success();
}
@Log(title = "服务商信息", businessType = BusinessType.UPDATE,operatorType = OperatorType.MANAGE)
@PostMapping("/edit")
@Operation(summary = "编辑")
public AjaxResult edit(@RequestBody @Validated SpInfo info, BindingResult br) {
if (br.hasErrors()) {
return AjaxResult.error(br.getFieldError().getDefaultMessage());
}
spInfoService.edit(info);
return AjaxResult.success();
}
@Log(title = "服务商信息", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE)
@PostMapping("/delete/{id}")
@Operation(summary = "删除")
public AjaxResult remove(@PathVariable("id") Long id) {
spInfoService.remove(id);
return AjaxResult.success();
}
@GetMapping(value = "/storeInfo/list/{spCode}")
@Operation(summary = "根据服务商编码查询关联的门店分页列表")
public TableDataInfo<List<BusinessStore>> selectStoreListBySpCode(@PathVariable("spCode") String spCode) {
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
if (pageNum == null) pageNum = 1;
if (pageSize == null) pageSize = 10;
com.baomidou.mybatisplus.core.metadata.IPage<BusinessStore> pageResult = spInfoService.selectStoreListBySpCodePage(spCode, pageNum, pageSize);
TableDataInfo<List<BusinessStore>> rspData = new TableDataInfo<>();
rspData.setCode(com.bs.common.constant.HttpStatus.SUCCESS);
rspData.setMsg("查询成功");
rspData.setRows(pageResult.getRecords());
rspData.setTotal(pageResult.getTotal());
return rspData;
}
}