From 4f3a98f19143865cdc1de4791e8a95d96bd40c65 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期五, 01 八月 2025 13:27:59 +0800
Subject: [PATCH] yys 密码已重置

---
 inspect-server/src/main/java/com/ruoyi/inspect/util/UserUtils.java |   90 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 90 insertions(+), 0 deletions(-)

diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/util/UserUtils.java b/inspect-server/src/main/java/com/ruoyi/inspect/util/UserUtils.java
new file mode 100644
index 0000000..4ea9c59
--- /dev/null
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/util/UserUtils.java
@@ -0,0 +1,90 @@
+package com.ruoyi.inspect.util;
+
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.deepoove.poi.data.PictureRenderData;
+import com.deepoove.poi.data.Pictures;
+import com.ruoyi.common.core.domain.entity.User;
+import com.ruoyi.framework.exception.ErrorException;
+import com.ruoyi.system.mapper.UserMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+/**
+ * Author: yuan
+ * Date: 2024-12-17 鏄熸湡浜� 10:35:50
+ * Description: User宸ュ叿绫�
+ */
+@Component
+public class UserUtils {
+    private static UserMapper userMapper;
+
+    private static String imgUrl;
+
+    @Autowired
+    public void setUserMapper(UserMapper userMapper) {
+        UserUtils.userMapper = userMapper;
+    }
+
+    @Autowired
+    public void setImgUrl(@Value("${file.path}") String imgUrl) {
+        UserUtils.imgUrl = imgUrl;
+    }
+
+    /**
+     * 閫氳繃浜哄憳id鑾峰彇鐢ㄦ埛绛惧悕鍦板潃
+     * @param userId 浜哄憳id
+     * @return 鐢ㄦ埛绛惧悕鍦板潃
+     */
+    public static String getUserSignatureUrl(Integer userId) {
+        String userSignatureUrl = null;
+        if (userId != null) {
+            userSignatureUrl = userMapper.selectOne(Wrappers.<User>lambdaQuery()
+                            .eq(User::getId, userId))
+                    .getSignatureUrl();
+            if (StringUtils.isBlank(userSignatureUrl)) {
+                throw new ErrorException("鎵句笉鍒拌浜哄憳绛惧悕");
+            }
+            return imgUrl + "\\" + userSignatureUrl;
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * 閫氳繃浜哄憳id鑾峰彇娓叉煋Word鐢ㄦ埛绛惧悕瀵硅薄
+     * @param userId 浜哄憳id
+     * @return 鐢ㄦ埛绛惧悕瀵硅薄 or null
+     */
+    public static PictureRenderData getFinalUserSignatureUrl(Integer userId) {
+        String userSignatureUrl = null;
+        if (userId != null) {
+            userSignatureUrl = userMapper.selectById(userId)
+                    .getSignatureUrl();
+            if (StringUtils.isBlank(userSignatureUrl)) {
+                throw new ErrorException("鎵句笉鍒拌浜哄憳绛惧悕");
+            }
+        }
+        return StringUtils.isNotBlank(userSignatureUrl) ? Pictures.ofLocal(imgUrl + "/" + userSignatureUrl).create() : null;
+    }
+
+
+    /**
+     * 閫氳繃鍚嶅瓧鑾峰彇娓叉煋Word鐢ㄦ埛绛惧悕瀵硅薄
+     * @param userName 浜哄憳鍚嶅瓧
+     * @return 鐢ㄦ埛绛惧悕瀵硅薄 or null
+     */
+    public static PictureRenderData getFinalUserSignatureUrl(String userName) {
+        String userSignatureUrl = null;
+        if (userName != null) {
+            userSignatureUrl = userMapper.selectOne(Wrappers.<User>lambdaQuery()
+                            .eq(User::getName, userName))
+                    .getSignatureUrl();
+            if (StringUtils.isBlank(userSignatureUrl)) {
+                throw new ErrorException("鎵句笉鍒拌浜哄憳绛惧悕");
+            }
+        }
+        return StringUtils.isNotBlank(userSignatureUrl) ? Pictures.ofLocal(imgUrl + "/" + userSignatureUrl).create() : null;
+    }
+}

--
Gitblit v1.9.3