From 53e7dce8d55487cbac64e4374ec9aa1b52a6c6ed Mon Sep 17 00:00:00 2001
From: SZH <szh_hello@163.com>
Date: Thu, 09 Mar 2023 21:16:43 +0800
Subject: [PATCH] 解决npe问题
---
equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/controller/SafeMaterialController.java | 33 +++++++++++++++++++++++++--------
1 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/controller/SafeMaterialController.java b/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/controller/SafeMaterialController.java
index 558b456..2c86fc8 100644
--- a/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/controller/SafeMaterialController.java
+++ b/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/controller/SafeMaterialController.java
@@ -1,8 +1,12 @@
package com.gkhy.safePlatform.equipment.controller;
import com.alibaba.fastjson.JSONObject;
+import com.gkhy.safePlatform.commons.co.ContextCacheUser;
+import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.commons.query.PageQuery;
+import com.gkhy.safePlatform.commons.utils.PageUtils;
import com.gkhy.safePlatform.commons.vo.ResultVO;
+import com.gkhy.safePlatform.equipment.model.dto.req.ParamForm;
import com.gkhy.safePlatform.equipment.model.dto.req.SafeMaterialAddReq;
import com.gkhy.safePlatform.equipment.model.dto.req.SafeMaterialModReq;
import com.gkhy.safePlatform.equipment.model.dto.req.SafeMaterialQuery;
@@ -23,34 +27,47 @@
@PostMapping(value = "save")
public ResultVO save(Authentication authentication, @Validated @RequestBody SafeMaterialAddReq req){
- return safeMaterialService.save(req);
+ ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
+ return safeMaterialService.save(currentUser,req);
}
@PostMapping(value = "update")
public ResultVO update(Authentication authentication, @Validated @RequestBody SafeMaterialModReq req){
- return safeMaterialService.update(req);
+ ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
+ return safeMaterialService.update(currentUser,req);
}
@PostMapping(value = "delete")
public ResultVO delete(Authentication authentication, @RequestBody JSONObject jsonObject){
+ ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
Long id = jsonObject.getLong("id");
- return safeMaterialService.delete(id);
+ return safeMaterialService.delete(currentUser,id);
}
@PostMapping(value = "queryById")
public ResultVO queryById(Authentication authentication, @RequestBody JSONObject jsonObject){
+ ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
Long id = jsonObject.getLong("id");
- return safeMaterialService.queryById(id);
+ return safeMaterialService.queryById(currentUser,id);
}
@PostMapping(value = "list")
public ResultVO list(Authentication authentication){
- return safeMaterialService.list();
+ ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
+ return new ResultVO<>(ResultCodes.OK,safeMaterialService.list(currentUser));
+ }
+ @PostMapping(value = "listByDepId")
+ public ResultVO listByDepId(Authentication authentication){
+ ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
+ return new ResultVO<>(ResultCodes.OK,safeMaterialService.listByDepId(currentUser));
}
@PostMapping(value = "page/list")
public ResultVO listByPage(Authentication authentication,@RequestBody PageQuery<SafeMaterialQuery> pageQuery){
- return safeMaterialService.listByPage(pageQuery);
+ PageUtils.checkCheck(pageQuery);
+ ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
+ return safeMaterialService.listByPage(currentUser,pageQuery);
}
@PostMapping(value = "deleteBatch")
- public ResultVO deleteBatch(Authentication authentication, @RequestBody Long[] ids){
- return safeMaterialService.deleteBatch(ids);
+ public ResultVO deleteBatch(Authentication authentication,@Validated @RequestBody ParamForm paramForm){
+ ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
+ return safeMaterialService.deleteBatch(currentUser,paramForm);
}
}
--
Gitblit v1.9.2