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();
|
}
|
}
|