增加了设备查询接口
diff --git a/src/main/java/com/supwisdom/dlpay/framework/util/TradeErrorCode.java b/src/main/java/com/supwisdom/dlpay/framework/util/TradeErrorCode.java
index 336239e..b3fee04 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/util/TradeErrorCode.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/util/TradeErrorCode.java
@@ -9,6 +9,7 @@
*/
public static final int INPUT_DATA_ERROR = 10000;
+ public static final int PROCESS_ERROR = 11000;
/**
* 账户不存在
diff --git a/src/main/java/com/supwisdom/dlpay/framework/util/WaterErrorCode.java b/src/main/java/com/supwisdom/dlpay/framework/util/WaterErrorCode.java
new file mode 100644
index 0000000..f58e0a3
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/framework/util/WaterErrorCode.java
@@ -0,0 +1,14 @@
+package com.supwisdom.dlpay.framework.util;
+
+public class WaterErrorCode {
+ public static final int OK = 0;
+
+ /**
+ * 10000 开始表述错误码
+ */
+ public static final int REQUEST_DATA_ERROR = 10000;
+
+ public static final int DATA_NOTFOUND_ERROR= 10002;
+
+ public static final int PROCESS_ERROR = 10001;
+}
diff --git a/src/main/java/com/supwisdom/dlpay/water/dao/DeviceDao.java b/src/main/java/com/supwisdom/dlpay/water/dao/DeviceDao.java
index 6866e24..f824147 100644
--- a/src/main/java/com/supwisdom/dlpay/water/dao/DeviceDao.java
+++ b/src/main/java/com/supwisdom/dlpay/water/dao/DeviceDao.java
@@ -1,14 +1,15 @@
package com.supwisdom.dlpay.water.dao;
-import com.supwisdom.dlpay.water.framework.domain.TDevice;
+import com.supwisdom.dlpay.water.domain.TDevice;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
-public interface DeviceDao extends JpaRepository<TDevice, Integer> {
+public interface DeviceDao extends JpaRepository<TDevice, Integer>, JpaSpecificationExecutor<TDevice> {
List<TDevice> findByRegino(Integer regino);
diff --git a/src/main/java/com/supwisdom/dlpay/water/dao/RegionDao.java b/src/main/java/com/supwisdom/dlpay/water/dao/RegionDao.java
index 6825189..c5396cb 100644
--- a/src/main/java/com/supwisdom/dlpay/water/dao/RegionDao.java
+++ b/src/main/java/com/supwisdom/dlpay/water/dao/RegionDao.java
@@ -1,6 +1,6 @@
package com.supwisdom.dlpay.water.dao;
-import com.supwisdom.dlpay.water.framework.domain.TRegion;
+import com.supwisdom.dlpay.water.domain.TRegion;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
diff --git a/src/main/java/com/supwisdom/dlpay/water/framework/domain/TDevice.java b/src/main/java/com/supwisdom/dlpay/water/domain/TDevice.java
similarity index 95%
rename from src/main/java/com/supwisdom/dlpay/water/framework/domain/TDevice.java
rename to src/main/java/com/supwisdom/dlpay/water/domain/TDevice.java
index 9606edd..d93012b 100644
--- a/src/main/java/com/supwisdom/dlpay/water/framework/domain/TDevice.java
+++ b/src/main/java/com/supwisdom/dlpay/water/domain/TDevice.java
@@ -1,4 +1,4 @@
-package com.supwisdom.dlpay.water.framework.domain;
+package com.supwisdom.dlpay.water.domain;
import javax.persistence.*;
diff --git a/src/main/java/com/supwisdom/dlpay/water/framework/domain/TRegion.java b/src/main/java/com/supwisdom/dlpay/water/domain/TRegion.java
similarity index 97%
rename from src/main/java/com/supwisdom/dlpay/water/framework/domain/TRegion.java
rename to src/main/java/com/supwisdom/dlpay/water/domain/TRegion.java
index 29704bd..5c7c0d3 100644
--- a/src/main/java/com/supwisdom/dlpay/water/framework/domain/TRegion.java
+++ b/src/main/java/com/supwisdom/dlpay/water/domain/TRegion.java
@@ -1,4 +1,4 @@
-package com.supwisdom.dlpay.water.framework.domain;
+package com.supwisdom.dlpay.water.domain;
import javax.persistence.*;
diff --git a/src/main/java/com/supwisdom/dlpay/water/service/DeviceService.java b/src/main/java/com/supwisdom/dlpay/water/service/DeviceService.java
index 39bfebb..663a0a9 100644
--- a/src/main/java/com/supwisdom/dlpay/water/service/DeviceService.java
+++ b/src/main/java/com/supwisdom/dlpay/water/service/DeviceService.java
@@ -1,7 +1,7 @@
package com.supwisdom.dlpay.water.service;
import com.supwisdom.dlpay.framework.util.PageResult;
-import com.supwisdom.dlpay.water.framework.domain.TDevice;
+import com.supwisdom.dlpay.water.domain.TDevice;
import com.supwisdom.dlpay.water.system.bean.DeviceSearchBean;
import java.util.List;
@@ -24,4 +24,6 @@
boolean deleteDevice(Integer devino);
List<String> groupStatus();
+
+ PageResult<TDevice> queryDeviceByParams(DeviceSearchBean param);
}
diff --git a/src/main/java/com/supwisdom/dlpay/water/service/RegionService.java b/src/main/java/com/supwisdom/dlpay/water/service/RegionService.java
index 39f3c55..d894d8f 100644
--- a/src/main/java/com/supwisdom/dlpay/water/service/RegionService.java
+++ b/src/main/java/com/supwisdom/dlpay/water/service/RegionService.java
@@ -2,7 +2,7 @@
import com.supwisdom.dlpay.framework.util.PageResult;
import com.supwisdom.dlpay.water.system.bean.RegionSearchBean;
-import com.supwisdom.dlpay.water.framework.domain.TRegion;
+import com.supwisdom.dlpay.water.domain.TRegion;
import java.util.List;
import java.util.Map;
diff --git a/src/main/java/com/supwisdom/dlpay/water/service/impl/DeviceServiceImpl.java b/src/main/java/com/supwisdom/dlpay/water/service/impl/DeviceServiceImpl.java
index 67e661a..6d90f4e 100644
--- a/src/main/java/com/supwisdom/dlpay/water/service/impl/DeviceServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/water/service/impl/DeviceServiceImpl.java
@@ -3,20 +3,22 @@
import com.supwisdom.dlpay.framework.util.PageResult;
import com.supwisdom.dlpay.water.dao.DeviceDao;
import com.supwisdom.dlpay.water.dao.RegionDao;
-import com.supwisdom.dlpay.water.framework.domain.TDevice;
-import com.supwisdom.dlpay.water.framework.domain.TRegion;
+import com.supwisdom.dlpay.water.domain.TDevice;
+import com.supwisdom.dlpay.water.domain.TRegion;
import com.supwisdom.dlpay.water.service.DeviceService;
import com.supwisdom.dlpay.water.system.bean.DeviceSearchBean;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
-import org.springframework.http.ResponseEntity;
+import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import java.util.*;
@Service
public class DeviceServiceImpl implements DeviceService {
@@ -127,4 +129,27 @@
List<String> status = deviceDao.groupStatus();
return status == null || status.size() == 0 ? null : status;
}
+
+ @Override
+ public PageResult<TDevice> queryDeviceByParams(DeviceSearchBean param) {
+ Pageable pageable = PageRequest.of(param.getPageNo() - 1, param.getPageSize());
+ Specification<TDevice> specification = (Specification<TDevice>) (root, query, cb) -> {
+ List<Predicate> predicates = new ArrayList<>();
+ if (param.getDevino() != null) {
+ predicates.add(cb.equal(root.get("devino").as(Integer.class), param.getDevino()));
+ }
+ if (param.getRegino() != null) {
+ predicates.add(cb.equal(root.get("regino").as(Integer.class), param.getRegino()));
+ }
+ if (param.getDevistatus() != null) {
+ predicates.add(cb.equal(root.get("devistatus").as(String.class), param.getDevistatus()));
+ }
+ if (param.getDeviname() != null) {
+ predicates.add(cb.like(root.get("deviname"), "%" + param.getDeviname() + "%"));
+ }
+ Predicate[] pre = new Predicate[predicates.size()];
+ return query.where(predicates.toArray(pre)).getRestriction();
+ };
+ return new PageResult<>(deviceDao.findAll(specification, pageable));
+ }
}
diff --git a/src/main/java/com/supwisdom/dlpay/water/service/impl/RegionServiceImpl.java b/src/main/java/com/supwisdom/dlpay/water/service/impl/RegionServiceImpl.java
index 9b585ec..fe9b856 100644
--- a/src/main/java/com/supwisdom/dlpay/water/service/impl/RegionServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/water/service/impl/RegionServiceImpl.java
@@ -4,7 +4,7 @@
import com.supwisdom.dlpay.framework.util.StringUtil;
import com.supwisdom.dlpay.water.system.bean.RegionSearchBean;
import com.supwisdom.dlpay.water.dao.RegionDao;
-import com.supwisdom.dlpay.water.framework.domain.TRegion;
+import com.supwisdom.dlpay.water.domain.TRegion;
import com.supwisdom.dlpay.water.service.RegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
diff --git a/src/main/java/com/supwisdom/dlpay/water/system/bean/DeviceSearchBean.java b/src/main/java/com/supwisdom/dlpay/water/system/bean/DeviceSearchBean.java
index 3796de1..e2c742f 100644
--- a/src/main/java/com/supwisdom/dlpay/water/system/bean/DeviceSearchBean.java
+++ b/src/main/java/com/supwisdom/dlpay/water/system/bean/DeviceSearchBean.java
@@ -3,4 +3,40 @@
import com.supwisdom.dlpay.system.bean.PageBean;
public class DeviceSearchBean extends PageBean {
+ private String deviname;
+ private Integer devino;
+ private Integer regino;
+ private String devistatus;
+
+ public String getDeviname() {
+ return deviname;
+ }
+
+ public void setDeviname(String deviname) {
+ this.deviname = deviname;
+ }
+
+ public Integer getDevino() {
+ return devino;
+ }
+
+ public void setDevino(Integer devino) {
+ this.devino = devino;
+ }
+
+ public Integer getRegino() {
+ return regino;
+ }
+
+ public void setRegino(Integer regino) {
+ this.regino = regino;
+ }
+
+ public String getDevistatus() {
+ return devistatus;
+ }
+
+ public void setDevistatus(String devistatus) {
+ this.devistatus = devistatus;
+ }
}
diff --git a/src/main/kotlin/com/supwisdom/dlpay/water/controller/water_controller.kt b/src/main/kotlin/com/supwisdom/dlpay/water/controller/water_controller.kt
index 6a0d196..0086ee8 100644
--- a/src/main/kotlin/com/supwisdom/dlpay/water/controller/water_controller.kt
+++ b/src/main/kotlin/com/supwisdom/dlpay/water/controller/water_controller.kt
@@ -2,14 +2,15 @@
import com.supwisdom.dlpay.framework.ResponseBodyBuilder
import com.supwisdom.dlpay.framework.util.PageResult
-import com.supwisdom.dlpay.water.framework.domain.TDevice
-import com.supwisdom.dlpay.water.framework.domain.TRegion
+import com.supwisdom.dlpay.framework.util.TradeErrorCode
+import com.supwisdom.dlpay.framework.util.WaterErrorCode
+import com.supwisdom.dlpay.water.domain.TDevice
+import com.supwisdom.dlpay.water.domain.TRegion
import com.supwisdom.dlpay.water.service.DeviceService
import com.supwisdom.dlpay.water.system.bean.RegionSearchBean
import com.supwisdom.dlpay.water.service.RegionService
import com.supwisdom.dlpay.water.system.bean.DeviceSearchBean
import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.*
@@ -38,10 +39,10 @@
.data("regions", it)
.success())
}
- return ResponseEntity.ok(ResponseBodyBuilder.create().fail(HttpStatus.NOT_FOUND.value(), "区域未找到"))
+ return ResponseEntity.ok(ResponseBodyBuilder.create().fail(WaterErrorCode.DATA_NOTFOUND_ERROR, "区域未找到"))
} catch (ex: Exception) {
return ResponseEntity.ok(ResponseBodyBuilder.create()
- .exception(HttpStatus.INTERNAL_SERVER_ERROR.value(), ex, "服务器繁忙,请稍后再试"))
+ .exception(WaterErrorCode.PROCESS_ERROR, ex, "服务器繁忙,请稍后再试"))
}
}
@@ -52,7 +53,7 @@
@RequestParam("limit", defaultValue = "10", required = false) pageSize: Int): PageResult<TRegion> {
try {
if (pageNo < 1 || pageSize < 1) {
- return PageResult(400, "请求参数错误")
+ return PageResult(WaterErrorCode.REQUEST_DATA_ERROR, "请求参数错误")
}
val searchBean = RegionSearchBean().apply {
this.pageNo = pageNo
@@ -62,9 +63,9 @@
regionService.queryRegionsByParentId(searchBean)?.let {
return it
}
- return PageResult(404, "区域未找到")
+ return PageResult(WaterErrorCode.DATA_NOTFOUND_ERROR, "区域未找到")
} catch (ex: Exception) {
- return PageResult(500, "服务器繁忙,请稍后再试")
+ return PageResult(WaterErrorCode.PROCESS_ERROR, "服务器繁忙,请稍后再试")
}
}
@@ -75,7 +76,7 @@
@RequestParam("limit", defaultValue = "10", required = false) pageSize: Int): PageResult<TRegion> {
try {
if (pageNo < 1 || pageSize < 1) {
- return PageResult(400, "请求参数错误")
+ return PageResult(WaterErrorCode.REQUEST_DATA_ERROR, "请求参数错误")
}
val searchBean = RegionSearchBean().apply {
this.pageNo = pageNo
@@ -85,9 +86,9 @@
regionService.queryRegionsBySearchKey(searchBean)?.let {
return it
}
- return PageResult(404, "区域未找到")
+ return PageResult(WaterErrorCode.REQUEST_DATA_ERROR, "区域未找到")
} catch (ex: Exception) {
- return PageResult(500, "服务器繁忙,请稍后再试")
+ return PageResult(WaterErrorCode.PROCESS_ERROR, "服务器繁忙,请稍后再试")
}
}
@@ -95,17 +96,17 @@
@ResponseBody
fun getRegionTree(): ResponseEntity<Any> {
try {
- regionService.queryAllRegion()?.let {
+ regionService.queryAllRegion()?.let { it ->
regionService.getRegionTree(it, 0)?.let {
return ResponseEntity.ok(ResponseBodyBuilder.create()
.data("regions", it)
.success())
}
}
- return ResponseEntity.ok(ResponseBodyBuilder.create().fail(HttpStatus.NOT_FOUND.value(), "区域未找到"))
+ return ResponseEntity.ok(ResponseBodyBuilder.create().fail(WaterErrorCode.REQUEST_DATA_ERROR, "区域未找到"))
} catch (ex: Exception) {
return ResponseEntity.ok(ResponseBodyBuilder.create()
- .exception(HttpStatus.INTERNAL_SERVER_ERROR.value(), ex, "服务器繁忙,请稍后再试"))
+ .exception(WaterErrorCode.PROCESS_ERROR, ex, "服务器繁忙,请稍后再试"))
}
}
@@ -115,11 +116,11 @@
try {
if (null == region.regiName) {
return ResponseEntity.ok(ResponseBodyBuilder.create()
- .fail(HttpStatus.BAD_REQUEST.value(), "区域名不能为空"))
+ .fail(WaterErrorCode.REQUEST_DATA_ERROR, "区域名不能为空"))
}
if (!regionService.checkRegiName(region)) {
return ResponseEntity.ok(ResponseBodyBuilder.create()
- .fail(HttpStatus.BAD_REQUEST.value(), "区域名已存在"))
+ .fail(WaterErrorCode.REQUEST_DATA_ERROR, "区域名已存在"))
}
if (null == region.regino) {
@@ -129,7 +130,7 @@
.success())
} else {
ResponseEntity.ok(ResponseBodyBuilder.create()
- .fail(HttpStatus.INTERNAL_SERVER_ERROR.value(), "新增失败"))
+ .fail(WaterErrorCode.PROCESS_ERROR, "新增失败"))
}
} else {
return if (regionService.updateRegion(region)) {
@@ -138,12 +139,12 @@
.success())
} else {
ResponseEntity.ok(ResponseBodyBuilder.create()
- .fail(HttpStatus.INTERNAL_SERVER_ERROR.value(), "更新失败"))
+ .fail(WaterErrorCode.PROCESS_ERROR, "更新失败"))
}
}
} catch (ex: Exception) {
return ResponseEntity.ok(ResponseBodyBuilder.create()
- .exception(HttpStatus.INTERNAL_SERVER_ERROR.value(), ex, "服务器繁忙,请稍后再试"))
+ .exception(WaterErrorCode.PROCESS_ERROR, ex, "服务器繁忙,请稍后再试"))
}
}
@@ -153,11 +154,11 @@
try {
if (regionService.existSubRegion(regino)) {
return ResponseEntity.ok(ResponseBodyBuilder.create()
- .fail(HttpStatus.BAD_REQUEST.value(), "该区域存在子区域,删除失败"))
+ .fail(WaterErrorCode.REQUEST_DATA_ERROR ,"该区域存在子区域,删除失败"))
}
if (deviceService.existSubDevice(regino)) {
return ResponseEntity.ok(ResponseBodyBuilder.create()
- .fail(HttpStatus.BAD_REQUEST.value(), "该区域有关联设备,删除失败"))
+ .fail(WaterErrorCode.REQUEST_DATA_ERROR, "该区域有关联设备,删除失败"))
}
return if (regionService.deleteRegion(regino)) {
ResponseEntity.ok(ResponseBodyBuilder.create()
@@ -165,11 +166,11 @@
.success())
} else {
ResponseEntity.ok(ResponseBodyBuilder.create()
- .fail(HttpStatus.INTERNAL_SERVER_ERROR.value(), "删除失败"))
+ .fail(WaterErrorCode.PROCESS_ERROR, "删除失败"))
}
} catch (ex: Exception) {
return ResponseEntity.ok(ResponseBodyBuilder.create()
- .exception(HttpStatus.INTERNAL_SERVER_ERROR.value(), ex, "服务器繁忙,请稍后再试"))
+ .exception(WaterErrorCode.PROCESS_ERROR, ex, "服务器繁忙,请稍后再试"))
}
}
}
@@ -195,7 +196,7 @@
@RequestParam("limit", defaultValue = "10", required = false) pageSize: Int): PageResult<TDevice> {
try {
if (pageNo < 1 || pageSize < 1) {
- return PageResult(400, "请求参数错误")
+ return PageResult(WaterErrorCode.REQUEST_DATA_ERROR, "请求参数错误")
}
val searchBean = DeviceSearchBean().apply {
this.pageNo = pageNo
@@ -217,7 +218,7 @@
val checkResult = deviceService.checkParams(device)
if (checkResult["flag"] == false) {
return ResponseEntity.ok(ResponseBodyBuilder.create()
- .fail(HttpStatus.BAD_REQUEST.value(), checkResult["msg"].toString()))
+ .fail(TradeErrorCode.INPUT_DATA_ERROR, checkResult["msg"].toString()))
}
if (checkResult["type"].toString() == "update") {
return if (deviceService.updateDevice(device)) {
@@ -226,7 +227,7 @@
.success())
} else {
ResponseEntity.ok(ResponseBodyBuilder.create()
- .fail(HttpStatus.INTERNAL_SERVER_ERROR.value(), "更新失败"))
+ .fail(TradeErrorCode.PROCESS_ERROR, "更新失败"))
}
} else {
return if (deviceService.saveDevice(device)) {
@@ -235,12 +236,12 @@
.success())
} else {
ResponseEntity.ok(ResponseBodyBuilder.create()
- .fail(HttpStatus.INTERNAL_SERVER_ERROR.value(), "新增失败"))
+ .fail(WaterErrorCode.PROCESS_ERROR, "新增失败"))
}
}
} catch (ex: Exception) {
return ResponseEntity.ok(ResponseBodyBuilder.create()
- .exception(HttpStatus.INTERNAL_SERVER_ERROR.value(), ex, "服务器繁忙,请稍后再试"))
+ .exception(WaterErrorCode.PROCESS_ERROR, ex, "服务器繁忙,请稍后再试"))
}
}
@@ -258,7 +259,7 @@
.success())
} catch (ex: Exception) {
return ResponseEntity.ok(ResponseBodyBuilder.create()
- .exception(HttpStatus.INTERNAL_SERVER_ERROR.value(), ex, "服务器繁忙,请稍后再试"))
+ .exception(WaterErrorCode.PROCESS_ERROR, ex, "服务器繁忙,请稍后再试"))
}
}
@@ -272,11 +273,11 @@
.success())
} else {
ResponseEntity.ok(ResponseBodyBuilder.create()
- .fail(HttpStatus.INTERNAL_SERVER_ERROR.value(), "删除失败"))
+ .fail(WaterErrorCode.PROCESS_ERROR, "删除失败"))
}
} catch (ex: Exception) {
ResponseEntity.ok(ResponseBodyBuilder.create()
- .exception(HttpStatus.INTERNAL_SERVER_ERROR.value(), ex, "服务器繁忙,请稍后再试"))
+ .exception(WaterErrorCode.PROCESS_ERROR, ex, "服务器繁忙,请稍后再试"))
}
}
@@ -285,15 +286,44 @@
fun allStatus(): ResponseEntity<Any> {
try {
deviceService.groupStatus()?.let {
- return ResponseEntity.ok(ResponseBodyBuilder.create()
+ return ResponseEntity.ok(ResponseBodyBuilder.create()
.data("status", it)
.success())
}
return ResponseEntity.ok(ResponseBodyBuilder.create()
- .fail(HttpStatus.INTERNAL_SERVER_ERROR.value(), "查询失败"))
+ .fail(WaterErrorCode.PROCESS_ERROR, "查询失败"))
} catch (ex: Exception) {
return ResponseEntity.ok(ResponseBodyBuilder.create()
- .exception(HttpStatus.INTERNAL_SERVER_ERROR.value(), ex, "服务器繁忙,请稍后再试"))
+ .exception(WaterErrorCode.PROCESS_ERROR, ex, "服务器繁忙,请稍后再试"))
+ }
+ }
+
+ @GetMapping("/device/search")
+ @ResponseBody
+ fun queryRegions(@RequestParam("deviname", required = false) deviname: String,
+ @RequestParam("devino", required = false) devino: Int,
+ @RequestParam("regino", required = false) regino: Int,
+ @RequestParam("devistatus", required = false) devistatus: String,
+ @RequestParam("page", defaultValue = "1", required = false) pageNo: Int,
+ @RequestParam("limit", defaultValue = "10", required = false) pageSize: Int): PageResult<TDevice> {
+ try {
+ if (pageNo < 1 || pageSize < 1) {
+ return PageResult(WaterErrorCode.REQUEST_DATA_ERROR, "请求参数错误")
+ }
+ val searchBean = DeviceSearchBean().apply {
+ this.pageNo = pageNo
+ this.pageSize = pageSize
+ this.deviname = deviname
+ this.devino=devino
+ this.regino=regino
+ this.devistatus=devistatus
+ }
+ deviceService.queryDeviceByParams(searchBean)?.let {
+ return it
+ }
+ return PageResult(WaterErrorCode.DATA_NOTFOUND_ERROR, "区域未找到")
+ } catch (ex: Exception) {
+ return PageResult(WaterErrorCode.PROCESS_ERROR, "服务器繁忙,请稍后再试")
}
}
}
\ No newline at end of file
diff --git a/src/main/resources/templates/system/device/index.html b/src/main/resources/templates/system/device/index.html
index d8145a4..7ef64d6 100644
--- a/src/main/resources/templates/system/device/index.html
+++ b/src/main/resources/templates/system/device/index.html
@@ -70,8 +70,8 @@
// 渲染区域选择框
$.ajax({
url: '/region/all',
- type:'GET',
- success:function (data) {
+ type: 'GET',
+ success: function (data) {
if (data.retcode == '0') {
var html = '<option value="">请选择一个区域</option>'
var regions = data.regions
@@ -82,27 +82,27 @@
form.render('select')
}
},
- error:function (xhr) {
+ error: function (xhr) {
console.log(xhr)
}
})
// 渲染状态选择框
$.ajax({
- url:'device/status',
- type:'GET',
- success:function (data) {
+ url: 'device/status',
+ type: 'GET',
+ success: function (data) {
console.log(data)
if (data.retcode == 0) {
var html = '<option value="">请选择状态</option>'
var status = data.status
for (var i = 0; i < status.length; i++) {
- html += '<option value="' + status[i]+ '">' + status[i] + '</option>'
+ html += '<option value="' + status[i] + '">' + status[i] + '</option>'
}
$("#select-status").html(html);
form.render('select')
}
},
- error:function (xhr) {
+ error: function (xhr) {
console.log(xhr)
}
})
@@ -134,9 +134,20 @@
// 搜索按钮点击事件
$('#btn-search-device').click(function () {
- let key = $('#deviname-search-value').val();
+ var deviname = $('#deviname-search-value').val();
+ var devino = $('#devino-search-value').val();
+ var regino = $('#select-region').val();
+ var status = $('#select-status').val();
+ devino == '' ? 'null' : devino;
+ console.log(devino)
+ regino == "" ? 'null' : regino;
table.reload('devicetable', {
- where: {searchkey: key},
+ where: {
+ deviname: deviname,
+ devino: devino,
+ regino: regino,
+ devistatus: status
+ },
url: "/device/search"
});
});