|
|
@@ -1,6 +1,7 @@
|
|
|
package com.zsElectric.boot.business.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.zsElectric.boot.business.model.vo.applet.AppletUserInfoVO;
|
|
|
import com.zsElectric.boot.security.util.SecurityUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -113,39 +114,13 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> i
|
|
|
* @return 当前用户信息
|
|
|
*/
|
|
|
@Override
|
|
|
- public UserInfoVO getCurrentUserInfo() {
|
|
|
- // 从 Spring Security 上下文获取当前登录用户的ID
|
|
|
- // 注意:小程序用户token中的userId就是c_user_info表的ID
|
|
|
+ public AppletUserInfoVO getAppletUserInfo() {
|
|
|
+ // 从 Spring Security 上下文获取当前登录用户的ID 注意:小程序用户token中的userId就是c_user_info表的ID
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
-
|
|
|
- log.info("获取当前用户信息,userId: {}", userId);
|
|
|
-
|
|
|
- if (ObjectUtil.isNull(userId)) {
|
|
|
- log.warn("未获取到当前登录用户ID");
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- // 直接通过ID查询c_user_info表
|
|
|
- UserInfo userInfo = null;
|
|
|
- try {
|
|
|
- log.info("准备查询用户信息,userId: {}", userId);
|
|
|
- userInfo = this.getById(userId);
|
|
|
- log.info("查询结果: {}", userInfo != null ? "找到用户" : "未找到用户");
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("查询用户信息异常,userId: {}, 错误: {}", userId, e.getMessage(), e);
|
|
|
- throw e;
|
|
|
+ if(ObjectUtil.isNotNull(userId)) {
|
|
|
+ return this.baseMapper.getAppletUserInfo(userId);
|
|
|
}
|
|
|
-
|
|
|
- if (userInfo == null) {
|
|
|
- log.warn("未找到用户信息,userId: {}", userId);
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- log.info("获取用户信息成功,ID: {}, 昵称: {}, 手机号: {}",
|
|
|
- userInfo.getId(), userInfo.getNickName(), userInfo.getPhone());
|
|
|
-
|
|
|
- // 实体转换为VO
|
|
|
- return userInfoConverter.toVO(userInfo);
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
/**
|