fengxiang
2018-06-08 8a44b29fc5599fd92a9b583a07a16952bc6adfd8
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
package com.moral.controller;
 
import com.moral.common.bean.PageBean;
import com.moral.common.bean.ResultBean;
import com.moral.entity.Sensor;
import com.moral.service.SensorService;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.util.List;
 
@RestController
@RequestMapping("sensor")
@CrossOrigin(origins = "*", maxAge = 3600)
public class SensorController {
    @Resource
    SensorService sensorService;
    @GetMapping("page-list")
    public PageBean pageList(PageBean pageBean) {
        return sensorService.queryByPageBean(pageBean);
    }
    @GetMapping("list-by-vid")
    public PageBean pageListByVersionId(Integer versionId){
        return sensorService.queryByVersionId(versionId);
    }
    @PostMapping("delete-by-ids")
    public ResultBean deleteByIds(@RequestBody Integer [] ids){
        sensorService.deleteByIds(ids);
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        return resultBean;
    }
    @PostMapping("add-or-modify")
    public ResultBean addOrModify(@RequestBody Sensor sensor){
        sensorService.addOrModify(sensor);
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        return resultBean;
    }
    
    @GetMapping("all")
    public ResultBean<List<Sensor>> getAllSensors() {
        List<Sensor> sensors = sensorService.getAllSensors();
        return new ResultBean<List<Sensor>>(sensors);
    }
 
}