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