| | |
| | | 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 java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | import org.springframework.web.bind.annotation.CrossOrigin; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.moral.common.bean.PageBean; |
| | | import com.moral.common.bean.ResultBean; |
| | | import com.moral.common.util.StringUtils; |
| | | import com.moral.entity.Sensor; |
| | | import com.moral.service.SensorService; |
| | | |
| | | @RestController |
| | | @RequestMapping("sensor") |
| | |
| | | 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){ |
| | | 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){ |
| | | 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); |
| | | } |
| | | |
| | | @GetMapping("allById") |
| | | public ResultBean<List<Map<String, Object>>> getAllSensorsById() { |
| | | List<Map<String, Object>> sensors = sensorService.getSensorByDId("1230"); |
| | | return new ResultBean<List<Map<String, Object>>>(sensors); |
| | | } |
| | | |
| | | @GetMapping("getSenosrsByOrgId") |
| | | public ResultBean<List<Sensor>> getSenosrsByOrgId(Integer organizationId, String regionCode) { |
| | | Map<String, Object> parameters = new HashMap<>(); |
| | | parameters.put("organizationId", organizationId); |
| | | if (!StringUtils.isNullOrEmpty(regionCode)) { |
| | | parameters.put("regionCode", Long.valueOf(regionCode)); |
| | | } |
| | | List<Sensor> sensors = sensorService.selectSenosrsByOrgId(parameters); |
| | | return new ResultBean<>(sensors); |
| | | } |
| | | |
| | | } |