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
package org.rcisoft.business.manage.controller;
/*固定导入*/
import io.swagger.annotations.ApiOperation;
import org.rcisoft.business.manage.entity.BusDevicetpParam;
import org.rcisoft.business.manage.service.BusDevicetpParamService;
import org.rcisoft.business.manage.vo.BusDevicetpParamList;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.controller.PaginationController;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* Created by on 2018-5-2 16:09:29.
*/
@RestController
@RequestMapping("manage/busdevicetpparam")
public class BusDevicetpParamController extends PaginationController<BusDevicetpParam> {
@Autowired
private BusDevicetpParamService busDevicetpParamServiceImpl;
/**
* 批量出入设备类型模板
* @param busDevicetpParamList
* @return
*/
@ApiOperation(value="添加设备类型模板", notes="添加设备类型模板")
@PostMapping(value = "/add")
public Result add(@RequestBody BusDevicetpParamList busDevicetpParamList) {
PersistModel data = busDevicetpParamServiceImpl.save(busDevicetpParamList);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
busDevicetpParamList);
}
/**
* 先清空模板,后重新批量新增
* @param busDevicetpParamList
* @return
*/
@ApiOperation(value="修改设备类型模板", notes="修改设备类型模板")
@PostMapping(value = "/update")
public Result update(@RequestBody BusDevicetpParamList busDevicetpParamList) {
PersistModel data = busDevicetpParamServiceImpl.update(busDevicetpParamList);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
busDevicetpParamList);
}
@ApiOperation(value="添加或修改设备类型模板", notes="添加或修改设备类型模板")
@PostMapping(value = "/saveOrUpdate")
public Result saveOrUpdate(@RequestBody BusDevicetpParamList busDevicetpParamList) {
PersistModel data = null;
List<BusDevicetpParam> list = busDevicetpParamServiceImpl.queryBusDevicetpParam(busDevicetpParamList.getBusDevicetpParamList().get(0));
if(list.size()>0){
data = busDevicetpParamServiceImpl.update(busDevicetpParamList);
}else{
data = busDevicetpParamServiceImpl.save(busDevicetpParamList);
}
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
busDevicetpParamList);
}
/**
* 删除模板
* @return
*/
@ApiOperation(value="删除设备类型模板", notes="删除设备类型模板")
@PostMapping(value = "/delete")
public Result delete(@RequestParam String devTpId,@RequestParam String proId) {
BusDevicetpParam bp = new BusDevicetpParam();
bp.setDevTpId(devTpId);
bp.setProId(proId);
PersistModel data = busDevicetpParamServiceImpl.delete(bp);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
null);
}
/**
* 查询设备类型模板
* @return
*/
@ApiOperation(value="查询设备类型模板", notes="查询设备类型模板")
@PostMapping(value = "/query")
public List<BusDevicetpParam> query(@RequestParam String devTpId, @RequestParam String proId) {
BusDevicetpParam bp = new BusDevicetpParam();
bp.setDevTpId(devTpId);
bp.setProId(proId);
return busDevicetpParamServiceImpl.queryBusDevicetpParam(bp);
}
}