From 1ea8eebfec5272842109a4ae58469a9be4eefabb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Thu, 24 Mar 2022 10:28:42 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E6=9B=B4=E6=96=B0=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E7=99=BB=E5=BD=95=20=E5=8D=95=E7=8B=AC=E7=9A=84?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/domain/model/XcxLoginUser.java | 24 +++++++++++++++++++ .../ruoyi/system/service/SysLoginService.java | 7 +++++- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/XcxLoginUser.java diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/XcxLoginUser.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/XcxLoginUser.java new file mode 100644 index 00000000..83313a0f --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/XcxLoginUser.java @@ -0,0 +1,24 @@ +package com.ruoyi.common.core.domain.model; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +/** + * 小程序登录用户身份权限 + * + * @author Lion Li + */ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +public class XcxLoginUser extends LoginUser { + + private static final long serialVersionUID = 1L; + + /** + * openid + */ + private String openid; + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/SysLoginService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/SysLoginService.java index be5aac26..34c8fe6c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/SysLoginService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/SysLoginService.java @@ -8,6 +8,7 @@ import com.ruoyi.common.constant.Constants; import com.ruoyi.common.core.domain.dto.RoleDTO; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.core.domain.model.XcxLoginUser; import com.ruoyi.common.core.service.LogininforService; import com.ruoyi.common.enums.DeviceType; import com.ruoyi.common.enums.UserStatus; @@ -150,7 +151,11 @@ public class SysLoginService { SysUser user = loadUserByOpenid(openid); // 此处可根据登录用户的数据不同 自行创建 loginUser - LoginUser loginUser = buildLoginUser(user); + XcxLoginUser loginUser = new XcxLoginUser(); + loginUser.setUserId(user.getUserId()); + loginUser.setUsername(user.getUserName()); + loginUser.setUserType(user.getUserType()); + loginUser.setOpenid(openid); // 生成token LoginHelper.loginByDevice(loginUser, DeviceType.XCX);