From 3b32adb6b7b8d40f85e84f8b1a775f2ec1df88af Mon Sep 17 00:00:00 2001
From: Administrator <zhubaomin>
Date: 星期四, 01 八月 2024 21:55:06 +0800
Subject: [PATCH] 2024-08-01 朱宝民 查询统计3个接口

---
 pipIrr-platform/pipIrr-web/pipIrr-web-operation/src/main/java/com/dy/pipIrrOperation/feedback/FeedbackCtrl.java |  117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 115 insertions(+), 2 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-operation/src/main/java/com/dy/pipIrrOperation/feedback/FeedbackCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-operation/src/main/java/com/dy/pipIrrOperation/feedback/FeedbackCtrl.java
index 32a36f4..dcc040c 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-operation/src/main/java/com/dy/pipIrrOperation/feedback/FeedbackCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-operation/src/main/java/com/dy/pipIrrOperation/feedback/FeedbackCtrl.java
@@ -1,9 +1,21 @@
 package com.dy.pipIrrOperation.feedback;
 
+import com.dy.common.aop.SsoAop;
+import com.dy.common.webUtil.BaseResponse;
+import com.dy.common.webUtil.BaseResponseUtils;
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pipIrrGlobal.pojoOp.OpeFeedback;
+import com.dy.pipIrrGlobal.voOp.Vofeedback;
+import io.swagger.v3.oas.annotations.Parameter;
+import jakarta.validation.Valid;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.http.MediaType;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.*;
 
 /**
  * @author ZhuBaoMin
@@ -19,4 +31,105 @@
 public class FeedbackCtrl {
     private final FeedbackSv feedbackSv;
 
+    /**
+     * 娣诲姞闂鍙嶉
+     * @param feedback
+     * @param bindingResult
+     * @return
+     */
+    @PostMapping(path = "add", consumes = MediaType.APPLICATION_JSON_VALUE)
+    @Transactional(rollbackFor = Exception.class)
+    @SsoAop
+    public BaseResponse<Boolean> add(@RequestBody @Valid OpeFeedback feedback, @Parameter(hidden = true) BindingResult bindingResult){
+        if (bindingResult != null && bindingResult.hasErrors()) {
+            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+        }
+        if (feedback.getFeedbackerId() == null){
+            return BaseResponseUtils.buildFail("璇蜂紶鍏ュ啘鎴穒d");
+        }
+        Integer rec = Optional.ofNullable(feedbackSv.add(feedback)).orElse(0);
+        if (rec == 0) {
+            return BaseResponseUtils.buildFail("娣诲姞澶辫触");
+        }
+        return BaseResponseUtils.buildSuccess(true);
+    }
+
+    /**
+     * 淇敼闂鍙嶉鐘舵��
+     * @param feedback
+     * @param bindingResult
+     * @return
+     */
+    @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE)
+    @Transactional(rollbackFor = Exception.class)
+    @SsoAop()
+    public BaseResponse<Boolean> update(@RequestBody @Parameter(description = "form琛ㄥ崟json鏁版嵁", required = true) @Valid OpeFeedback feedback, @Parameter(hidden = true) BindingResult bindingResult) {
+        if (bindingResult != null && bindingResult.hasErrors()) {
+            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+        }
+        if (feedback.getId() == null){
+            return BaseResponseUtils.buildFail("璇蜂紶鍏d");
+        }
+        if (feedback.getState() == null){
+            return BaseResponseUtils.buildFail("璇蜂紶鍏ョ姸鎬�");
+        }
+        int count ;
+        try {
+            count = feedbackSv.update(feedback);
+        } catch (Exception e) {
+            log.error("淇敼闂鍙嶉鐘舵�佸紓甯�", e);
+            return BaseResponseUtils.buildException(e.getMessage());
+        }
+        if (count <= 0) {
+            return BaseResponseUtils.buildFail("淇敼鐘舵�佸け璐�");
+        } else {
+            return BaseResponseUtils.buildSuccess(true);
+        }
+    }
+
+    /**
+     * 鍒犻櫎闂鍙嶉
+     * @param map
+     * @return
+     */
+    @PostMapping(path = "delete")
+    @Transactional(rollbackFor = Exception.class)
+    @SsoAop()
+    public BaseResponse<Boolean> delete(@RequestBody Map map) {
+        if (map == null || map.size() <= 0) {
+            return BaseResponseUtils.buildFail("璇蜂紶鍏d");
+        }
+        Long id = Long.parseLong(map.get("id").toString());
+        try {
+            Integer recordCount = Optional.ofNullable(feedbackSv.delete(id)).orElse(0);
+            if (recordCount == 0) {
+                return BaseResponseUtils.buildFail("鍒犻櫎澶辫触");
+            } else {
+                return BaseResponseUtils.buildSuccess(true);
+            }
+        } catch (Exception e) {
+            log.error("鍒犻櫎寮傚父", e);
+            return BaseResponseUtils.buildException(e.getMessage());
+        }
+    }
+
+    /**
+     * 鍒嗛〉鏌ヨ闂鍙嶉
+     * @param qo
+     * @return
+     */
+    @GetMapping(path = "getFeedbacks")
+    @SsoAop()
+    public BaseResponse<QueryResultVo<List<Vofeedback>>> getFeedbacks(QueryVo qo) {
+        try {
+            QueryResultVo<List<Vofeedback>> res = feedbackSv.getFeedbacks(qo);
+            if (res == null) {
+                return BaseResponseUtils.buildFail("鏌ヨ澶辫触");
+            }
+            return BaseResponseUtils.buildSuccess(res);
+        } catch (Exception e) {
+            log.error("鏌ヨ寮傚父", e);
+            return BaseResponseUtils.buildException(e.getMessage());
+        }
+    }
 }

--
Gitblit v1.8.0