From 9ae1c10cb364c8b499447a83a5cb387f8eb98cbd Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期五, 25 十月 2024 11:38:32 +0800
Subject: [PATCH] 类型Action查询、添加、移除接口上传

---
 /dev/null                                                                                                 |   67 -----------
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsTypeActionController.java    |   89 ++++++++++++++
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsTypeActionServiceI.java         |   40 ++++++
 Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/PLTypeActionDTO.java                  |   31 +++++
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsTypeActionServiceImpl.java |   97 ++++++++++++++++
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsAttributeController.java     |    7 
 6 files changed, 259 insertions(+), 72 deletions(-)

diff --git a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/PLTypeActionDTO.java b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/PLTypeActionDTO.java
new file mode 100644
index 0000000..99bae91
--- /dev/null
+++ b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/PLTypeActionDTO.java
@@ -0,0 +1,31 @@
+package com.vci.dto;
+
+import com.vci.corba.portal.data.PLAction;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 绫诲瀷Action鏁版嵁浼犺緭瀵硅薄
+ * @author ludc
+ * @date 2024/10/24 18:11
+ */
+@Data
+public class PLTypeActionDTO implements java.io.Serializable{
+
+    /**
+     * 绂佹淇敼杩欎釜鍊�
+     */
+    private static final long serialVersionUID = 2009350578651813261L;
+
+    /**
+     * Action鎵�鍦ㄧ殑涓氬姟绫诲瀷鍚�
+     */
+    private String plTypeName;
+
+    /**
+     * action瀵硅薄
+     */
+    private List<PLAction> actions;
+
+}
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsAttributeController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsAttributeController.java
index 2323993..e33e49b 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsAttributeController.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsAttributeController.java
@@ -48,10 +48,8 @@
      */
     private Logger logger = LoggerFactory.getLogger(getClass());
 
-
-
     /**
-     * 鑾峰彇鎵�鏈変笟鍔$被鍨嬶紙鏍戝舰缁撴瀯锛�
+     * 鑾峰彇鎵�鏈夊睘鎬э紙鏍戝舰缁撴瀯锛�
      * @return 鏌ヨ缁撴灉
      */
     @GetMapping( "/getTreeAttributes")
@@ -68,7 +66,6 @@
             return BaseResult.fail(exceptionMessage);
         }
     }
-
 
     /**
      * 灞炴�у垪琛�
@@ -109,7 +106,7 @@
     /**
      * 娣诲姞鍗曟潯灞炴�у埌灞炴�ф睜
      * @param osAttributeDTO
-     * @return 鍒楄〃鐨勫唴瀹�
+     * @return
      */
     @PostMapping( "/addAttribute")
     @VciBusinessLog(operateName = "娣诲姞灞炴��")
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsTypeActionController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsTypeActionController.java
new file mode 100644
index 0000000..9f96bde
--- /dev/null
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsTypeActionController.java
@@ -0,0 +1,89 @@
+package com.vci.web.controller;
+
+import com.vci.corba.common.PLException;
+import com.vci.dto.OsAttributeDTO;
+import com.vci.dto.PLActionClsDTO;
+import com.vci.dto.PLTypeActionDTO;
+import com.vci.starter.web.annotation.log.VciBusinessLog;
+import com.vci.starter.web.pagemodel.BaseResult;
+import com.vci.starter.web.util.VciBaseUtil;
+import com.vci.web.service.OsTypeActionServiceI;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.Arrays;
+
+/**
+ * 绫诲瀷Action绠$悊鎺у埗鍣�
+ * @author ludc
+ * @date 2024/10/24 17:36
+ */
+@RequestMapping("/typeActionController")
+@RestController
+public class OsTypeActionController {
+
+    @Resource
+    private OsTypeActionServiceI actionServiceI;
+
+    /**
+     * 鏃ュ織
+     */
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    /**
+     * 鏍规嵁涓氬姟绫诲瀷鍚嶈幏鍙栫被鍨媋ction
+     * @param typeName 鏌ヨ鏉′欢-涓氬姟绫诲瀷鍚嶇О
+     * @return 淇濆瓨缁撴灉
+     */
+    @GetMapping("/getTypeActionByType")
+    public BaseResult getTypeActionByType(String typeName){
+        try {
+            return BaseResult.dataList(actionServiceI.getTypeActionByType(typeName));
+        } catch (PLException e) {
+            BaseResult objectBaseResult = new BaseResult<>();
+            objectBaseResult.setCode(Integer.parseInt(e.code));
+            objectBaseResult.setMsg(Arrays.toString(e.messages));
+            return objectBaseResult;
+        }
+    }
+
+    /**
+     * 淇濆瓨绫诲瀷Action
+     * @param plActionDTO
+     * @return
+     */
+    @PostMapping( "/savePLTypeAction")
+    @VciBusinessLog(operateName = "娣诲姞灞炴��")
+    public BaseResult savePLTypeAction(@RequestBody PLTypeActionDTO plActionDTO) {
+        try {
+            return actionServiceI.savePLTypeAction(plActionDTO);
+        }catch (Exception e) {
+            e.printStackTrace();
+            String exceptionMessage = "淇濆瓨绫诲瀷Action鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e);
+            logger.error(exceptionMessage);
+            return BaseResult.fail(exceptionMessage);
+        }
+    }
+
+    /**
+     * 绉婚櫎绫诲瀷Action
+     * @param typeName
+     * @param typeActionOIds
+     * @return
+     */
+    @DeleteMapping( "/delPLTypeActions")
+    @VciBusinessLog(operateName = "绉婚櫎绫诲瀷Action")
+    public BaseResult delPLTypeActions(String typeName, String typeActionOIds) {
+        try {
+            return actionServiceI.delPLTypeActions(typeName,typeActionOIds);
+        }catch (Exception e) {
+            e.printStackTrace();
+            String exceptionMessage = "绉婚櫎绫诲瀷Action鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e);
+            logger.error(exceptionMessage);
+            return BaseResult.fail(exceptionMessage);
+        }
+    }
+
+}
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebActionController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebActionController.java
deleted file mode 100644
index a4dc923..0000000
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebActionController.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.vci.web.controller;
-
-import com.vci.starter.web.pagemodel.BaseResult;
-import com.vci.web.service.WebActionServiceI;
-import com.vci.web.util.WebUtil;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-/**
- * 骞冲彴瀹氫箟鐨刟ction
- * @author weidy
- * @date 2019/9/9 9:39
- */
-@Controller
-@RequestMapping("/webActionController")
-public class WebActionController  {
-
-    @Autowired
-    private WebActionServiceI actionService;
-
-
-    @RequestMapping("/getActionByOid")
-    @ResponseBody
-    public BaseResult getActionByOid(String oid){
-        try{
-            return BaseResult.success(actionService.getActionByOid(oid));
-        }catch (Exception e){
-            return BaseResult.fail(WebUtil.getErrorMsg(e));
-        }
-    }
-}
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsTypeActionServiceI.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsTypeActionServiceI.java
new file mode 100644
index 0000000..ba8dfdd
--- /dev/null
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsTypeActionServiceI.java
@@ -0,0 +1,40 @@
+package com.vci.web.service;
+
+import com.vci.corba.common.PLException;
+import com.vci.corba.portal.data.PLAction;
+import com.vci.dto.PLTypeActionDTO;
+import com.vci.starter.web.pagemodel.BaseResult;
+
+import java.util.List;
+
+/**
+ * 绫诲瀷Action绠$悊鏈嶅姟
+ * @author ludc
+ * @date 2024/10/24 17:02
+ */
+public interface OsTypeActionServiceI {
+
+    /**
+     * 鏍规嵁涓氬姟绫诲瀷鍚嶈幏鍙栫被鍨婣ction
+     * @param typeName 鏌ヨ鏉′欢-涓氬姟绫诲瀷鍚嶇О
+     * @return
+     */
+    List<PLAction> getTypeActionByType(String typeName) throws PLException;
+
+    /**
+     * 淇濆瓨绫诲瀷Action
+     * @param plActionDTO
+     * @return
+     */
+    BaseResult savePLTypeAction(PLTypeActionDTO plActionDTO) throws PLException;
+
+    /**
+     * 绉婚櫎绫诲瀷Action
+     * @param typeName 鎵�鍦ㄧ被鍨嬪悕
+     * @param typeActionOIds 绫诲瀷action
+     * @return
+     */
+    BaseResult delPLTypeActions(String typeName, String typeActionOIds) throws PLException;
+
+
+}
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/WebActionServiceI.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/WebActionServiceI.java
deleted file mode 100644
index dd7757e..0000000
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/WebActionServiceI.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.vci.web.service;
-
-import com.vci.starter.web.exception.VciBaseException;
-import com.vci.pagemodel.UIActionVO;
-
-/**
- * 骞冲彴鐨刟ction鏈嶅姟
- * @author weidy
- * @date 2019/9/9 13:38
- */
-public interface WebActionServiceI {
-    /**
-     * action瀵硅薄
-     * @param oid 涓婚敭
-     * @return
-     */
-    UIActionVO getActionByOid(String oid) throws VciBaseException;
-}
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsTypeActionServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsTypeActionServiceImpl.java
new file mode 100644
index 0000000..a3ae9f7
--- /dev/null
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsTypeActionServiceImpl.java
@@ -0,0 +1,97 @@
+package com.vci.web.service.impl;
+
+import com.vci.client.mw.ClientContextVariable;
+import com.vci.common.utility.ObjectUtility;
+import com.vci.corba.common.PLException;
+import com.vci.corba.portal.data.PLAction;
+import com.vci.corba.portal.data.PLTypeAction;
+import com.vci.dto.PLActionDTO;
+import com.vci.dto.PLTypeActionDTO;
+import com.vci.starter.web.pagemodel.BaseResult;
+import com.vci.starter.web.util.VciBaseUtil;
+import com.vci.web.service.OsTypeActionServiceI;
+import com.vci.web.util.Func;
+import com.vci.web.util.PlatformClientUtil;
+import com.vci.web.util.UITools;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * 绫诲瀷Action绠$悊鏈嶅姟
+ * @author ludc
+ * @date 2024/10/24 17:05
+ */
+@Service
+public class OsTypeActionServiceImpl implements OsTypeActionServiceI {
+
+    @Autowired
+    private PlatformClientUtil platformClientUtil;
+
+    /**
+     * 鏍规嵁涓氬姟绫诲瀷鍚嶈幏鍙栫被鍨婣ction
+     * @param typeName 鏌ヨ鏉′欢-涓氬姟绫诲瀷鍚嶇О
+     * @return
+     */
+    @Override
+    public List<PLAction> getTypeActionByType(String typeName) throws PLException {
+        VciBaseUtil.alertNotNull(typeName,"鏌ヨ鏉′欢銆愮被鍨嬪悕銆�");
+        PLAction[] plActions = platformClientUtil.getUIService().getAllPLActionEntityByType(typeName);
+        return Arrays.asList(plActions);
+    }
+
+    /**
+     * 淇濆瓨绫诲瀷Action
+     * @param plActionDTO
+     * @return
+     */
+    @Override
+    public BaseResult savePLTypeAction(PLTypeActionDTO plActionDTO) throws PLException {
+        VciBaseUtil.alertNotNull(
+                plActionDTO,"娣诲姞鐨勭被鍨婣ction瀵硅薄",plActionDTO.getPlTypeName(),
+                plActionDTO.getActions(),"娣诲姞鐨凙ction鍒楄〃"
+        );
+        String typeName = plActionDTO.getPlTypeName();
+        PLAction[] dbActions = platformClientUtil.getUIService().getAllPLActionEntityByType(typeName);
+        List<PLAction> actions = plActionDTO.getActions();
+        //閬嶅巻鏁扮粍鍜宭ist锛屾瘮杈冩柊娣诲姞鐨勭储寮曡鏄惁宸茬粡瀛樺湪
+        for(PLAction ac: dbActions){
+            for(int i=0; i<actions.size(); i++){
+                if(actions.get(i).plOId.equals(ac.plOId)){
+                    return BaseResult.fail("宸插瓨鍦ㄥ悕绉颁负 銆�"+actions.get(i).plName+"銆� 鐨刟ction锛�");
+                }
+            }
+        }
+        for(int i=0;i<actions.size();i++){
+            PLTypeAction plTypeAction = new PLTypeAction(ObjectUtility.getNewObjectID36(), typeName, actions.get(i).plOId);
+            boolean res = UITools.getService().savePLTypeActionEntity(plTypeAction);
+            if(!res){
+                return BaseResult.fail("绫诲瀷action淇濆瓨澶辫触锛�");
+            }
+        }
+        return BaseResult.success("绫诲瀷action淇濆瓨鎴愬姛锛�");
+    }
+
+    /**
+     * 绉婚櫎绫诲瀷Action
+     * @param typeName 鎵�鍦ㄧ被鍨嬪悕
+     * @param typeActionOIds 绫诲瀷action
+     * @return
+     */
+    @Override
+    public BaseResult delPLTypeActions(String typeName, String typeActionOIds) throws PLException {
+        VciBaseUtil.alertNotNull(typeName,"绫诲瀷鍚�",typeActionOIds,"寰呯Щ闄ょ殑绫诲瀷action涓婚敭闆嗗悎");
+        List<String> taOIds = Func.toStrList(typeActionOIds);
+        for (String taOId : taOIds) {
+            boolean res = UITools.getService().deletePLTypeActionEntityByTypeAndAction(typeName, taOId);
+            if(!res){
+                return BaseResult.success("绫诲瀷Action绉婚櫎澶辫触锛�");
+            }
+        }
+        return BaseResult.success("绫诲瀷Action绉婚櫎鎴愬姛锛�");
+    }
+
+}
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebActionServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebActionServiceImpl.java
deleted file mode 100644
index 7dcc7ee..0000000
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebActionServiceImpl.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package com.vci.web.service.impl;
-
-//import com.vci.client.portal.utility.UITools;
-import com.vci.corba.common.PLException;
-import com.vci.corba.portal.data.PLAction;
-import com.vci.starter.web.exception.VciBaseException;
-import com.vci.pagemodel.UIActionVO;
-import com.vci.web.service.WebActionServiceI;
-import com.vci.web.util.PlatformClientUtil;
-import com.vci.web.util.WebUtil;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-/**
- * Action鏈嶅姟
- * @author weidy
- * @date 2019/9/9 13:40
- */
-@Service
-public class WebActionServiceImpl implements WebActionServiceI {
-
-    /**
-     * 骞冲彴鐨勮皟鐢ㄥ伐鍏风被
-     */
-    @Autowired
-    private PlatformClientUtil platformClientUtil;
-
-    /**
-     * action瀵硅薄
-     *
-     * @param oid 涓婚敭
-     * @return
-     */
-    @Override
-    public UIActionVO getActionByOid(String oid) throws VciBaseException {
-        WebUtil.alertNotNull(oid,"action鐨勪富閿�");
-        try {
-            PLAction action = platformClientUtil.getUIService()
-                    .getPLActionById(oid);
-            if(action == null || StringUtils.isBlank(action.plOId)){
-                throw new VciBaseException("杩欎釜action鍦ㄧ郴缁熶腑涓嶅瓨鍦�");
-            }
-            return convertWebAction(action);
-        } catch (PLException vciError) {
-           throw WebUtil.getVciBaseException(vciError);
-        }
-    }
-
-    private UIActionVO convertWebAction(PLAction action){
-       UIActionVO UIActionVO = new UIActionVO();
-//        UIActionVO.setPlActionCls(action.plActionCls);
-//        UIActionVO.setPlBSUrl(action.plBSUrl);
-//        UIActionVO.setPlCode(action.plCode);
-//        UIActionVO.setPlCreateTime(action.plCreateTime);
-//        UIActionVO.setPlCreateUser(action.plCreateUser);
-//        UIActionVO.setPlCSClass(action.plCSClass);
-//        UIActionVO.setPlDesc(action.plDesc);
-//        UIActionVO.setPlLicensOrs(action.plLicensOrs);
-//        UIActionVO.setPlModifyTime(action.plModifyTime);
-//        UIActionVO.setPlModifyUser(action.plModifyUser);
-//        UIActionVO.setPlName(action.plName);
-//        UIActionVO.setPlOId(action.plOId);
-//        UIActionVO.setPlTypeType(action.plTypeType);
-        return UIActionVO;
-    }
-}

--
Gitblit v1.9.3