SceneTemplateController.java
3.15 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
package com.glsx.smart.controller;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.glsx.smart.dao.entity.SmartSceneTemplate;
import com.glsx.smart.service.SmartSceneTemplateService;
import com.glsx.smart.service.SmartTemplateParamService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
@Slf4j
@RestController
@RequestMapping("/sceneTemplate")
public class SceneTemplateController {
@Autowired
private SmartSceneTemplateService sceneTemplateService;
@Autowired
private SmartTemplateParamService templateParamService;
@RequestMapping(value = "/getPageList", method = {RequestMethod.GET, RequestMethod.POST})
public PageInfo<SmartSceneTemplate> getPageList(SmartSceneTemplate sceneTemplate) {
log.info("/sceneTemplate/getList param: {}", JSON.toJSONString(sceneTemplate));
List<SmartSceneTemplate> sceneList = sceneTemplateService.getList(sceneTemplate);
PageInfo<SmartSceneTemplate> pageInfo = PageInfo.of(sceneList);
return pageInfo;
}
@RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST})
public List<SmartSceneTemplate> getList(SmartSceneTemplate sceneTemplate) {
log.info("/sceneTemplate/getList param: {}", JSON.toJSONString(sceneTemplate));
return sceneTemplateService.getList(sceneTemplate);
}
@RequestMapping(value = "/getById", method = {RequestMethod.GET, RequestMethod.POST})
public SmartSceneTemplate getById(Long id) {
log.info("/sceneTemplate/getById param: {}", id);
SmartSceneTemplate template = sceneTemplateService.getById(id);
if(template != null){
template.setTemplateList(templateParamService.getByTemplateId(id));
}
return template;
}
@RequestMapping(value = "/add", method = {RequestMethod.POST})
public boolean save(@RequestBody SmartSceneTemplate sceneTemplate) {
log.info("新增调用/sceneTemplate/add param: {}", JSON.toJSONString(sceneTemplate));
return sceneTemplateService.insert(sceneTemplate) > 0 ? true : false;
}
@RequestMapping(value = "/update", method = {RequestMethod.POST})
public boolean update(@RequestBody SmartSceneTemplate sceneTemplate) {
log.info("更新调用/sceneTemplate/update param: {}", JSON.toJSONString(sceneTemplate));
return sceneTemplateService.update(sceneTemplate) > 0 ? true : false;
}
@RequestMapping(value = "/updateParam", method = {RequestMethod.POST})
public boolean updateParam(@RequestBody SmartSceneTemplate sceneTemplate) {
log.info("更新主表调用/sceneTemplate/updateParam param: {}", JSON.toJSONString(sceneTemplate));
return sceneTemplateService.updateByPrimaryKeySelective(sceneTemplate) > 0 ? true : false;
}
}