|
@@ -5,9 +5,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.util.Assert;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.thingsboard.server.common.data.yunteng.utils.ExcelUtil;
|
|
|
+import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
|
|
|
import org.thingsboard.server.domain.BaseOutput;
|
|
|
import org.thingsboard.server.domain.NxKnowledgeDatabase;
|
|
|
import org.thingsboard.server.domain.NxRescueCar;
|
|
@@ -18,6 +20,8 @@ import org.thingsboard.server.service.nanxi.INxRescueCarService;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
|
|
|
|
|
|
* @author LF
|
|
@@ -41,8 +45,8 @@ public class NxRescueCarController {
|
|
|
*/
|
|
|
@ApiOperation(value = "分页查询", notes = "分页查询")
|
|
|
@PostMapping("/page")
|
|
|
- public BaseOutput<IPage> getNxRescueCarPage(@RequestBody NxRescueCar nxRescueCar) {
|
|
|
- return BaseOutput.success(nxRescueCarService.page(nxRescueCar));
|
|
|
+ public TkPageData<NxRescueCar> getNxRescueCarPage(@RequestBody NxRescueCar nxRescueCar) {
|
|
|
+ return nxRescueCarService.page(nxRescueCar);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -86,14 +90,18 @@ public class NxRescueCarController {
|
|
|
|
|
|
|
|
|
* 通过id删除
|
|
|
- * @param id id
|
|
|
+ * @param ids id
|
|
|
* @return Result
|
|
|
*/
|
|
|
@ApiOperation(value = "通过id删除", notes = "通过id删除")
|
|
|
- @DeleteMapping("/{id}")
|
|
|
- public BaseOutput removeById(@PathVariable Integer id) {
|
|
|
- log.info("删除救援车辆参数:{}", id);
|
|
|
- return nxRescueCarService.removeById(id) ? BaseOutput.successMsg("删除成功") : BaseOutput.failure("删除失败");
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
+ public BaseOutput removeById(@PathVariable String ids) {
|
|
|
+ log.info("删除救援车辆参数:{}", ids);
|
|
|
+ List<String> list = Arrays.asList(ids.split(","));
|
|
|
+ if (validDeleteParams(list)) {
|
|
|
+ return BaseOutput.failure("参数有误");
|
|
|
+ }
|
|
|
+ return nxRescueCarService.removeByIds(list) ? BaseOutput.successMsg("删除成功") : BaseOutput.failure("删除失败");
|
|
|
}
|
|
|
|
|
|
|
|
@@ -107,11 +115,14 @@ public class NxRescueCarController {
|
|
|
ExcelUtil.exportExcel(response, "用户信息", "user info", nxRescueCarService.listByExport(nxRescueCar), NxRescueCarExport.class);
|
|
|
}
|
|
|
|
|
|
+ private boolean validDeleteParams(List<String> list) {
|
|
|
+ return list.stream().anyMatch(item -> !StringUtils.isNumeric(item));
|
|
|
+ }
|
|
|
|
|
|
private void validIsNull(NxRescueCar nxRescueCar){
|
|
|
Assert.notNull(nxRescueCar.getCompanyId(), "所属单位不能为空");
|
|
|
Assert.notNull(nxRescueCar.getAreaCode(), "所属区域不能为空");
|
|
|
- Assert.notNull(nxRescueCar.getCarId(), "车辆名称不能为空");
|
|
|
+ Assert.notNull(nxRescueCar.getCarName(), "车辆名称不能为空");
|
|
|
Assert.notNull(nxRescueCar.getCarTypeCode(), "车辆类型不能为空");
|
|
|
Assert.notNull(nxRescueCar.getLiableId(), "责任人不能为空");
|
|
|
Assert.notNull(nxRescueCar.getContactId(), "联系人不能为空");
|