From 1b5a723592ea63e5eec0bdeef7855b9c40e9df71 Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期四, 03 七月 2025 17:46:35 +0800
Subject: [PATCH] art:三保-设计修改

---
 lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/aspect/EamDictAspect.java |   81 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 81 insertions(+), 0 deletions(-)

diff --git a/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/aspect/EamDictAspect.java b/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/aspect/EamDictAspect.java
new file mode 100644
index 0000000..77202b1
--- /dev/null
+++ b/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/aspect/EamDictAspect.java
@@ -0,0 +1,81 @@
+package org.jeecg.modules.eam.aspect;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import lombok.extern.slf4j.Slf4j;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.system.aspect.DicAspectService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * @Description: Dnc瀛楀吀aop绫�
+ * @Version: 1.0
+ */
+@Aspect
+@Component
+@Slf4j
+public class EamDictAspect {
+    @Autowired
+    private DicAspectService dicAspectService;
+
+    // 瀹氫箟鍒囩偣Pointcut
+    @Pointcut("execution(public * org.jeecg.modules.eam..*.*Controller.*(..))")
+    public void excudeService() {
+    }
+
+    @Around("excudeService()")
+    public Object  doAround(ProceedingJoinPoint pjp) throws Throwable {
+        long time1=System.currentTimeMillis();
+        Object result = pjp.proceed();
+        long time2=System.currentTimeMillis();
+        log.debug("鑾峰彇JSON鏁版嵁 鑰楁椂锛�"+(time2-time1)+"ms");
+        long start=System.currentTimeMillis();
+        this.parseDictText(result);
+        long end=System.currentTimeMillis();
+        log.debug("瑙f瀽娉ㄥ叆JSON鏁版嵁  鑰楁椂"+(end-start)+"ms");
+        return result;
+    }
+
+    /**
+     * 鏈柟娉曢拡瀵硅繑鍥炲璞′负Result 鐨処Page鐨勫垎椤靛垪琛ㄦ暟鎹繘琛屽姩鎬佸瓧鍏告敞鍏�
+     * 瀛楀吀娉ㄥ叆瀹炵幇 閫氳繃瀵瑰疄浣撶被娣诲姞娉ㄨВ@dict 鏉ユ爣璇嗛渶瑕佺殑瀛楀吀鍐呭,瀛楀吀鍒嗕负鍗曞瓧鍏竎ode鍗冲彲 锛宼able瀛楀吀 code table text閰嶅悎浣跨敤涓庡師鏉eecg鐨勭敤娉曠浉鍚�
+     * 绀轰緥涓篠ysUser   瀛楁涓簊ex 娣诲姞浜嗘敞瑙Dict(dicCode = "sex") 浼氬湪瀛楀吀鏈嶅姟绔嬮┈鏌ュ嚭鏉ュ搴旂殑text 鐒跺悗鍦ㄨ姹俵ist鐨勬椂鍊欏皢杩欎釜瀛楀吀text锛屽凡瀛楁鍚嶇О鍔燺dictText褰㈠紡杩斿洖鍒板墠绔�
+     * 渚嬭緭鍏ュ綋鍓嶈繑鍥炲�肩殑灏变細澶氬嚭涓�涓猻ex_dictText瀛楁
+     * {
+     *      sex:1,
+     *      sex_dictText:"鐢�"
+     * }
+     * 鍓嶇鐩存帴鍙栧�約ext_dictText鍦╰able閲岄潰鏃犻渶鍐嶈繘琛屽墠绔殑瀛楀吀杞崲浜�
+     *  customRender:function (text) {
+     *               if(text==1){
+     *                 return "鐢�";
+     *               }else if(text==2){
+     *                 return "濂�";
+     *               }else{
+     *                 return text;
+     *               }
+     *             }
+     *             鐩墠vue鏄繖涔堣繘琛屽瓧鍏告覆鏌撳埌table涓婄殑澶氫簡灏卞緢楹荤儲浜� 杩欎釜鐩存帴鍦ㄦ湇鍔$娓叉煋瀹屾垚鍓嶇鍙互鐩存帴鐢�
+     * @param result
+     */
+    private void parseDictText(Object result) {
+        if (result instanceof Result) {
+            if (((Result) result).getResult() instanceof IPage) {
+                List<JSONObject> items = dicAspectService.detailDict(((IPage) ((Result) result).getResult()).getRecords());
+                ((IPage) ((Result) result).getResult()).setRecords(items);
+            }
+            else if(((Result) result).getResult() instanceof List){
+                List<JSONObject> items = dicAspectService.detailDict(((List) ((Result) result).getResult()));
+                ((Result) result).setResult(items);
+            }
+        }
+    }
+
+}

--
Gitblit v1.9.3