fengxiang
2018-08-24 41863d2c44c03dca9f0bff4e3fad2be454362da0
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
package com.moral.controller;
 
import com.moral.common.bean.ResultBean;
import com.moral.entity.SensorUnit;
import com.moral.service.SensorUnitService;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
 
@RestController
@RequestMapping("sensor-unit")
@CrossOrigin(origins = "*", maxAge = 3600)
public class SensorUnitController {
    @Resource
    SensorUnitService sensorUnitService;
    @PostMapping("add-or-modify")
    public ResultBean addOrModify(@RequestBody SensorUnit sensorUnit){
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        if(!sensorUnitService.addOrModify(sensorUnit)){
            resultBean.setCode(ResultBean.FAIL);
        }
        return resultBean;
    }
 
    /**
     *  获取单位数组
     * @param sensorId
     * @return
     */
    @GetMapping("gets-bysid")
    public ResultBean getListBySensorId(Integer sensorId) {
        return  new ResultBean(sensorUnitService.queryListBySensorId(sensorId));
    }
    @GetMapping("delete")
    public ResultBean delete(Integer id) {
         sensorUnitService.remove(id);
         return  ResultBean.success();
    }
}