CompanyController.java
3.1 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
package com.tianbo.warehouse.controller;
import com.github.pagehelper.PageInfo;
import com.tianbo.warehouse.annotation.LogAnnotation;
import com.tianbo.warehouse.controller.response.ResultJson;
import com.tianbo.warehouse.model.Company;
import com.tianbo.warehouse.service.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
@RestController
@RequestMapping("/company")
public class CompanyController {
@Autowired
CompanyService companyService;
@GetMapping("/list")
public PageInfo<Company> list(@RequestParam(value = "pageNum",required = false,defaultValue = "1")
int pageNum,
@RequestParam(value = "pageSize",required = false,defaultValue = "5")
int pageSize,
@RequestParam(value = "companyName", required = false) String companyName){
return companyService.findAll(pageNum,pageSize, companyName);
}
@LogAnnotation(moduleName = "公司管理",operate = "公司添加")
@PostMapping("/add")
public ResultJson add(@RequestBody Company company){
int i =companyService.insertSelective(company);
ResultJson resultJson = new ResultJson();
if (1==i){
resultJson = new ResultJson("200","添加成功");
}else {
resultJson = new ResultJson("500","insert faild");
}
return resultJson;
}
@LogAnnotation(moduleName = "公司管理",operate = "公司修改")
@PutMapping("/edit")
@ResponseBody
public ResultJson edit(@RequestBody @Valid Company company){
int i =companyService.updateByPrimaryKeySelective(company);
ResultJson resultJson = new ResultJson();
if (1==i){
resultJson = new ResultJson("200","修改成功");
}else {
resultJson = new ResultJson("500","insert faild");
}
return resultJson;
}
@LogAnnotation(moduleName = "公司管理",operate = "公司删除")
@DeleteMapping("/del")
public ResultJson reomve(@RequestBody Company company, HttpServletRequest request, HttpServletResponse response){
int i =companyService.deleteByPrimaryKey(company.getCompanyId());
ResultJson resultJson = new ResultJson();
if (1==i){
resultJson = new ResultJson("200","删除成功");
}else {
resultJson = new ResultJson("500","insert faild");
}
return resultJson;
}
@LogAnnotation(moduleName = "公司管理",operate = "公司批量删除")
@GetMapping("/batchremove")
public ResultJson reomve(String ids, HttpServletRequest request, HttpServletResponse response){
ResultJson resultJson = new ResultJson();
if (companyService.deleteByPrimaryKey(ids)>0){
resultJson = new ResultJson("200","删除成功");
}else {
resultJson = new ResultJson("500","insert faild");
}
return resultJson;
}
}