From 14255942c7a30ddac8f513c91b026ae34e17cfde Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期四, 16 五月 2024 17:55:26 +0800
Subject: [PATCH] 完善代码
---
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductCtrl.java | 51 +++++++++++++++++++++++++++++++++++----------------
1 files changed, 35 insertions(+), 16 deletions(-)
diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductCtrl.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductCtrl.java
index 0f93791..a3d01fc 100644
--- a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductCtrl.java
+++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductCtrl.java
@@ -6,15 +6,10 @@
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pmsGlobal.aop.Log;
-import com.dy.pmsGlobal.daoOth.OthFileMapper;
-import com.dy.pmsGlobal.dyFile.FileOperate;
-import com.dy.pmsGlobal.dyFile.FileRestVo;
-import com.dy.pmsGlobal.pojoOth.OthFile;
import com.dy.pmsGlobal.pojoPlt.PltProduct;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
@@ -46,22 +41,23 @@
* @return
*/
@PostMapping(path="save")
- @SsoPowerAop(power = "10100011")
+ @SsoPowerAop(power = "10300001")
@Log("淇濆瓨浜у搧淇℃伅")
- public BaseResponse<PltProduct> save(@RequestBody @Valid PltProduct pro, BindingResult bindingResult){
+ public BaseResponse<PltProduct> save(@RequestBody @Valid PltProduct pro,
+ BindingResult bindingResult){
pro.id = null;
- Long id;
+ int count;
try {
if (bindingResult != null && bindingResult.hasErrors()) {
return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
}
pro.setDeleted(false);
- id = proSv.save(pro);
+ count = proSv.save(pro);
}catch (Exception e){
log.error("淇濆瓨浜у搧寮傚父", e);
return BaseResponseUtils.buildException(e.getMessage());
}
- if (id <= 0) {
+ if (count <= 0) {
return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
} else {
return BaseResponseUtils.buildSuccess(true);
@@ -76,7 +72,7 @@
* @return
*/
@PostMapping(path="update")
- @SsoPowerAop(power = "10100011")
+ @SsoPowerAop(power = "10300001")
@Log("鏇存柊浜у搧淇℃伅")
public BaseResponse<PltProduct> update(@RequestBody @Valid PltProduct pro,BindingResult bindingResult){
int count;
@@ -102,14 +98,20 @@
* @return
*/
@GetMapping(path="delete")
- @SsoPowerAop(power = "10100011")
+ @SsoPowerAop(power = "10300001")
@Log("鍒犻櫎浜у搧淇℃伅")
- public BaseResponse<PltProduct> delete(String id){
+ public BaseResponse<Boolean> delete(String id){
+ int count;
try {
- return BaseResponseUtils.buildSuccess(proSv.delete(Long.parseLong(id)));
+ count = proSv.delete(Long.parseLong(id));
}catch (Exception e){
log.error("鍒犻櫎浜у搧寮傚父", e);
return BaseResponseUtils.buildException(e.getMessage());
+ }
+ if (count <= 0) {
+ return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
+ } else {
+ return BaseResponseUtils.buildSuccess(true);
}
}
@@ -119,7 +121,7 @@
* @return
*/
@GetMapping(path="one")
- @SsoPowerAop(power = "10100010") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
+ @SsoPowerAop(power = "10300000") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
@Log("鏍规嵁ID鏌ヨ浜у搧淇℃伅")
public BaseResponse<PltProduct> one(String id){
try{
@@ -138,7 +140,7 @@
* @return
*/
@PostMapping(path="some")
- @SsoPowerAop(power = "10100010")
+ @SsoPowerAop(power = "10300000")
@Log("鏌ヨ浜у搧淇℃伅")
public BaseResponse<QueryResultVo<List<PltProduct>>> some(@RequestBody QueryVo vo){
try {
@@ -149,4 +151,21 @@
return BaseResponseUtils.buildException(e.getMessage());
}
}
+
+ /**
+ * 鏌ヨ鎵�鏈変骇鍝�
+ * @return
+ */
+ @GetMapping(path="all")
+ @SsoPowerAop(power = "10300000")
+ @Log("鏌ヨ鎵�鏈変骇鍝�")
+ public BaseResponse<List<PltProduct>> all(){
+ try {
+ List<PltProduct> list = proSv.selectAll() ;
+ return BaseResponseUtils.buildSuccess(list);
+ }catch (Exception e){
+ log.error("鏌ヨ鎵�鏈変骇鍝佸紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
}
--
Gitblit v1.8.0