fengxiang
2018-01-26 e125b445697a6b8c2b5cc5c57f31249c5088c1c9
Merge remote-tracking branch 'origin/master'
9 files modified
58 ■■■■■ changed files
src/main/java/com/moral/controller/DeviceController.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/MonitorPointController.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/SensorController.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/DeviceService.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/MonitorPointService.java 3 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/SensorService.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/DeviceServiceImpl.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java 12 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/SensorServiceImpl.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/DeviceController.java
@@ -6,6 +6,8 @@
import com.moral.service.DeviceService;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import javax.annotation.Resource;
@RestController
@@ -30,4 +32,11 @@
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        return resultBean;
    }
    @GetMapping("monitorPointId")
    public ResultBean<List<Device>> getDevicesByMonitorPointId(@RequestParam(name="monitorPointId")Integer  monitorPointId) {
        List<Device> devices = deviceService.getDevicesByMonitorPointId(monitorPointId);
        return new ResultBean<List<Device>>(devices);
    }
}
src/main/java/com/moral/controller/MonitorPointController.java
@@ -6,6 +6,8 @@
import com.moral.service.MonitorPointService;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import javax.annotation.Resource;
@@ -44,4 +46,11 @@
        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);
    }
}
src/main/java/com/moral/controller/SensorController.java
@@ -35,4 +35,11 @@
        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);
    }
}
src/main/java/com/moral/service/DeviceService.java
@@ -22,4 +22,6 @@
    void deleteByIds(Integer[] ids);
    void addOrModify(Device device);
    List<Device> getDevicesByMonitorPointId(Integer monitorPointId);
}
src/main/java/com/moral/service/MonitorPointService.java
@@ -19,4 +19,7 @@
    public void addOrModify(MonitorPoint monitorPoint);
    public void deleteByIds(Integer... ids);
    List<MonitorPoint> getMonitorPointsByName(String name);
}
src/main/java/com/moral/service/SensorService.java
@@ -1,5 +1,7 @@
package com.moral.service;
import java.util.List;
import com.moral.common.bean.PageBean;
import com.moral.entity.Sensor;
@@ -14,4 +16,6 @@
    public void addOrModify(Sensor sensor);
    public void deleteByIds(Integer... ids);
    public List<Sensor> getAllSensors();
}
src/main/java/com/moral/service/impl/DeviceServiceImpl.java
@@ -151,5 +151,12 @@
        }
    }
    @Override
    public List<Device> getDevicesByMonitorPointId(Integer monitorPointId) {
        Device device = new Device();
        device.setMonitorPointId(monitorPointId);
        device.setIsDelete(Constants.IS_DELETE_FALSE);
        return deviceMapper.select(device);
    }
}
src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java
@@ -18,6 +18,7 @@
import com.moral.mapper.MonitorPointMapper;
import com.moral.service.MonitorPointService;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria;
@Service
public class MonitorPointServiceImpl implements MonitorPointService {
@@ -87,4 +88,15 @@
        }
    }
    @Override
    public List<MonitorPoint> getMonitorPointsByName(String name) {
        Example example = new Example(MonitorPoint.class);
        Criteria criteria = example.createCriteria();
        criteria.andEqualTo("isDelete", Constants.IS_DELETE_FALSE).andLike("name", "%" + name + "%");
        example.or().andEqualTo("isDelete", Constants.IS_DELETE_FALSE).andCondition("getPY(name) like ", "%" + name + "%");
        List<MonitorPoint> monitorPoints = monitorPointMapper.selectByExample(example);
        return monitorPoints;
    }
}
src/main/java/com/moral/service/impl/SensorServiceImpl.java
@@ -61,4 +61,9 @@
        }
    }
    @Override
    public List<Sensor> getAllSensors() {
        return sensorMapper.selectAll();
    }
}