| | |
| | | package com.moral.controller; |
| | | |
| | | |
| | | import com.moral.common.bean.PageBean; |
| | | import com.moral.common.bean.ResultBean; |
| | | import com.moral.entity.DeviceVersion; |
| | | import com.moral.service.DeviceVersionService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | | @RequestMapping("device-version") |
| | | @CrossOrigin(origins = "*", maxAge = 3600) |
| | | public class DeviceVersionController { |
| | | @Resource |
| | | private DeviceVersionService deviceVersionService; |
| | | |
| | | @GetMapping("page-list") |
| | | public PageBean<DeviceVersion> pageList(PageBean pageBean) throws NoSuchMethodException, UnsupportedEncodingException { |
| | | return deviceVersionService.queryByPageBean(pageBean); |
| | | } |
| | | @PostMapping("delete-by-ids") |
| | | public ResultBean deleteByIds(@RequestBody Integer [] ids){ |
| | | deviceVersionService.deleteByIds(ids); |
| | | ResultBean resultBean = new ResultBean(ResultBean.SUCCESS); |
| | | return resultBean; |
| | | } |
| | | @PostMapping("add-or-modify") |
| | | public ResultBean addOrModify(@RequestBody DeviceVersion deviceVersion){ |
| | | deviceVersionService.addOrModify(deviceVersion); |
| | | ResultBean resultBean = new ResultBean(ResultBean.SUCCESS); |
| | | return resultBean; |
| | | } |
| | | @GetMapping("get-sensor-ids") |
| | | public List<Integer> getSensorIds(Integer deviceVersionId){ |
| | | return deviceVersionService.getSensorIds(deviceVersionId); |
| | | } |
| | | @PostMapping("version-sensor-config/{id}") |
| | | public ResultBean versionSensorConfig(@PathVariable("id") Integer deviceVersionId,@RequestBody Integer [] sensorIds){ |
| | | ResultBean resultBean = new ResultBean(); |
| | | if(deviceVersionId==null){ |
| | | resultBean.setCode(ResultBean.NO_PERMISSION); |
| | | resultBean.setMessage("设备型号ID不能为null"); |
| | | return resultBean; |
| | | }else{ |
| | | deviceVersionService.versionSensorConfig(deviceVersionId,sensorIds); |
| | | resultBean.setCode(ResultBean.SUCCESS); |
| | | } |
| | | return resultBean; |
| | | } |
| | | } |