package com.moral.controller;
|
|
import com.moral.common.bean.PageBean;
|
import com.moral.common.bean.ResultBean;
|
import com.moral.entity.MonitorPoint;
|
import com.moral.service.MonitorPointService;
|
import org.springframework.web.bind.annotation.*;
|
|
import static com.moral.common.util.WebUtils.getParametersStartingWith;
|
|
import java.util.List;
|
import java.util.Map;
|
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletRequest;
|
|
|
@RestController
|
@RequestMapping("monitor-point")
|
@CrossOrigin(origins = "*", maxAge = 3600)
|
public class MonitorPointController {
|
@Resource
|
MonitorPointService monitorPointService;
|
@GetMapping("page-list")
|
public PageBean pageList(PageBean pageBean) {
|
return monitorPointService.queryByPageBean(pageBean);
|
}
|
@PostMapping("delete-by-ids")
|
public ResultBean deleteByIds(@RequestBody Integer [] ids){
|
monitorPointService.deleteByIds(ids);
|
ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
|
return resultBean;
|
}
|
|
/**
|
* 根据 监控点id 获取 监控点
|
* @param id
|
* @return
|
*/
|
@GetMapping("get-by-id")
|
public ResultBean getById(Integer id){
|
MonitorPoint monitorPoint = monitorPointService.queryWithRelationById(id);
|
ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
|
resultBean.setData(monitorPoint);
|
return resultBean;
|
}
|
@PostMapping("add-or-modify")
|
public ResultBean addOrModify(@RequestBody MonitorPoint monitorPoint){
|
monitorPointService.addOrModify(monitorPoint);
|
ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
|
return resultBean;
|
}
|
|
@GetMapping("list/{name}")
|
public ResultBean<List<MonitorPoint>> getMonitorPointsByName(@PathVariable("name") String name) {
|
List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsByName(name);
|
return new ResultBean<List<MonitorPoint>>(monitorPoints);
|
}
|
|
@GetMapping("list/region")
|
public ResultBean<List<MonitorPoint>> getMonitorPointsByRegion(HttpServletRequest request) {
|
Map<String, Object> parameters = getParametersStartingWith(request, null);
|
List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsByRegion(parameters);
|
return new ResultBean<List<MonitorPoint>>(monitorPoints);
|
}
|
|
}
|