CompanyInfoController.java
4.3 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
package com.sunyo.wlpt.dispatch.controller;
import com.github.pagehelper.PageInfo;
import com.sunyo.wlpt.dispatch.domain.CompanyInfo;
import com.sunyo.wlpt.dispatch.response.ResultJson;
import com.sunyo.wlpt.dispatch.service.CompanyInfoService;
import com.sunyo.wlpt.dispatch.utils.GetUUID;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @author 子诚
* Description:公司信息 Controller
* 时间:2020/4/28 15:41
*/
@CrossOrigin
@Api(value = "公司信息,业务", tags = "业务管理——公司信息")
@RequestMapping("dispatch/companyInfo")
@RestController
public class CompanyInfoController {
@Resource
private CompanyInfoService companyInfoService;
@ApiOperation("分页查询,公司信息列表")
@GetMapping("/selectCompanyInfoList")
public ResultJson<PageInfo> selectCompanyInfoList(
@ApiParam(name = "companyName", value = "公司名称", required = false)
@RequestParam(value = "companyName", required = false) String companyName,
@ApiParam(name = "companyMobile", value = "公司联系方式", required = false)
@RequestParam(value = "companyMobile", required = false) String companyMobile,
@ApiParam(name = "pageNum", value = "第几页,默认为第一页", required = false)
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@ApiParam(name = "pageSize", value = "每页数量,默认10条", required = false)
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
ResultJson<PageInfo> result = new ResultJson<>();
CompanyInfo companyInfo = new CompanyInfo();
if ("".equals(companyName)) {
companyInfo.setCompanyName(companyName);
}
if ("".equals(companyMobile)) {
companyInfo.setCompanyMobile(companyMobile);
}
PageInfo pageInfo = companyInfoService.selectCompanyInfoList(companyInfo, pageNum, pageSize);
if (pageInfo.getTotal() > 0) {
result.setData(pageInfo);
result.setMsg("查询公司信息,成功");
} else {
result.setCode("400");
result.setMsg("查询公司信息,失败");
}
return result;
}
/**
* 增加公司信息.
*
* @param companyInfo {@link CompanyInfo}
* @return
*/
@ApiOperation("增加,公司信息")
@PostMapping("/insertCompanyInfo")
public ResultJson insertCompanyInfo(@RequestBody CompanyInfo companyInfo) {
ResultJson result = new ResultJson();
companyInfo.setId(GetUUID.getuuid());
int num = companyInfoService.insertSelective(companyInfo);
if (num > 0) {
result.setMsg("增加公司信息,成功");
} else {
result.setCode("400");
result.setMsg("增加公司信息,失败");
}
return result;
}
/**
* 编辑公司信息
*
* @param companyInfo {@link CompanyInfo}
* @return
*/
@ApiOperation("编辑,公司信息")
@PutMapping("/updateCompanyInfo")
public ResultJson updateCompanyInfo(@RequestBody CompanyInfo companyInfo) {
ResultJson result = new ResultJson();
int num = companyInfoService.updateByPrimaryKeySelective(companyInfo);
if (num > 0) {
result.setMsg("修改公司信息,成功");
} else {
result.setCode("400");
result.setMsg("修改公司信息,失败");
}
return result;
}
/**
* 删除公司信息
*
* @param companyInfo {@link CompanyInfo}
* @return
*/
@ApiOperation("删除,公司信息")
@DeleteMapping("/deleteCompanyInfo")
public ResultJson deleteCompanyInfo(@RequestBody CompanyInfo companyInfo) {
ResultJson result = new ResultJson();
int num = companyInfoService.deleteByPrimaryKey(companyInfo.getId());
if (num > 0) {
result.setMsg("删除公司信息,成功");
} else {
result.setCode("400");
result.setMsg("删除公司信息,失败");
}
return result;
}
}