Commit 028c99aa10dff05d2acbcb6fbd99667a4bce057b
1 parent
03ef1fc7
完成 user-admin-server 的用户手机 + 密码登录
Showing
23 changed files
with
69 additions
and
39 deletions
README.md
| ... | ... | @@ -88,7 +88,7 @@ |
| 88 | 88 | | `yudao-admin-ui` | 管理后台的 UI 界面 | |
| 89 | 89 | | `yudao-user-server` | 用户前台的服务端 | |
| 90 | 90 | | `yudao-user-ui` | 用户前台的 UI 界面 | |
| 91 | -| `yudao-core-service` | 通用服务,提供共享逻辑 | | |
| 91 | +| `yudao-core-service` | 公共服务,提供共享逻辑 | | |
| 92 | 92 | |
| 93 | 93 | > 友情提示:`yudao-admin-server` 和 `yudao-user-server` 会存在需要复用的逻辑,通过 `yudao-core-service` 实现。 |
| 94 | 94 | ... | ... |
http-client.env.json
yudao-dependencies/pom.xml
| ... | ... | @@ -26,7 +26,7 @@ |
| 26 | 26 | <druid.version>1.2.4</druid.version> |
| 27 | 27 | <mybatis-plus.version>3.4.2</mybatis-plus.version> |
| 28 | 28 | <dynamic-datasource.version>3.3.2</dynamic-datasource.version> |
| 29 | - <redisson.version>3.15.1</redisson.version> | |
| 29 | + <redisson.version>3.16.3</redisson.version> | |
| 30 | 30 | <!-- Config 配置中心相关 --> |
| 31 | 31 | <apollo.version>1.7.0</apollo.version> |
| 32 | 32 | <!-- Job 定时任务相关 --> | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/enums/MbrErrorCodeConstants.java
| ... | ... | @@ -9,9 +9,4 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode; |
| 9 | 9 | */ |
| 10 | 10 | public interface MbrErrorCodeConstants { |
| 11 | 11 | |
| 12 | - // ========== AUTH 模块 1004000000 ========== | |
| 13 | - ErrorCode AUTH_LOGIN_BAD_CREDENTIALS = new ErrorCode(1004000000, "登录失败,账号密码不正确"); | |
| 14 | - ErrorCode AUTH_LOGIN_USER_DISABLED = new ErrorCode(1004000001, "登录失败,账号被禁用"); | |
| 15 | - ErrorCode AUTH_LOGIN_FAIL_UNKNOWN = new ErrorCode(1004000002, "登录失败"); // 登录失败的兜底,未知原因 | |
| 16 | - | |
| 17 | 12 | } | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/service/package-info.java
0 → 100644
| 1 | +package cn.iocoder.yudao.userserver.modules.member.service; | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/controller/auth/SysAuthController.http
0 → 100644
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/auth/MbrAuthController.java renamed to yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/controller/auth/SysAuthController.java
| 1 | -package cn.iocoder.yudao.userserver.modules.member.controller.auth; | |
| 1 | +package cn.iocoder.yudao.userserver.modules.system.controller.auth; | |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | -import cn.iocoder.yudao.userserver.modules.member.controller.auth.vo.*; | |
| 5 | -import cn.iocoder.yudao.userserver.modules.member.service.auth.MbrAuthService; | |
| 4 | +import cn.iocoder.yudao.userserver.modules.system.controller.auth.vo.*; | |
| 5 | +import cn.iocoder.yudao.userserver.modules.system.service.auth.SysAuthService; | |
| 6 | 6 | import io.swagger.annotations.Api; |
| 7 | 7 | import io.swagger.annotations.ApiImplicitParam; |
| 8 | 8 | import io.swagger.annotations.ApiImplicitParams; |
| ... | ... | @@ -23,14 +23,14 @@ import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getUse |
| 23 | 23 | @RequestMapping("/") |
| 24 | 24 | @Validated |
| 25 | 25 | @Slf4j |
| 26 | -public class MbrAuthController { | |
| 26 | +public class SysAuthController { | |
| 27 | 27 | |
| 28 | 28 | @Resource |
| 29 | - private MbrAuthService authService; | |
| 29 | + private SysAuthService authService; | |
| 30 | 30 | |
| 31 | 31 | @PostMapping("/login") |
| 32 | 32 | @ApiOperation("使用手机 + 密码登录") |
| 33 | - public CommonResult<MbrAuthLoginRespVO> login(@RequestBody @Valid MbrAuthLoginReqVO reqVO) { | |
| 33 | + public CommonResult<MbrAuthLoginRespVO> login(@RequestBody @Valid SysAuthLoginReqVO reqVO) { | |
| 34 | 34 | String token = authService.login(reqVO, getClientIP(), getUserAgent()); |
| 35 | 35 | // 返回结果 |
| 36 | 36 | return success(MbrAuthLoginRespVO.builder().token(token).build()); |
| ... | ... | @@ -38,7 +38,7 @@ public class MbrAuthController { |
| 38 | 38 | |
| 39 | 39 | @PostMapping("/sms-login") |
| 40 | 40 | @ApiOperation("使用手机 + 验证码登录") |
| 41 | - public CommonResult<MbrAuthLoginRespVO> smsLogin(@RequestBody @Valid MbrAuthLoginReqVO reqVO) { | |
| 41 | + public CommonResult<MbrAuthLoginRespVO> smsLogin(@RequestBody @Valid SysAuthLoginReqVO reqVO) { | |
| 42 | 42 | return null; |
| 43 | 43 | } |
| 44 | 44 | |
| ... | ... | @@ -53,7 +53,7 @@ public class MbrAuthController { |
| 53 | 53 | |
| 54 | 54 | @PostMapping("/reset-password") |
| 55 | 55 | @ApiOperation(value = "重置密码", notes = "用户忘记密码时使用") |
| 56 | - public CommonResult<Boolean> resetPassword(@RequestBody @Valid MbrAuthResetPasswordReqVO reqVO) { | |
| 56 | + public CommonResult<Boolean> resetPassword(@RequestBody @Valid SysAuthResetPasswordReqVO reqVO) { | |
| 57 | 57 | return null; |
| 58 | 58 | } |
| 59 | 59 | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/auth/vo/MbrAuthLoginRespVO.java renamed to yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/controller/auth/vo/MbrAuthLoginRespVO.java
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/auth/vo/MbrAuthSendSmsReqVO.java renamed to yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/controller/auth/vo/MbrAuthSendSmsReqVO.java
| 1 | -package cn.iocoder.yudao.userserver.modules.member.controller.auth.vo; | |
| 1 | +package cn.iocoder.yudao.userserver.modules.system.controller.auth.vo; | |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.validation.Mobile; |
| 4 | 4 | import io.swagger.annotations.ApiModel; |
| ... | ... | @@ -21,4 +21,4 @@ public class MbrAuthSendSmsReqVO { |
| 21 | 21 | @NotNull(message = "发送场景不能为空") |
| 22 | 22 | private Integer scene; |
| 23 | 23 | |
| 24 | -} | |
| 25 | 24 | \ No newline at end of file |
| 25 | +} | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/auth/vo/MbrAuthSmsLoginReqVO.java renamed to yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/controller/auth/vo/MbrAuthSmsLoginReqVO.java
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/auth/vo/MbrAuthSocialBindReqVO.java renamed to yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/controller/auth/vo/MbrAuthSocialBindReqVO.java
| 1 | -package cn.iocoder.yudao.userserver.modules.member.controller.auth.vo; | |
| 1 | +package cn.iocoder.yudao.userserver.modules.system.controller.auth.vo; | |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 4 | 4 | import cn.iocoder.yudao.userserver.modules.member.enums.social.SysSocialTypeEnum; | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/auth/vo/MbrAuthSocialLogin2ReqVO.java renamed to yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/controller/auth/vo/MbrAuthSocialLogin2ReqVO.java
| 1 | -package cn.iocoder.yudao.userserver.modules.member.controller.auth.vo; | |
| 1 | +package cn.iocoder.yudao.userserver.modules.system.controller.auth.vo; | |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 4 | 4 | import cn.iocoder.yudao.userserver.modules.member.enums.social.SysSocialTypeEnum; | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/auth/vo/MbrAuthSocialLoginReqVO.java renamed to yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/controller/auth/vo/MbrAuthSocialLoginReqVO.java
| 1 | -package cn.iocoder.yudao.userserver.modules.member.controller.auth.vo; | |
| 1 | +package cn.iocoder.yudao.userserver.modules.system.controller.auth.vo; | |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 4 | 4 | import cn.iocoder.yudao.userserver.modules.member.enums.social.SysSocialTypeEnum; | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/auth/vo/MbrAuthSocialUnbindReqVO.java renamed to yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/controller/auth/vo/MbrAuthSocialUnbindReqVO.java
| 1 | -package cn.iocoder.yudao.userserver.modules.member.controller.auth.vo; | |
| 1 | +package cn.iocoder.yudao.userserver.modules.system.controller.auth.vo; | |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 4 | 4 | import cn.iocoder.yudao.userserver.modules.member.enums.social.SysSocialTypeEnum; | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/auth/vo/MbrAuthLoginReqVO.java renamed to yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/controller/auth/vo/SysAuthLoginReqVO.java
| 1 | -package cn.iocoder.yudao.userserver.modules.member.controller.auth.vo; | |
| 1 | +package cn.iocoder.yudao.userserver.modules.system.controller.auth.vo; | |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.validation.Mobile; |
| 4 | 4 | import io.swagger.annotations.ApiModel; |
| ... | ... | @@ -16,7 +16,7 @@ import javax.validation.constraints.NotEmpty; |
| 16 | 16 | @NoArgsConstructor |
| 17 | 17 | @AllArgsConstructor |
| 18 | 18 | @Builder |
| 19 | -public class MbrAuthLoginReqVO { | |
| 19 | +public class SysAuthLoginReqVO { | |
| 20 | 20 | |
| 21 | 21 | @ApiModelProperty(value = "手机号", required = true, example = "15601691300") |
| 22 | 22 | @NotEmpty(message = "手机号不能为空") | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/auth/vo/MbrAuthResetPasswordReqVO.java renamed to yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/controller/auth/vo/SysAuthResetPasswordReqVO.java
| 1 | -package cn.iocoder.yudao.userserver.modules.member.controller.auth.vo; | |
| 1 | +package cn.iocoder.yudao.userserver.modules.system.controller.auth.vo; | |
| 2 | 2 | |
| 3 | 3 | import io.swagger.annotations.ApiModel; |
| 4 | 4 | import io.swagger.annotations.ApiModelProperty; |
| ... | ... | @@ -16,7 +16,7 @@ import javax.validation.constraints.Pattern; |
| 16 | 16 | @NoArgsConstructor |
| 17 | 17 | @AllArgsConstructor |
| 18 | 18 | @Builder |
| 19 | -public class MbrAuthResetPasswordReqVO { | |
| 19 | +public class SysAuthResetPasswordReqVO { | |
| 20 | 20 | |
| 21 | 21 | @ApiModelProperty(value = "新密码", required = true, example = "buzhidao") |
| 22 | 22 | @NotEmpty(message = "新密码不能为空") | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/controller/package-info.java
0 → 100644
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/convert/user/MbrAuthConvert.java renamed to yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/convert/auth/MbrAuthConvert.java
| 1 | -package cn.iocoder.yudao.userserver.modules.member.convert.user; | |
| 1 | +package cn.iocoder.yudao.userserver.modules.system.convert.auth; | |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 4 | 4 | import cn.iocoder.yudao.framework.security.core.LoginUser; |
| 5 | 5 | import cn.iocoder.yudao.userserver.modules.member.dal.dataobject.user.MbrUserDO; |
| 6 | 6 | import org.mapstruct.Mapper; |
| 7 | +import org.mapstruct.Mapping; | |
| 7 | 8 | import org.mapstruct.factory.Mappers; |
| 8 | 9 | |
| 9 | 10 | @Mapper |
| ... | ... | @@ -11,6 +12,7 @@ public interface MbrAuthConvert { |
| 11 | 12 | |
| 12 | 13 | MbrAuthConvert INSTANCE = Mappers.getMapper(MbrAuthConvert.class); |
| 13 | 14 | |
| 15 | + @Mapping(source = "mobile", target = "username") | |
| 14 | 16 | LoginUser convert0(MbrUserDO bean); |
| 15 | 17 | |
| 16 | 18 | default LoginUser convert(MbrUserDO bean) { | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/enums/SysErrorCodeConstants.java
0 → 100644
| 1 | +package cn.iocoder.yudao.userserver.modules.system.enums; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.exception.ErrorCode; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * System 错误码枚举类 | |
| 7 | + * | |
| 8 | + * system 系统,使用 1-005-000-000 段 | |
| 9 | + */ | |
| 10 | +public interface SysErrorCodeConstants { | |
| 11 | + | |
| 12 | + // ========== AUTH 模块 1005000000 ========== | |
| 13 | + ErrorCode AUTH_LOGIN_BAD_CREDENTIALS = new ErrorCode(1005000000, "登录失败,账号密码不正确"); | |
| 14 | + ErrorCode AUTH_LOGIN_USER_DISABLED = new ErrorCode(1005000001, "登录失败,账号被禁用"); | |
| 15 | + ErrorCode AUTH_LOGIN_FAIL_UNKNOWN = new ErrorCode(1005000002, "登录失败"); // 登录失败的兜底,未知原因 | |
| 16 | + | |
| 17 | +} | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/service/auth/MbrAuthService.java renamed to yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/service/auth/SysAuthService.java
| 1 | -package cn.iocoder.yudao.userserver.modules.member.service.auth; | |
| 1 | +package cn.iocoder.yudao.userserver.modules.system.service.auth; | |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.security.core.service.SecurityAuthFrameworkService; |
| 4 | -import cn.iocoder.yudao.userserver.modules.member.controller.auth.vo.MbrAuthLoginReqVO; | |
| 4 | +import cn.iocoder.yudao.userserver.modules.system.controller.auth.vo.SysAuthLoginReqVO; | |
| 5 | 5 | |
| 6 | 6 | import javax.validation.Valid; |
| 7 | 7 | |
| ... | ... | @@ -12,7 +12,7 @@ import javax.validation.Valid; |
| 12 | 12 | * |
| 13 | 13 | * @author 芋道源码 |
| 14 | 14 | */ |
| 15 | -public interface MbrAuthService extends SecurityAuthFrameworkService { | |
| 15 | +public interface SysAuthService extends SecurityAuthFrameworkService { | |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * 手机 + 密码登录 |
| ... | ... | @@ -22,6 +22,6 @@ public interface MbrAuthService extends SecurityAuthFrameworkService { |
| 22 | 22 | * @param userAgent 用户 UA |
| 23 | 23 | * @return 身份令牌,使用 JWT 方式 |
| 24 | 24 | */ |
| 25 | - String login(@Valid MbrAuthLoginReqVO reqVO, String userIp, String userAgent); | |
| 25 | + String login(@Valid SysAuthLoginReqVO reqVO, String userIp, String userAgent); | |
| 26 | 26 | |
| 27 | 27 | } | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/service/auth/impl/MbrAuthServiceImpl.java renamed to yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/service/auth/impl/SysAuthServiceImpl.java
| 1 | -package cn.iocoder.yudao.userserver.modules.member.service.auth.impl; | |
| 1 | +package cn.iocoder.yudao.userserver.modules.system.service.auth.impl; | |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.coreservice.modules.system.service.auth.SysUserSessionCoreService; |
| 4 | 4 | import cn.iocoder.yudao.coreservice.modules.system.service.logger.SysLoginLogCoreService; |
| ... | ... | @@ -6,10 +6,10 @@ import cn.iocoder.yudao.coreservice.modules.system.service.logger.dto.SysLoginLo |
| 6 | 6 | import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; |
| 8 | 8 | import cn.iocoder.yudao.framework.security.core.LoginUser; |
| 9 | -import cn.iocoder.yudao.userserver.modules.member.controller.auth.vo.MbrAuthLoginReqVO; | |
| 10 | -import cn.iocoder.yudao.userserver.modules.member.convert.user.MbrAuthConvert; | |
| 9 | +import cn.iocoder.yudao.userserver.modules.system.controller.auth.vo.SysAuthLoginReqVO; | |
| 10 | +import cn.iocoder.yudao.userserver.modules.system.convert.auth.MbrAuthConvert; | |
| 11 | 11 | import cn.iocoder.yudao.userserver.modules.member.dal.dataobject.user.MbrUserDO; |
| 12 | -import cn.iocoder.yudao.userserver.modules.member.service.auth.MbrAuthService; | |
| 12 | +import cn.iocoder.yudao.userserver.modules.system.service.auth.SysAuthService; | |
| 13 | 13 | import cn.iocoder.yudao.userserver.modules.member.service.user.MbrUserService; |
| 14 | 14 | import cn.iocoder.yudao.coreservice.modules.system.enums.logger.SysLoginLogTypeEnum; |
| 15 | 15 | import cn.iocoder.yudao.coreservice.modules.system.enums.logger.SysLoginResultEnum; |
| ... | ... | @@ -30,7 +30,7 @@ import javax.annotation.Resource; |
| 30 | 30 | import java.util.Objects; |
| 31 | 31 | |
| 32 | 32 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 33 | -import static cn.iocoder.yudao.userserver.modules.member.enums.MbrErrorCodeConstants.*; | |
| 33 | +import static cn.iocoder.yudao.userserver.modules.system.enums.SysErrorCodeConstants.*; | |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * Auth Service 实现类 |
| ... | ... | @@ -39,7 +39,7 @@ import static cn.iocoder.yudao.userserver.modules.member.enums.MbrErrorCodeConst |
| 39 | 39 | */ |
| 40 | 40 | @Service |
| 41 | 41 | @Slf4j |
| 42 | -public class MbrAuthServiceImpl implements MbrAuthService { | |
| 42 | +public class SysAuthServiceImpl implements SysAuthService { | |
| 43 | 43 | |
| 44 | 44 | @Resource |
| 45 | 45 | @Lazy // 延迟加载,因为存在相互依赖的问题 |
| ... | ... | @@ -64,7 +64,7 @@ public class MbrAuthServiceImpl implements MbrAuthService { |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | @Override |
| 67 | - public String login(MbrAuthLoginReqVO reqVO, String userIp, String userAgent) { | |
| 67 | + public String login(SysAuthLoginReqVO reqVO, String userIp, String userAgent) { | |
| 68 | 68 | // 使用手机 + 密码,进行登录。 |
| 69 | 69 | LoginUser loginUser = this.login0(reqVO.getMobile(), reqVO.getPassword()); |
| 70 | 70 | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/service/package-info.java
0 → 100644
| 1 | +package cn.iocoder.yudao.userserver.modules.system.service; | ... | ... |
更新日志.md