From 68027b9f16d48bfe58bdc28cebd450a0eabe6731 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 17 May 2019 00:35:42 +0800 Subject: [PATCH 1/5] =?UTF-8?q?-=20=E5=90=8E=E7=AB=AF=EF=BC=9AUser=20?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=EF=BC=8C=E6=8E=A5=E5=85=A5=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E7=9A=84=20OAuth2=20=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/guides/功能列表/功能列表-管理后台.md | 10 ++-- mobile-web/src/page/account/phonelogin.vue | 2 +- .../iocoder/mall/admin/api/AdminService.java | 2 +- .../iocoder/mall/admin/api/OAuth2Service.java | 2 + .../api/bo/oauth2/OAuth2AuthenticationBO.java | 4 +- .../api/dto/oauth2/OAuth2CreateTokenDTO.java | 3 +- .../api/dto/oauth2/OAuth2GetTokenDTO.java | 3 +- .../mall/admin/service/OAuth2ServiceImpl.java | 1 + .../admin/service/SmsYunPianPlatform.java | 10 ++-- .../controller/users/PassportController.java | 14 ++--- .../user/sdk/context/UserSecurityContext.java | 20 +++---- .../context/UserSecurityContextHolder.java | 2 +- .../interceptor/UserSecurityInterceptor.java | 60 ++++++++++++------- user/user-service-api/pom.xml | 5 ++ .../iocoder/mall/user/api/OAuth2Service.java | 3 +- .../mall/user/api/UserAccessLogService.java | 1 + .../cn/iocoder/mall/user/api/UserService.java | 4 ++ .../api/bo/user/UserAuthenticationBO.java | 22 +++++++ .../UserAuthenticationByMobileCodeDTO.java | 29 +++++++++ .../mall/user/biz/convert/UserConvert.java | 8 ++- .../mall/user/biz/dao/MobileCodeMapper.java | 23 ++++--- .../user/biz/dataobject/MobileCodeDO.java | 9 ++- .../biz/service/MobileCodeServiceImpl.java | 35 +++++------ .../user/biz/service/OAuth2ServiceImpl.java | 21 ------- .../user/biz/service/UserServiceImpl.java | 43 ++++++++++++- .../main/resources/config/application.yaml | 17 +++--- .../resources/mapper/MobileCodeMapper.xml | 35 ----------- .../src/main/resources/mybatis-config.xml | 19 ------ 28 files changed, 229 insertions(+), 178 deletions(-) create mode 100644 user/user-service-api/src/main/java/cn/iocoder/mall/user/api/bo/user/UserAuthenticationBO.java create mode 100644 user/user-service-api/src/main/java/cn/iocoder/mall/user/api/dto/user/UserAuthenticationByMobileCodeDTO.java delete mode 100644 user/user-service-impl/src/main/resources/mapper/MobileCodeMapper.xml delete mode 100644 user/user-service-impl/src/main/resources/mybatis-config.xml diff --git a/docs/guides/功能列表/功能列表-管理后台.md b/docs/guides/功能列表/功能列表-管理后台.md index bb534edfc..be9b5190f 100644 --- a/docs/guides/功能列表/功能列表-管理后台.md +++ b/docs/guides/功能列表/功能列表-管理后台.md @@ -14,11 +14,11 @@ - [x] 发布商品 - [x] 商品列表 - [x] 展示类目 - - [ ] 品牌管理【待认领】 + - [ ] 品牌管理【开发中 @黑子】 - [ ] 订单管理 - [ ] 销售单 开发中 - [ ] 售后单 开发中 - - [ ] 订单评价【开发中】 + - [ ] 订单评价【开发中 @wang171776704】 - [ ] 会员管理 - [ ] 会员资料 20%【待认领】 - TODO 需要补充 @@ -33,8 +33,10 @@ - [ ] 系统管理 - [x] 员工管理 - [x] 角色管理 - - [ ] 权限管理 - - [ ] 短信管理 + - [x] 权限管理 + - [ ] 部门管理【待认领】 + - [x] 数据字典 + - [ ] 短信管理【开发中 @小范】 - [ ] 短信模板 - [ ] 发送日志 - [ ] 员工操作日志 diff --git a/mobile-web/src/page/account/phonelogin.vue b/mobile-web/src/page/account/phonelogin.vue index 66bf1921c..a17b071ff 100644 --- a/mobile-web/src/page/account/phonelogin.vue +++ b/mobile-web/src/page/account/phonelogin.vue @@ -69,7 +69,7 @@ export default { let that = this; let response = doPassportMobileRegister(this.mobile, this.code); response.then(data => { - setLoginToken(data.accessToken, data.refreshToken); + setLoginToken(data.token.accessToken, data.token.refreshToken); Dialog.alert({ title: '系统提示', message: '登陆成功', diff --git a/system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/AdminService.java b/system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/AdminService.java index da12818b9..dac695c57 100644 --- a/system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/AdminService.java +++ b/system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/AdminService.java @@ -17,7 +17,7 @@ import java.util.Map; public interface AdminService { /** - * 用户认证。认证成功后,返回认证信息 + * 管理员认证。认证成功后,返回认证信息 * * 实际上,就是用户名 + 密码登陆 * diff --git a/system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/OAuth2Service.java b/system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/OAuth2Service.java index ccc78681a..eadf0d373 100644 --- a/system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/OAuth2Service.java +++ b/system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/OAuth2Service.java @@ -20,6 +20,8 @@ public interface OAuth2Service { // TODO @see 刷新 token + void removeToken(Integer userId); // TODO 需要优化 + /** * 通过 accessToken 获得身份信息 * diff --git a/system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/bo/oauth2/OAuth2AuthenticationBO.java b/system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/bo/oauth2/OAuth2AuthenticationBO.java index dfd6abb19..2e5146538 100644 --- a/system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/bo/oauth2/OAuth2AuthenticationBO.java +++ b/system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/bo/oauth2/OAuth2AuthenticationBO.java @@ -5,10 +5,12 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.experimental.Accessors; +import java.io.Serializable; + @ApiModel("OAUTH2 认证 BO") @Data @Accessors(chain = true) -public class OAuth2AuthenticationBO { +public class OAuth2AuthenticationBO implements Serializable { @ApiModelProperty(value = "用户编号", required = true, example = "1") private Integer userId; diff --git a/system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/dto/oauth2/OAuth2CreateTokenDTO.java b/system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/dto/oauth2/OAuth2CreateTokenDTO.java index a70e2298f..fbd46456c 100644 --- a/system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/dto/oauth2/OAuth2CreateTokenDTO.java +++ b/system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/dto/oauth2/OAuth2CreateTokenDTO.java @@ -8,11 +8,12 @@ import lombok.Data; import lombok.experimental.Accessors; import javax.validation.constraints.NotNull; +import java.io.Serializable; @ApiModel("OAuth2 创建 Token DTO") @Data @Accessors(chain = true) -public class OAuth2CreateTokenDTO { +public class OAuth2CreateTokenDTO implements Serializable { @ApiModelProperty(value = "用户编号", required = true, example = "1") @NotNull(message = "用户编号不能为空") diff --git a/system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/dto/oauth2/OAuth2GetTokenDTO.java b/system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/dto/oauth2/OAuth2GetTokenDTO.java index 0b0d4862c..b2d2b602a 100644 --- a/system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/dto/oauth2/OAuth2GetTokenDTO.java +++ b/system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/dto/oauth2/OAuth2GetTokenDTO.java @@ -9,11 +9,12 @@ import lombok.experimental.Accessors; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import java.io.Serializable; @ApiModel("OAuth2 身份验证 DTO") @Data @Accessors(chain = true) -public class OAuth2GetTokenDTO { +public class OAuth2GetTokenDTO implements Serializable { @ApiModelProperty(value = "accessToken", required = true, example = "001e8f49b20e47f7b3a2de774497cd50") @NotEmpty(message = "accessToken 不能为空") diff --git a/system/system-service-impl/src/main/java/cn/iocoder/mall/admin/service/OAuth2ServiceImpl.java b/system/system-service-impl/src/main/java/cn/iocoder/mall/admin/service/OAuth2ServiceImpl.java index 5db47a9c1..035cf4edf 100644 --- a/system/system-service-impl/src/main/java/cn/iocoder/mall/admin/service/OAuth2ServiceImpl.java +++ b/system/system-service-impl/src/main/java/cn/iocoder/mall/admin/service/OAuth2ServiceImpl.java @@ -64,6 +64,7 @@ public class OAuth2ServiceImpl implements OAuth2Service { * * @param adminId 管理员编号 */ + @Override @Transactional public void removeToken(Integer adminId) { // 设置 access token 失效 diff --git a/system/system-service-impl/src/main/java/cn/iocoder/mall/admin/service/SmsYunPianPlatform.java b/system/system-service-impl/src/main/java/cn/iocoder/mall/admin/service/SmsYunPianPlatform.java index 8d852a9d3..80f4b3853 100644 --- a/system/system-service-impl/src/main/java/cn/iocoder/mall/admin/service/SmsYunPianPlatform.java +++ b/system/system-service-impl/src/main/java/cn/iocoder/mall/admin/service/SmsYunPianPlatform.java @@ -1,9 +1,9 @@ package cn.iocoder.mall.admin.service; +import cn.iocoder.common.framework.exception.ServiceException; import cn.iocoder.mall.admin.api.SmsPlatform; import cn.iocoder.mall.admin.api.constant.AdminErrorCodeEnum; import cn.iocoder.mall.admin.api.constant.SmsApplyStatusEnum; -import cn.iocoder.mall.admin.api.exception.SmsFailException; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -104,7 +104,7 @@ public class SmsYunPianPlatform implements SmsPlatform { String result = post(URL_SIGN_ADD, params); JSONObject jsonObject = JSON.parseObject(result); if (!(jsonObject.getInteger("code") == SUCCESS_CODE)) { - throw new SmsFailException(AdminErrorCodeEnum.SMS_SIGN_ADD_FAIL.getCode(), + throw new ServiceException(AdminErrorCodeEnum.SMS_SIGN_ADD_FAIL.getCode(), AdminErrorCodeEnum.SMS_SIGN_ADD_FAIL.getMessage()); } @@ -124,13 +124,13 @@ public class SmsYunPianPlatform implements SmsPlatform { JSONObject jsonObject = JSON.parseObject(result); if (!(jsonObject.getInteger("code") == SUCCESS_CODE)) { - throw new SmsFailException(AdminErrorCodeEnum.SMS_SIGN_ADD_FAIL.getCode(), + throw new ServiceException(AdminErrorCodeEnum.SMS_SIGN_ADD_FAIL.getCode(), AdminErrorCodeEnum.SMS_SIGN_ADD_FAIL.getMessage()); } JSONArray jsonArray = jsonObject.getJSONArray("sign"); if (jsonArray.size() <= 0) { - throw new SmsFailException(AdminErrorCodeEnum.SMS_SIGN_NOT_EXISTENT.getCode(), + throw new ServiceException(AdminErrorCodeEnum.SMS_SIGN_NOT_EXISTENT.getCode(), AdminErrorCodeEnum.SMS_SIGN_NOT_EXISTENT.getMessage()); } @@ -151,7 +151,7 @@ public class SmsYunPianPlatform implements SmsPlatform { JSONObject jsonObject = JSON.parseObject(result); if (!(jsonObject.getInteger("code") == SUCCESS_CODE)) { - throw new SmsFailException(AdminErrorCodeEnum.SMS_SIGN_UPDATE_FAIL.getCode(), + throw new ServiceException(AdminErrorCodeEnum.SMS_SIGN_UPDATE_FAIL.getCode(), AdminErrorCodeEnum.SMS_SIGN_UPDATE_FAIL.getMessage()); } diff --git a/user/user-application/src/main/java/cn/iocoder/mall/user/application/controller/users/PassportController.java b/user/user-application/src/main/java/cn/iocoder/mall/user/application/controller/users/PassportController.java index 80db85f14..c51c64ad7 100644 --- a/user/user-application/src/main/java/cn/iocoder/mall/user/application/controller/users/PassportController.java +++ b/user/user-application/src/main/java/cn/iocoder/mall/user/application/controller/users/PassportController.java @@ -5,13 +5,13 @@ import cn.iocoder.mall.user.api.MobileCodeService; import cn.iocoder.mall.user.api.OAuth2Service; import cn.iocoder.mall.user.api.UserService; import cn.iocoder.mall.user.api.bo.OAuth2AccessTokenBO; +import cn.iocoder.mall.user.api.bo.user.UserAuthenticationBO; +import cn.iocoder.mall.user.api.dto.user.UserAuthenticationByMobileCodeDTO; import cn.iocoder.mall.user.application.convert.PassportConvert; import cn.iocoder.mall.user.application.vo.users.UsersAccessTokenVO; -import cn.iocoder.mall.user.application.vo.users.UsersMobileRegisterVO; import cn.iocoder.mall.user.sdk.annotation.PermitAll; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.apache.dubbo.config.annotation.Reference; import org.springframework.web.bind.annotation.PostMapping; @@ -43,14 +43,8 @@ public class PassportController { @PermitAll @PostMapping("/mobile/register") @ApiOperation(value = "手机号 + 验证码登陆(注册)", notes = "如果手机对应的账号不存在,则会自动创建") - @ApiImplicitParams({ - @ApiImplicitParam(name = "mobile", value = "手机号", required = true, example = "15601691300"), - @ApiImplicitParam(name = "code", value = "验证码", required = true, example = "9999") - }) - public CommonResult mobileRegister(@RequestParam("mobile") String mobile, - @RequestParam("code") String code) { - OAuth2AccessTokenBO result = oauth2Service.getAccessToken(mobile, code); - return success(PassportConvert.INSTANCE.convert(result)); + public CommonResult mobileRegister(UserAuthenticationByMobileCodeDTO userAuthenticationByMobileCodeDTO) { + return success(userService.authenticationByMobileCode(userAuthenticationByMobileCodeDTO)); } @PermitAll diff --git a/user/user-sdk/src/main/java/cn/iocoder/mall/user/sdk/context/UserSecurityContext.java b/user/user-sdk/src/main/java/cn/iocoder/mall/user/sdk/context/UserSecurityContext.java index c43328309..c6ab1a707 100644 --- a/user/user-sdk/src/main/java/cn/iocoder/mall/user/sdk/context/UserSecurityContext.java +++ b/user/user-sdk/src/main/java/cn/iocoder/mall/user/sdk/context/UserSecurityContext.java @@ -1,18 +1,18 @@ package cn.iocoder.mall.user.sdk.context; +import lombok.Data; +import lombok.experimental.Accessors; + /** * User Security 上下文 */ +@Data +@Accessors(chain = true) public class UserSecurityContext { - private final Integer userId; + /** + * 用户编号 + */ + private Integer userId; - public UserSecurityContext(Integer userId) { - this.userId = userId; - } - - public Integer getUserId() { - return userId; - } - -} \ No newline at end of file +} diff --git a/user/user-sdk/src/main/java/cn/iocoder/mall/user/sdk/context/UserSecurityContextHolder.java b/user/user-sdk/src/main/java/cn/iocoder/mall/user/sdk/context/UserSecurityContextHolder.java index 09ca1bcd1..c63c1a43b 100644 --- a/user/user-sdk/src/main/java/cn/iocoder/mall/user/sdk/context/UserSecurityContextHolder.java +++ b/user/user-sdk/src/main/java/cn/iocoder/mall/user/sdk/context/UserSecurityContextHolder.java @@ -17,7 +17,7 @@ public class UserSecurityContextHolder { UserSecurityContext ctx = SECURITY_CONTEXT.get(); // 为空时,设置一个空的进去 if (ctx == null) { - ctx = new UserSecurityContext(null); + ctx = new UserSecurityContext(); SECURITY_CONTEXT.set(ctx); } return ctx; diff --git a/user/user-sdk/src/main/java/cn/iocoder/mall/user/sdk/interceptor/UserSecurityInterceptor.java b/user/user-sdk/src/main/java/cn/iocoder/mall/user/sdk/interceptor/UserSecurityInterceptor.java index 9404aa9bf..f559222f2 100644 --- a/user/user-sdk/src/main/java/cn/iocoder/mall/user/sdk/interceptor/UserSecurityInterceptor.java +++ b/user/user-sdk/src/main/java/cn/iocoder/mall/user/sdk/interceptor/UserSecurityInterceptor.java @@ -1,11 +1,14 @@ package cn.iocoder.mall.user.sdk.interceptor; -import cn.iocoder.common.framework.constant.MallConstants; +import cn.iocoder.common.framework.constant.UserTypeEnum; import cn.iocoder.common.framework.exception.ServiceException; import cn.iocoder.common.framework.util.HttpUtil; import cn.iocoder.common.framework.util.MallUtil; -import cn.iocoder.mall.user.api.OAuth2Service; -import cn.iocoder.mall.user.api.bo.OAuth2AuthenticationBO; +import cn.iocoder.common.framework.util.StringUtil; +import cn.iocoder.mall.admin.api.OAuth2Service; +import cn.iocoder.mall.admin.api.bo.oauth2.OAuth2AuthenticationBO; +import cn.iocoder.mall.admin.api.constant.AdminErrorCodeEnum; +import cn.iocoder.mall.admin.api.dto.oauth2.OAuth2GetTokenDTO; import cn.iocoder.mall.user.sdk.annotation.PermitAll; import cn.iocoder.mall.user.sdk.context.UserSecurityContext; import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder; @@ -18,40 +21,55 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** - * 安全拦截器 + * User 安全拦截器 */ @Component public class UserSecurityInterceptor extends HandlerInterceptorAdapter { - @Reference(validation = "true", version = "${dubbo.provider.OAuth2Service.version:1.0.0}") + @Reference(validation = "true", version = "${dubbo.consumer.OAuth2Service.version:1.0.0}") private OAuth2Service oauth2Service; @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { // 设置当前访问的用户类型。注意,即使未登陆,我们也认为是用户 - MallUtil.setUserType(request, MallConstants.USER_TYPE_USER); - // 校验访问令牌是否正确。若正确,返回授权信息 + MallUtil.setUserType(request, UserTypeEnum.USER.getValue()); + + // 根据 accessToken 获得认证信息,判断是谁 String accessToken = HttpUtil.obtainAuthorization(request); OAuth2AuthenticationBO authentication = null; - if (accessToken != null) { - authentication = oauth2Service.checkToken(accessToken); // TODO 芋艿,如果访问的地址无需登录,这里也不用抛异常 - // 添加到 SecurityContext - UserSecurityContext context = new UserSecurityContext(authentication.getUserId()); - UserSecurityContextHolder.setContext(context); - // 同时也记录管理员编号到 AdminAccessLogInterceptor 中。因为: - // AdminAccessLogInterceptor 需要在 AdminSecurityInterceptor 之前执行,这样记录的访问日志才健全 - // AdminSecurityInterceptor 执行后,会移除 AdminSecurityContext 信息,这就导致 AdminAccessLogInterceptor 无法获得管理员编号 - // 因此,这里需要进行记录 - if (authentication.getUserId() != null) { - MallUtil.setUserId(request, authentication.getUserId()); + ServiceException serviceException = null; + if (StringUtil.hasText(accessToken)) { + try { + authentication = oauth2Service.getAuthentication(new OAuth2GetTokenDTO().setAccessToken(accessToken) + .setUserType(UserTypeEnum.USER.getValue())); + } catch (ServiceException e) { + serviceException = e; } } - // 校验是否需要已授权 + + // 进行鉴权 HandlerMethod method = (HandlerMethod) handler; boolean isPermitAll = method.hasMethodAnnotation(PermitAll.class); - if (!isPermitAll && authentication == null) { - throw new ServiceException(-1, "未授权"); // TODO 这里要改下 + if (!isPermitAll) { // 如果需要鉴权 + if (serviceException != null) { // 认证失败,抛出上面认证失败的 ServiceException 异常 + throw serviceException; + } + if (authentication == null) { // 无认证信息,抛出未登陆 ServiceException 异常 + throw new ServiceException(AdminErrorCodeEnum.OAUTH2_NOT_LOGIN.getCode(), AdminErrorCodeEnum.OAUTH2_NOT_LOGIN.getMessage()); + } + // TODO 芋艿,后续拓展读取用户信息 } + + // 鉴权完成,初始化 AdminSecurityContext 上下文 + UserSecurityContext context = new UserSecurityContext(); + UserSecurityContextHolder.setContext(context); + if (authentication != null) { + context.setUserId(authentication.getUserId()); + MallUtil.setUserId(request, authentication.getUserId()); // 记录到 request 中,避免 AdminSecurityContext 后续清理掉后,其它地方需要用到 userId + // TODO 芋艿,后续拓展读取用户信息 + } + + // 返回成功 return super.preHandle(request, response, handler); } diff --git a/user/user-service-api/pom.xml b/user/user-service-api/pom.xml index 8054f41cd..92eade7ab 100644 --- a/user/user-service-api/pom.xml +++ b/user/user-service-api/pom.xml @@ -17,6 +17,11 @@ common-framework 1.0-SNAPSHOT + + cn.iocoder.mall + system-service-api + 1.0-SNAPSHOT + diff --git a/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/OAuth2Service.java b/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/OAuth2Service.java index 2a3ae3870..b6cbb6f27 100644 --- a/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/OAuth2Service.java +++ b/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/OAuth2Service.java @@ -4,10 +4,9 @@ package cn.iocoder.mall.user.api; import cn.iocoder.mall.user.api.bo.OAuth2AccessTokenBO; import cn.iocoder.mall.user.api.bo.OAuth2AuthenticationBO; +@Deprecated public interface OAuth2Service { - OAuth2AccessTokenBO getAccessToken(String mobile, String code); - /** * 校验访问令牌,获取身份信息( 不包括 accessToken 等等 ) * diff --git a/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/UserAccessLogService.java b/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/UserAccessLogService.java index 972d6e195..8e5fcaa6b 100644 --- a/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/UserAccessLogService.java +++ b/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/UserAccessLogService.java @@ -2,6 +2,7 @@ package cn.iocoder.mall.user.api; import cn.iocoder.mall.user.api.dto.UserAccessLogAddDTO; +@Deprecated public interface UserAccessLogService { void addUserAccessLog(UserAccessLogAddDTO userAccessLogAddDTO); diff --git a/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/UserService.java b/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/UserService.java index b97c94aeb..94b3d6031 100644 --- a/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/UserService.java +++ b/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/UserService.java @@ -2,13 +2,17 @@ package cn.iocoder.mall.user.api; import cn.iocoder.common.framework.constant.CommonStatusEnum; import cn.iocoder.common.framework.validator.InEnum; +import cn.iocoder.mall.user.api.bo.user.UserAuthenticationBO; import cn.iocoder.mall.user.api.bo.UserBO; import cn.iocoder.mall.user.api.bo.UserPageBO; import cn.iocoder.mall.user.api.dto.UserPageDTO; import cn.iocoder.mall.user.api.dto.UserUpdateDTO; +import cn.iocoder.mall.user.api.dto.user.UserAuthenticationByMobileCodeDTO; public interface UserService { + UserAuthenticationBO authenticationByMobileCode(UserAuthenticationByMobileCodeDTO userAuthenticationByMobileCodeDTO); + UserPageBO getUserPage(UserPageDTO userPageDTO); UserBO getUser(Integer userId); diff --git a/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/bo/user/UserAuthenticationBO.java b/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/bo/user/UserAuthenticationBO.java new file mode 100644 index 000000000..06e401011 --- /dev/null +++ b/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/bo/user/UserAuthenticationBO.java @@ -0,0 +1,22 @@ +package cn.iocoder.mall.user.api.bo.user; + +import cn.iocoder.mall.admin.api.bo.oauth2.OAuth2AccessTokenBO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +@ApiModel("用户认证 BO") +@Data +@Accessors(chain = true) +public class UserAuthenticationBO { + + @ApiModelProperty(value = "用户编号", required = true, example = "1") + private Integer id; + + @ApiModelProperty(value = "昵称", required = true, example = "小王") + private String nickname; + + private OAuth2AccessTokenBO token; + +} diff --git a/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/dto/user/UserAuthenticationByMobileCodeDTO.java b/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/dto/user/UserAuthenticationByMobileCodeDTO.java new file mode 100644 index 000000000..c63ca07ed --- /dev/null +++ b/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/dto/user/UserAuthenticationByMobileCodeDTO.java @@ -0,0 +1,29 @@ +package cn.iocoder.mall.user.api.dto.user; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; + +@ApiModel("用户认证 DTO") +@Data +@Accessors(chain = true) +public class UserAuthenticationByMobileCodeDTO { + + @ApiModelProperty(value = "手机号", required = true, example = "15601691300") + @NotEmpty(message = "手机号不能为空") + @Length(min = 11, max = 11, message = "账号长度为 11 位") + @Pattern(regexp = "^[0-9]+$", message = "手机号必须都是数字") + private String mobile; + + @ApiModelProperty(value = "手机验证码", required = true, example = "1024") + @NotEmpty(message = "手机验证码不能为空") + @Length(min = 4, max = 6, message = "手机验证码长度为 4-6 位") + @Pattern(regexp = "^[0-9]+$", message = "手机验证码必须都是数字") + private String code; + +} diff --git a/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/convert/UserConvert.java b/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/convert/UserConvert.java index 3b7a37a21..ea9bb8dff 100644 --- a/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/convert/UserConvert.java +++ b/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/convert/UserConvert.java @@ -1,8 +1,9 @@ package cn.iocoder.mall.user.biz.convert; -import cn.iocoder.mall.user.biz.dataobject.UserDO; +import cn.iocoder.mall.user.api.bo.user.UserAuthenticationBO; import cn.iocoder.mall.user.api.bo.UserBO; import cn.iocoder.mall.user.api.dto.UserUpdateDTO; +import cn.iocoder.mall.user.biz.dataobject.UserDO; import org.mapstruct.Mapper; import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; @@ -17,10 +18,13 @@ public interface UserConvert { @Mappings({}) UserBO convert(UserDO userDO); + @Mappings({}) + UserAuthenticationBO convert2(UserDO userDO); + @Mappings({}) UserDO convert(UserUpdateDTO userUpdateDTO); @Mappings({}) List convert(List userDOs); -} \ No newline at end of file +} diff --git a/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/dao/MobileCodeMapper.java b/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/dao/MobileCodeMapper.java index 6691a75c5..1e68c74b7 100644 --- a/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/dao/MobileCodeMapper.java +++ b/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/dao/MobileCodeMapper.java @@ -1,19 +1,12 @@ package cn.iocoder.mall.user.biz.dao; import cn.iocoder.mall.user.biz.dataobject.MobileCodeDO; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.springframework.stereotype.Repository; @Repository // 实际不加也没问entity,就是不想 IDEA 那看到有个报错 -public interface MobileCodeMapper { - - void insert(MobileCodeDO entity); - - /** - * 更新手机验证码 - * - * @param entity 更新信息 - */ - void update(MobileCodeDO entity); +public interface MobileCodeMapper extends BaseMapper { /** * 获得手机号的最后一个手机验证码 @@ -21,6 +14,12 @@ public interface MobileCodeMapper { * @param mobile 手机号 * @return 手机验证码 */ - MobileCodeDO selectLast1ByMobile(String mobile); + default MobileCodeDO selectLast1ByMobile(String mobile) { + QueryWrapper query = new QueryWrapper() + .eq("mobile", mobile) + .orderByDesc("id") + .last("limit 1"); + return selectOne(query); + } -} \ No newline at end of file +} diff --git a/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/dataobject/MobileCodeDO.java b/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/dataobject/MobileCodeDO.java index aec91c673..0963e41ff 100644 --- a/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/dataobject/MobileCodeDO.java +++ b/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/dataobject/MobileCodeDO.java @@ -1,14 +1,17 @@ package cn.iocoder.mall.user.biz.dataobject; +import cn.iocoder.common.framework.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import lombok.experimental.Accessors; import java.util.Date; // TODO 优化,IP +@TableName("mobile_code") @Data @Accessors(chain = true) -public class MobileCodeDO { +public class MobileCodeDO extends BaseDO { /** * 编号 @@ -34,10 +37,6 @@ public class MobileCodeDO { * 注册的用户编号 */ private Integer usedUserId; - /** - * 创建时间 - */ - private Date createTime; /** * 使用时间 */ diff --git a/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/service/MobileCodeServiceImpl.java b/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/service/MobileCodeServiceImpl.java index 11e78ae95..eba7226cb 100644 --- a/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/service/MobileCodeServiceImpl.java +++ b/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/service/MobileCodeServiceImpl.java @@ -50,21 +50,21 @@ public class MobileCodeServiceImpl implements MobileCodeService { */ public MobileCodeDO validLastMobileCode(String mobile, String code) { // TODO: 2019-04-09 Sin 暂时先忽略掉验证码校验 - return new MobileCodeDO().setCode(code).setCreateTime(new Date()).setId(1); -// MobileCodeDO mobileCodePO = mobileCodeMapper.selectLast1ByMobile(mobile); -// if (mobileCodePO == null) { // 若验证码不存在,抛出异常 -// throw ServiceExceptionUtil.exception(UserErrorCodeEnum.MOBILE_CODE_NOT_FOUND.getCode()); -// } -// if (System.currentTimeMillis() - mobileCodePO.getCreateTime().getTime() >= codeExpireTimes) { // 验证码已过期 -// throw ServiceExceptionUtil.exception(UserErrorCodeEnum.MOBILE_CODE_EXPIRED.getCode()); -// } -// if (mobileCodePO.getUsed()) { // 验证码已使用 -// throw ServiceExceptionUtil.exception(UserErrorCodeEnum.MOBILE_CODE_USED.getCode()); -// } -// if (!mobileCodePO.getCode().equals(code)) { -// throw ServiceExceptionUtil.exception(UserErrorCodeEnum.MOBILE_CODE_NOT_CORRECT.getCode()); -// } -// return mobileCodePO; +// return new MobileCodeDO().setCode(code).setCreateTime(new Date()).setId(1); + MobileCodeDO mobileCodePO = mobileCodeMapper.selectLast1ByMobile(mobile); + if (mobileCodePO == null) { // 若验证码不存在,抛出异常 + throw ServiceExceptionUtil.exception(UserErrorCodeEnum.MOBILE_CODE_NOT_FOUND.getCode()); + } + if (System.currentTimeMillis() - mobileCodePO.getCreateTime().getTime() >= codeExpireTimes) { // 验证码已过期 + throw ServiceExceptionUtil.exception(UserErrorCodeEnum.MOBILE_CODE_EXPIRED.getCode()); + } + if (mobileCodePO.getUsed()) { // 验证码已使用 + throw ServiceExceptionUtil.exception(UserErrorCodeEnum.MOBILE_CODE_USED.getCode()); + } + if (!mobileCodePO.getCode().equals(code)) { + throw ServiceExceptionUtil.exception(UserErrorCodeEnum.MOBILE_CODE_NOT_CORRECT.getCode()); + } + return mobileCodePO; } /** @@ -75,7 +75,7 @@ public class MobileCodeServiceImpl implements MobileCodeService { */ public void useMobileCode(Integer id, Integer userId) { MobileCodeDO update = new MobileCodeDO().setId(id).setUsed(true).setUsedUserId(userId).setUsedTime(new Date()); - mobileCodeMapper.update(update); + mobileCodeMapper.updateById(update); } // TODO 芋艿,后面要返回有效时间 @@ -99,7 +99,8 @@ public class MobileCodeServiceImpl implements MobileCodeService { MobileCodeDO newMobileCodePO = new MobileCodeDO().setMobile(mobile) .setCode("9999") // TODO 芋艿,随机 4 位验证码 or 6 位验证码 .setTodayIndex(lastMobileCodePO != null ? lastMobileCodePO.getTodayIndex() : 1) - .setUsed(false).setCreateTime(new Date()); + .setUsed(false); + newMobileCodePO.setCreateTime(new Date()); mobileCodeMapper.insert(newMobileCodePO); // TODO 发送验证码短信 } diff --git a/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/service/OAuth2ServiceImpl.java b/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/service/OAuth2ServiceImpl.java index b4880370c..a568d0526 100644 --- a/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/service/OAuth2ServiceImpl.java +++ b/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/service/OAuth2ServiceImpl.java @@ -49,27 +49,6 @@ public class OAuth2ServiceImpl implements OAuth2Service { @Autowired private OAuth2RefreshTokenMapper oauth2RefreshTokenMapper; - @Override - @Transactional - public OAuth2AccessTokenBO getAccessToken(String mobile, String code) { - // 校验传入的 mobile 和 code 是否合法 - MobileCodeDO mobileCodeDO = mobileCodeService.validLastMobileCode(mobile, code); - // 获取用户 - UserDO userDO = userService.getUser(mobile); - if (userDO == null) { // 用户不存在,则进行创建用户 - userDO = userService.createUser(mobile); - Assert.notNull(userDO, "创建用户必然成功"); - } - // 创建刷新令牌 - OAuth2RefreshTokenDO oauth2RefreshTokenDO = createOAuth2RefreshToken(userDO.getId()); - // 创建访问令牌 - OAuth2AccessTokenDO oauth2AccessTokenDO = createOAuth2AccessToken(userDO.getId(), oauth2RefreshTokenDO.getId()); - // 标记已使用 - mobileCodeService.useMobileCode(mobileCodeDO.getId(), userDO.getId()); - // 转换返回 - return OAuth2Convert.INSTANCE.convertToAccessTokenWithExpiresIn(oauth2AccessTokenDO); - } - @Override public OAuth2AuthenticationBO checkToken(String accessToken) throws ServiceException { OAuth2AccessTokenDO accessTokenDO = oauth2AccessTokenMapper.selectByTokenId(accessToken); diff --git a/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/service/UserServiceImpl.java b/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/service/UserServiceImpl.java index f9fd61acb..874a48ebd 100644 --- a/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/service/UserServiceImpl.java +++ b/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/service/UserServiceImpl.java @@ -3,20 +3,28 @@ package cn.iocoder.mall.user.biz.service; import cn.iocoder.common.framework.constant.CommonStatusEnum; import cn.iocoder.common.framework.constant.DeletedStatusEnum; import cn.iocoder.common.framework.constant.SysErrorCodeEnum; +import cn.iocoder.common.framework.constant.UserTypeEnum; import cn.iocoder.common.framework.util.ServiceExceptionUtil; import cn.iocoder.common.framework.util.ValidationUtil; +import cn.iocoder.mall.admin.api.OAuth2Service; +import cn.iocoder.mall.admin.api.bo.oauth2.OAuth2AccessTokenBO; +import cn.iocoder.mall.admin.api.dto.oauth2.OAuth2CreateTokenDTO; import cn.iocoder.mall.user.api.UserService; +import cn.iocoder.mall.user.api.bo.user.UserAuthenticationBO; import cn.iocoder.mall.user.api.bo.UserBO; import cn.iocoder.mall.user.api.bo.UserPageBO; import cn.iocoder.mall.user.api.constant.UserConstants; import cn.iocoder.mall.user.api.constant.UserErrorCodeEnum; import cn.iocoder.mall.user.api.dto.UserPageDTO; import cn.iocoder.mall.user.api.dto.UserUpdateDTO; +import cn.iocoder.mall.user.api.dto.user.UserAuthenticationByMobileCodeDTO; import cn.iocoder.mall.user.biz.convert.UserConvert; import cn.iocoder.mall.user.biz.dao.UserMapper; import cn.iocoder.mall.user.biz.dao.UserRegisterMapper; +import cn.iocoder.mall.user.biz.dataobject.MobileCodeDO; import cn.iocoder.mall.user.biz.dataobject.UserDO; import cn.iocoder.mall.user.biz.dataobject.UserRegisterDO; +import org.apache.dubbo.config.annotation.Reference; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -35,7 +43,10 @@ public class UserServiceImpl implements UserService { @Autowired private UserRegisterMapper userRegisterMapper; @Autowired - private OAuth2ServiceImpl oAuth2Service; + private MobileCodeServiceImpl mobileCodeService; + + @Reference(validation = "true", version = "${dubbo.consumer.OAuth2Service.version}") + private OAuth2Service oAuth2Service; public UserDO getUser(String mobile) { return userMapper.selectByMobile(mobile); @@ -67,6 +78,36 @@ public class UserServiceImpl implements UserService { userRegisterMapper.insert(userRegisterDO); } + @Override + @Transactional + public UserAuthenticationBO authenticationByMobileCode(UserAuthenticationByMobileCodeDTO userAuthenticationByMobileCodeDTO) { + String mobile = userAuthenticationByMobileCodeDTO.getMobile(); + String code = userAuthenticationByMobileCodeDTO.getCode(); + // 校验手机格式 + if (!ValidationUtil.isMobile(mobile)) { + throw ServiceExceptionUtil.exception(SysErrorCodeEnum.VALIDATION_REQUEST_PARAM_ERROR.getCode(), "手机格式不正确"); // TODO 有点搓 + } + // 校验验证码是否正确 + MobileCodeDO mobileCodeDO = mobileCodeService.validLastMobileCode(mobile, code); + // 获得用户 + UserDO user = userMapper.selectByMobile(mobile); + if (user == null) { // 用户不存在,则进行创建 + user = new UserDO().setMobile(mobile).setStatus(UserConstants.STATUS_ENABLE); + user.setCreateTime(new Date()); + user.setDeleted(DeletedStatusEnum.DELETED_NO.getValue()); + userMapper.insert(user); + // 插入注册信息 TODO 芋艿 后续完善,记录 ip、ua 等等 + createUserRegister(user); + } + // 更新验证码已使用 + mobileCodeService.useMobileCode(mobileCodeDO.getId(), user.getId()); + // 创建 accessToken + OAuth2AccessTokenBO accessTokenBO = oAuth2Service.createToken(new OAuth2CreateTokenDTO().setUserId(user.getId()) + .setUserType(UserTypeEnum.USER.getValue())); + // 转换返回 + return UserConvert.INSTANCE.convert2(user).setToken(accessTokenBO); + } + @Override public UserPageBO getUserPage(UserPageDTO userPageDTO) { UserPageBO userPageBO = new UserPageBO(); diff --git a/user/user-service-impl/src/main/resources/config/application.yaml b/user/user-service-impl/src/main/resources/config/application.yaml index 515785456..105bfc298 100644 --- a/user/user-service-impl/src/main/resources/config/application.yaml +++ b/user/user-service-impl/src/main/resources/config/application.yaml @@ -6,19 +6,17 @@ spring: username: root password: ${MALL_MYSQL_PASSWORD} -# mybatis -#mybatis: -# config-location: classpath:mybatis-config.xml -# mapper-locations: classpath:mapper/*.xml -# type-aliases-package: cn.iocoder.mall.user.biz.dataobject - # mybatis-plus mybatis-plus: configuration: - mapUnderscoreToCamelCase: true # 虽然默认为 true ,但是还是显示去指定下。 + map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 + global-config: + db-config: + id-type: auto + logic-delete-value: 1 # 逻辑已删除值(默认为 1) + logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) mapperLocations: classpath*:mapper/*.xml typeAliasesPackage: cn.iocoder.mall.user.biz.dataobject - config-location: classpath:mybatis-config.xml # dubbo dubbo: @@ -43,3 +41,6 @@ dubbo: version: 1.0.0 UserService: version: 1.0.0 + consumer: + OAuth2Service: + version: 1.0.0 diff --git a/user/user-service-impl/src/main/resources/mapper/MobileCodeMapper.xml b/user/user-service-impl/src/main/resources/mapper/MobileCodeMapper.xml deleted file mode 100644 index a5599ef9a..000000000 --- a/user/user-service-impl/src/main/resources/mapper/MobileCodeMapper.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - INSERT INTO mobile_code ( - id, mobile, code, today_index, used, - userd_user_id, used_time, create_time - ) VALUES ( - #{id}, #{mobile}, #{code}, #{todayIndex}, #{used}, - #{usedUserId}, #{usedTime}, #{createTime} - ) - - - - UPDATE mobile_code - - used = #{used}, - userd_user_id = #{usedUserId}, - used_time = #{usedTime}, - - WHERE id = #{id} - - - - - \ No newline at end of file diff --git a/user/user-service-impl/src/main/resources/mybatis-config.xml b/user/user-service-impl/src/main/resources/mybatis-config.xml deleted file mode 100644 index 7f604cc7e..000000000 --- a/user/user-service-impl/src/main/resources/mybatis-config.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file From dbf2a4392408c8389ca87bc3688dcf205e3ffb04 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 17 May 2019 19:23:26 +0800 Subject: [PATCH 2/5] =?UTF-8?q?-=20=E5=90=8E=E7=AB=AF=EF=BC=9A=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=20README=20-=20=E5=90=8E=E7=AB=AF=EF=BC=9A=E9=87=8D?= =?UTF-8?q?=E6=9E=84=E9=83=A8=E5=88=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 13 +- .../common/framework/util/StringUtil.java | 4 + .../mall/spring/boot/package-info.java | 1 - .../boot/web/AdminMVCAutoConfiguration.java | 8 ++ docs/guides/功能列表/功能列表-H5 商城.md | 4 +- docs/guides/功能列表/功能列表-管理后台.md | 19 ++- mobile-web/src/config/request.js | 12 +- mobile-web/src/page/category/index.vue | 15 -- mobile-web/src/page/user/info/detail.vue | 8 +- .../admins/AdminOrderReturnController.java | 4 +- .../admins/AdminsOrderController.java | 9 +- .../controller/users/OrderController.java | 14 +- .../users/OrderLogisticsController.java | 3 +- .../users/OrderReturnController.java | 3 +- .../controller/users/UsersCartController.java | 6 +- .../iocoder/mall/order/api/OrderService.java | 2 +- .../mall/order/api/bo/OrderRecipientBO.java | 2 +- .../mall/order/api/dto/CalcOrderPriceDTO.java | 2 + .../iocoder/mall/order/api/package-info.java | 7 - .../config/ServiceExceptionConfiguration.java | 4 +- .../order/biz/constants/package-info.java | 7 - .../order/biz/dataobject/OrderReturnDO.java | 5 +- .../biz/service/OrderReturnServiceImpl.java | 2 +- .../order/biz/service/OrderServiceImpl.java | 33 ++--- .../main/resources/config/application.yaml | 1 - .../src/main/resources/mybatis-config.xml | 19 --- .../admins/AdminsPayRefundController.java | 8 +- .../AdminsPayTransactionController.java | 4 +- .../users/UsersPayTransactionController.java | 42 +++--- .../application/convert/PayRefundConvert.java | 2 +- .../vo/admins/AdminsPayRefundDetailVO.java | 4 +- .../mall/pay/api/PayRefundService.java | 8 +- .../mall/pay/api/PayTransactionService.java | 21 +-- .../pay/api/bo/PayTransactionSubmitBO.java | 24 ---- .../pay/api/bo/{ => refund}/PayRefundBO.java | 2 +- .../api/bo/{ => refund}/PayRefundPageBO.java | 2 +- .../bo/{ => refund}/PayRefundSubmitBO.java | 2 +- .../{ => transaction}/PayTransactionBO.java | 63 ++++----- .../PayTransactionPageBO.java | 2 +- .../transaction/PayTransactionSubmitBO.java | 21 +++ .../mall/pay/api/constant/PayChannelEnum.java | 13 +- .../pay/api/dto/PayTransactionSubmitDTO.java | 37 ----- .../dto/{ => refund}/PayRefundPageDTO.java | 2 +- .../dto/{ => refund}/PayRefundSubmitDTO.java | 2 +- .../PayTransactionCreateDTO.java | 49 +++---- .../dto/transaction/PayTransactionGetDTO.java | 28 ++++ .../PayTransactionPageDTO.java | 2 +- .../transaction/PayTransactionSubmitDTO.java | 35 +++++ .../pay/biz/component/DubboReferencePool.java | 20 +-- .../pay/biz/convert/PayRefundConvert.java | 4 +- .../biz/convert/PayTransactionConvert.java | 6 +- .../pay/biz/mq/PayRefundSuccessConsumer.java | 1 + .../pay/biz/service/PayAppServiceImpl.java | 11 +- .../pay/biz/service/PayNotifyServiceImpl.java | 1 + .../pay/biz/service/PayRefundServiceImpl.java | 16 +-- .../service/PayTransactionServiceImpl.java | 67 +++++---- .../biz/service/PayRefundServiceImplTest.java | 2 +- .../PayTransactionServiceImplTest.java | 4 - .../users/UsersProductCategoryController.java | 4 +- .../users/UsersProductSpuController.java | 3 - .../users/UsersBannerController.java | 2 - .../users/UsersCouponController.java | 2 - .../UsersProductRecommendController.java | 2 - .../main/resources/config/application.yaml | 7 +- .../src/main/resources/mybatis-config.xml | 19 --- sessionStore/root.data | Bin 0 -> 9710 bytes .../sdk/context/AdminSecurityContext.java | 10 ++ .../sdk/interceptor/AdminDemoInterceptor.java | 31 +++++ .../interceptor/AdminSecurityInterceptor.java | 5 +- .../iocoder/mall/admin/sdk/package-info.java | 4 +- .../iocoder/mall/admin/api/OAuth2Service.java | 17 ++- .../api/bo/admin/AdminAuthorizationBO.java | 6 +- .../bo/oauth2/OAuth2AuthenticationOldBO.java | 27 ---- .../admin/api/constant/AdminConstants.java | 10 +- .../api/constant/AdminErrorCodeEnum.java | 7 +- .../api/dto/oauth2/OAuth2RefreshTokenDTO.java | 28 ++++ .../oauth2/OAuth2RemoveTokenByUserDTO.java | 27 ++++ .../mall/admin/convert/OAuth2Convert.java | 12 -- .../admin/dao/OAuth2AccessTokenMapper.java | 11 +- .../admin/dao/OAuth2RefreshTokenMapper.java | 5 +- .../mall/admin/service/AdminServiceImpl.java | 18 ++- .../mall/admin/service/OAuth2ServiceImpl.java | 37 +++-- .../cn/iocoder/mall/admin/package-info.java | 5 - .../controller/users/PassportController.java | 22 ++- .../controller/users/UserController.java | 4 + .../application/convert/PassportConvert.java | 21 --- .../user/application/po/UserAddressAddPO.java | 8 +- .../mall/user/sdk/annotation/PermitAll.java | 14 -- .../user/sdk/annotation/RequiresLogin.java | 16 +++ .../interceptor/UserSecurityInterceptor.java | 6 +- .../iocoder/mall/user/api/OAuth2Service.java | 22 --- .../mall/user/api/UserAccessLogService.java | 10 -- .../mall/user/api/bo/OAuth2AccessTokenBO.java | 25 ---- .../user/api/bo/OAuth2AuthenticationBO.java | 17 --- .../user/api/dto/UserAccessLogAddDTO.java | 65 --------- .../mall/user/biz/convert/OAuth2Convert.java | 29 ---- .../biz/convert/UserAccessLogConvert.java | 17 --- .../user/biz/dao/OAuth2AccessTokenMapper.java | 18 --- .../biz/dao/OAuth2RefreshTokenMapper.java | 16 --- .../user/biz/dao/UserAccessLogMapper.java | 11 -- .../user/biz/service/OAuth2ServiceImpl.java | 129 ------------------ .../biz/service/UserAccessLogServiceImpl.java | 54 -------- .../user/biz/service/UserServiceImpl.java | 3 +- .../resources/config/application.properties | 3 - .../main/resources/config/application.yaml | 2 - .../mapper/OAuth2AccessTokenMapper.xml | 36 ----- .../mapper/OAuth2RefreshTokenMapper.xml | 27 ---- .../resources/mapper/UserAccessLogMapper.xml | 20 --- 108 files changed, 589 insertions(+), 1017 deletions(-) delete mode 100644 common/mall-spring-boot/src/main/java/cn/iocoder/mall/spring/boot/package-info.java delete mode 100644 order/order-service-api/src/main/java/cn/iocoder/mall/order/api/package-info.java delete mode 100644 order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/constants/package-info.java delete mode 100644 order/order-service-impl/src/main/resources/mybatis-config.xml delete mode 100644 pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/bo/PayTransactionSubmitBO.java rename pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/bo/{ => refund}/PayRefundBO.java (97%) rename pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/bo/{ => refund}/PayRefundPageBO.java (89%) rename pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/bo/{ => refund}/PayRefundSubmitBO.java (83%) rename pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/bo/{ => transaction}/PayTransactionBO.java (54%) rename pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/bo/{ => transaction}/PayTransactionPageBO.java (88%) create mode 100644 pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/bo/transaction/PayTransactionSubmitBO.java delete mode 100644 pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/dto/PayTransactionSubmitDTO.java rename pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/dto/{ => refund}/PayRefundPageDTO.java (95%) rename pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/dto/{ => refund}/PayRefundSubmitDTO.java (96%) rename pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/dto/{ => transaction}/PayTransactionCreateDTO.java (56%) create mode 100644 pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/dto/transaction/PayTransactionGetDTO.java rename pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/dto/{ => transaction}/PayTransactionPageDTO.java (95%) create mode 100644 pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/dto/transaction/PayTransactionSubmitDTO.java delete mode 100644 promotion/promotion-service-impl/src/main/resources/mybatis-config.xml create mode 100644 sessionStore/root.data create mode 100644 system/system-sdk/src/main/java/cn/iocoder/mall/admin/sdk/interceptor/AdminDemoInterceptor.java delete mode 100644 system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/bo/oauth2/OAuth2AuthenticationOldBO.java create mode 100644 system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/dto/oauth2/OAuth2RefreshTokenDTO.java create mode 100644 system/system-service-api/src/main/java/cn/iocoder/mall/admin/api/dto/oauth2/OAuth2RemoveTokenByUserDTO.java delete mode 100644 system/system-service-impl/src/test/java/cn/iocoder/mall/admin/package-info.java delete mode 100644 user/user-application/src/main/java/cn/iocoder/mall/user/application/convert/PassportConvert.java delete mode 100644 user/user-sdk/src/main/java/cn/iocoder/mall/user/sdk/annotation/PermitAll.java create mode 100644 user/user-sdk/src/main/java/cn/iocoder/mall/user/sdk/annotation/RequiresLogin.java delete mode 100644 user/user-service-api/src/main/java/cn/iocoder/mall/user/api/OAuth2Service.java delete mode 100644 user/user-service-api/src/main/java/cn/iocoder/mall/user/api/UserAccessLogService.java delete mode 100644 user/user-service-api/src/main/java/cn/iocoder/mall/user/api/bo/OAuth2AccessTokenBO.java delete mode 100644 user/user-service-api/src/main/java/cn/iocoder/mall/user/api/bo/OAuth2AuthenticationBO.java delete mode 100644 user/user-service-api/src/main/java/cn/iocoder/mall/user/api/dto/UserAccessLogAddDTO.java delete mode 100644 user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/convert/OAuth2Convert.java delete mode 100644 user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/convert/UserAccessLogConvert.java delete mode 100644 user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/dao/OAuth2AccessTokenMapper.java delete mode 100644 user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/dao/OAuth2RefreshTokenMapper.java delete mode 100644 user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/dao/UserAccessLogMapper.java delete mode 100644 user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/service/OAuth2ServiceImpl.java delete mode 100644 user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/service/UserAccessLogServiceImpl.java delete mode 100644 user/user-service-impl/src/main/resources/mapper/OAuth2AccessTokenMapper.xml delete mode 100644 user/user-service-impl/src/main/resources/mapper/OAuth2RefreshTokenMapper.xml delete mode 100644 user/user-service-impl/src/main/resources/mapper/UserAccessLogMapper.xml diff --git a/README.md b/README.md index d6dff6e16..b6f38bcc0 100644 --- a/README.md +++ b/README.md @@ -30,19 +30,26 @@ # 演示 +> 艿艿:目前的开发者,都是后端出身。所以,一帮没有审美自觉的人,撸出来的前端界面,可能是东半球倒数第二难看。 +> +> 迫切希望,有前端能力不错的小伙伴,加入我们,一起来完善「一个商城」。 +> +> 啊啊啊!我好像做店铺装修功能。 + ## H5 商城 [体验传送门](http://h5.shop.iocoder.cn:18099) -TODO 此处应有一个演示的装逼 GIF 图。 +![手残艿艿的 GIF 图](https://cdn.sinaimg.cn.52ecy.cn/large/005BYqpgly1g34hgm6fyhg31hc0u0nph.jpg) ## 管理后台 [体验传送门](http://admin.shop.iocoder.cn:18099) -TODO 暂时不提供管理后台的账号密码,等后面提供。 +* 账号:yudaoyuanma +* 密码:yudaoyuanma -TODO 此处应有一个演示的装逼 GIF 图。 +![](http://ww1.sinaimg.cn/large/98a7a01cgy1g34j9b2ktqg21hc0u01lf.gif) ## 其它演示 diff --git a/common/common-framework/src/main/java/cn/iocoder/common/framework/util/StringUtil.java b/common/common-framework/src/main/java/cn/iocoder/common/framework/util/StringUtil.java index c947894dc..61ebff370 100644 --- a/common/common-framework/src/main/java/cn/iocoder/common/framework/util/StringUtil.java +++ b/common/common-framework/src/main/java/cn/iocoder/common/framework/util/StringUtil.java @@ -35,4 +35,8 @@ public class StringUtil { return org.apache.commons.lang3.StringUtils.substring(str, start); } + public static void main(String[] args) { + System.out.println(StringUtil.split("cn.iocoder.mall.order.api.OrderService#updatePaySuccess#1.0.0", "#").size()); + } + } diff --git a/common/mall-spring-boot/src/main/java/cn/iocoder/mall/spring/boot/package-info.java b/common/mall-spring-boot/src/main/java/cn/iocoder/mall/spring/boot/package-info.java deleted file mode 100644 index e8b0e4716..000000000 --- a/common/mall-spring-boot/src/main/java/cn/iocoder/mall/spring/boot/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.mall.spring.boot; diff --git a/common/mall-spring-boot/src/main/java/cn/iocoder/mall/spring/boot/web/AdminMVCAutoConfiguration.java b/common/mall-spring-boot/src/main/java/cn/iocoder/mall/spring/boot/web/AdminMVCAutoConfiguration.java index f2c947b57..b83ecbddf 100644 --- a/common/mall-spring-boot/src/main/java/cn/iocoder/mall/spring/boot/web/AdminMVCAutoConfiguration.java +++ b/common/mall-spring-boot/src/main/java/cn/iocoder/mall/spring/boot/web/AdminMVCAutoConfiguration.java @@ -2,6 +2,7 @@ package cn.iocoder.mall.spring.boot.web; import cn.iocoder.common.framework.constant.MallConstants; import cn.iocoder.common.framework.servlet.CorsFilter; +import cn.iocoder.mall.admin.sdk.interceptor.AdminDemoInterceptor; import cn.iocoder.mall.spring.boot.web.interceptor.AccessLogInterceptor; import cn.iocoder.mall.admin.sdk.interceptor.AdminSecurityInterceptor; import cn.iocoder.mall.spring.boot.web.handler.GlobalExceptionHandler; @@ -34,6 +35,12 @@ public class AdminMVCAutoConfiguration implements WebMvcConfigurer { return new AdminSecurityInterceptor(); } + @Bean + @ConditionalOnMissingBean(AdminDemoInterceptor.class) + public AdminDemoInterceptor adminDemoInterceptor() { + return new AdminDemoInterceptor(); + } + @Bean @ConditionalOnMissingBean(GlobalResponseBodyHandler.class) public GlobalResponseBodyHandler globalReturnValueHandler() { @@ -50,6 +57,7 @@ public class AdminMVCAutoConfiguration implements WebMvcConfigurer { public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(adminAccessLogInterceptor()).addPathPatterns(MallConstants.ROOT_PATH_ADMIN + "/**"); registry.addInterceptor(adminSecurityInterceptor()).addPathPatterns(MallConstants.ROOT_PATH_ADMIN + "/**"); + registry.addInterceptor(adminDemoInterceptor()).addPathPatterns(MallConstants.ROOT_PATH_ADMIN + "/**"); } @Bean diff --git a/docs/guides/功能列表/功能列表-H5 商城.md b/docs/guides/功能列表/功能列表-H5 商城.md index 56f33d3ed..1cd19aa1d 100644 --- a/docs/guides/功能列表/功能列表-H5 商城.md +++ b/docs/guides/功能列表/功能列表-H5 商城.md @@ -29,4 +29,6 @@ - 用户相关 - [x] 登陆 - [x] 注册 - - [ ] 个人信息 + - [x] 个人信息 + - [ ] 手机改绑 + - [ ] 微信登陆 diff --git a/docs/guides/功能列表/功能列表-管理后台.md b/docs/guides/功能列表/功能列表-管理后台.md index be9b5190f..d8bb63a8d 100644 --- a/docs/guides/功能列表/功能列表-管理后台.md +++ b/docs/guides/功能列表/功能列表-管理后台.md @@ -10,17 +10,25 @@ - [ ] 支付单 20% 【待认领】 - [ ] 退款单 20% 【待认领】 - TODO 需要补充 +- [ ] 店铺装修【迫切需要靠谱前端一起做】 + - [ ] H5 装修 + - [ ] 小程序装修 + - [ ] 自定义页面 - [ ] 商品管理 - [x] 发布商品 - [x] 商品列表 - [x] 展示类目 - [ ] 品牌管理【开发中 @黑子】 + - [ ] 商品标签 - [ ] 订单管理 - - [ ] 销售单 开发中 - - [ ] 售后单 开发中 + - [x] 销售单 + - [x] 售后单 - [ ] 订单评价【开发中 @wang171776704】 - [ ] 会员管理 - [ ] 会员资料 20%【待认领】 + - [ ] 会员等级 + - [ ] 会员积分 + - [ ] 用户标签 - TODO 需要补充 - [ ] 营销管理 - [x] 首页广告 @@ -30,6 +38,13 @@ - [ ] 满减送 20% 【待认领】 - [ ] 限制折扣 20% 【待认领】 - [ ] 多人拼团【待认领】 + - [ ] 积分商城 + - [ ] 问卷调查 + - [ ] 幸运大转盘 +- [ ] 分销管理 + - [ ] 分销设置 + - [ ] 分销员管理 + - [ ] 提现管理 - [ ] 系统管理 - [x] 员工管理 - [x] 角色管理 diff --git a/mobile-web/src/config/request.js b/mobile-web/src/config/request.js index 90183546f..9d92692ec 100644 --- a/mobile-web/src/config/request.js +++ b/mobile-web/src/config/request.js @@ -229,11 +229,11 @@ service.interceptors.response.use( // TODO token 过期 // TODO 需要拿 refresh token 置换 - if (code === 1001001011 // 访问令牌不存在 - || code === 1001001013 // 访问令牌已失效 - || code === 1001001021 // 刷新令牌不存在 - || code === 1001001022 // 刷新令牌已过期 - || code === 1001001023) { // 刷新令牌已失效 + if (code === 1002001011 // 访问令牌不存在 + || code === 1002001013 // 访问令牌已失效 + || code === 1002001017 // 刷新令牌不存在 + || code === 1002001018 // 刷新令牌已过期 + || code === 1002001019) { // 刷新令牌已失效 Dialog.confirm({ title: '系统提示', message: res.message, @@ -249,7 +249,7 @@ service.interceptors.response.use( } } }); - } else if (code === 1001001012) { // 访问令牌已过期 + } else if (code === 1002001012) { // 访问令牌已过期 return refreshToken(response); } else { Dialog.alert({ diff --git a/mobile-web/src/page/category/index.vue b/mobile-web/src/page/category/index.vue index 2f7cd5dac..5baa98376 100644 --- a/mobile-web/src/page/category/index.vue +++ b/mobile-web/src/page/category/index.vue @@ -50,21 +50,6 @@
    - - - - - - - - - - - - - - -
  • diff --git a/mobile-web/src/page/user/info/detail.vue b/mobile-web/src/page/user/info/detail.vue index 155a303b5..be4913e87 100644 --- a/mobile-web/src/page/user/info/detail.vue +++ b/mobile-web/src/page/user/info/detail.vue @@ -1,7 +1,7 @@