Forráskód Böngészése

fix: fmtDict 空字典 key 导致前端报错 & 非扫码注册用户登录时 stationId 为 null 导致 NPE

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
skyline 2 napja
szülő
commit
bad77bc56c

+ 2 - 2
admin-web/src/utils/u.ts

@@ -696,7 +696,7 @@ const u = {
             }
 
             const dicts = Session.get("dicts");
-            if (u.isEmptyOrNull(dicts)) {
+            if (u.isEmptyOrNull(dicts) || u.isEmptyOrNull(dicts[type])) {
                 return '--'
             }
             let dict = dicts[type].find(k =>  k.value == v);
@@ -711,7 +711,7 @@ const u = {
             }
 
             const dicts = Session.get("dicts");
-            if (u.isEmptyOrNull(dicts)) {
+            if (u.isEmptyOrNull(dicts) || u.isEmptyOrNull(dicts[type])) {
                 return '';
             }
             let dict = dicts[type].find(k =>  k.value == v);

+ 3 - 1
car-wash-service/src/main/java/com/kym/service/impl/UserServiceImpl.java

@@ -187,7 +187,9 @@ public class UserServiceImpl extends MPJBaseServiceImpl<UserMapper, User> implem
         StpUtil.getSession().set("userId", user.getId());
         StpUtil.getSession().set("username", user.getUsername());
         StpUtil.getSession().set("mobilePhone", user.getMobilePhone());
-        StpUtil.getSession().set("stationId", user.getStationId());
+        if (user.getStationId() != null) {
+            StpUtil.getSession().set("stationId", user.getStationId());
+        }
         user.setLastLoginTime(LocalDateTime.now());
         updateById(user);
         LOGGER.info("用户:{}/{}登录成功,tokenName:{},tokenValue:{}", user.getMobilePhone(), user.getId(), StpUtil.getTokenName(), StpUtil.getTokenValue());