From ba94ceae1315174798ae1967ef62268c6d16cd5b Mon Sep 17 00:00:00 2001
From: Codex Assistant <codex@example.com>
Date: 星期一, 06 十月 2025 22:07:06 +0800
Subject: [PATCH] feat: 评审与活动相关改动 - backend(GraphQL): Activity schema 增加 updateActivityState(id, state);实现 resolver/service 仅更新 state=2 作为逻辑删除 - backend(GraphQL): region.graphqls 新增 Query leafRegions - backend(GraphQL): player.graphqls 的 projectReviewApplications 增加可选参数 regionId - backend(Service): listProjectReviewApplications 绑定 regionId 参数,修复 QueryParameterException - frontend(web): 新增 api/activity.js 的 updateActivityState 并接入 activity-list 删除逻辑 - frontend(web): review-list.vue 权限仅校验登录,移除角色限制;查询参数修正为 name/regionId - frontend(web): 删除未引用的 ActivityList.vue - frontend(web): projectReviewNew.js GraphQL 查询增加 name 参数

---
 backend/src/main/java/com/rongyichuang/user/service/UserService.java |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/backend/src/main/java/com/rongyichuang/user/service/UserService.java b/backend/src/main/java/com/rongyichuang/user/service/UserService.java
index 8ee3be7..a4c4913 100644
--- a/backend/src/main/java/com/rongyichuang/user/service/UserService.java
+++ b/backend/src/main/java/com/rongyichuang/user/service/UserService.java
@@ -5,6 +5,7 @@
 import com.rongyichuang.employee.repository.EmployeeRepository;
 import com.rongyichuang.judge.repository.JudgeRepository;
 import com.rongyichuang.player.repository.PlayerRepository;
+import com.rongyichuang.common.util.UserContextUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.stereotype.Service;
@@ -20,6 +21,9 @@
 @Service
 @Transactional
 public class UserService {
+
+    @Autowired
+    private UserContextUtil userContextUtil;
 
     private static final Logger logger = LoggerFactory.getLogger(UserService.class);
 
@@ -57,6 +61,39 @@
             if (password != null && !password.trim().isEmpty()) {
                 user.setPassword(passwordEncoder.encode(password));
             }
+
+            // 瑕嗙洊 wxOpenid / wxUnionid锛氬鏋滃綋鍓嶇櫥褰曠敤鎴锋湁openid/unionid锛屽苟涓庡簱涓笉鍚岋紝鍒欎互褰撳墠鐧诲綍瑕嗙洊
+            try {
+                Long currentUserId = userContextUtil != null ? userContextUtil.getCurrentUserId() : null;
+                if (currentUserId != null) {
+                    Optional<User> currentUserOpt = userRepository.findById(currentUserId);
+                    if (currentUserOpt.isPresent()) {
+                        User currentUser = currentUserOpt.get();
+                        String currentWxOpenid = currentUser.getWxOpenid();
+                        String currentWxUnionid = currentUser.getWxUnionid();
+
+                        boolean needUpdateWx = false;
+                        if (currentWxOpenid != null && !currentWxOpenid.trim().isEmpty()) {
+                            if (user.getWxOpenid() == null || !currentWxOpenid.equals(user.getWxOpenid())) {
+                                user.setWxOpenid(currentWxOpenid);
+                                needUpdateWx = true;
+                            }
+                        }
+                        if (currentWxUnionid != null && !currentWxUnionid.trim().isEmpty()) {
+                            if (user.getWxUnionid() == null || !currentWxUnionid.equals(user.getWxUnionid())) {
+                                user.setWxUnionid(currentWxUnionid);
+                                needUpdateWx = true;
+                            }
+                        }
+                        if (needUpdateWx) {
+                            logger.info("瑕嗙洊鐢ㄦ埛(wx)鏍囪瘑锛歱hone鍖归厤鐨勭敤鎴稩D={}, 浣跨敤褰撳墠鐧诲綍鐢ㄦ埛ID={} 鐨� openid/unionid 瑕嗙洊", user.getId(), currentUserId);
+                        }
+                    }
+                }
+            } catch (Exception ex) {
+                logger.warn("瑕嗙洊wxOpenid/unionid鏃跺彂鐢熷紓甯革紙蹇界暐锛屼笉闃绘柇鎶ュ悕娴佺▼锛夛細{}", ex.getMessage());
+            }
+
             return userRepository.save(user);
         } else {
             // 鐢ㄦ埛涓嶅瓨鍦紝鍒涘缓鏂扮敤鎴�
@@ -95,6 +132,13 @@
     }
 
     /**
+     * 鑾峰彇瀵嗙爜缂栫爜鍣�
+     */
+    public BCryptPasswordEncoder getPasswordEncoder() {
+        return passwordEncoder;
+    }
+
+    /**
      * 淇濆瓨鐢ㄦ埛鎵嬫満鍙风爜
      * 鏍稿績閫昏緫锛�
      * 1. 鏌ヨ褰撳墠t_user閲岄潰鏄惁瀛樺湪鐩稿悓鐨勭數璇濆彿鐮侊紝濡傛灉娌℃湁锛屽氨鏇存柊鍒板綋鍓島ser閲岄潰

--
Gitblit v1.8.0