From f3fb8faf22d96bf619e057f1967e319b197a9a33 Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Sat, 9 Mar 2019 22:07:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=A4=9A=E4=BD=99=E7=9A=84?= =?UTF-8?q?=20createUser=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{ => users}/PassportController.java | 4 +-- .../{ => users}/UserController.java | 4 +-- .../mall/user/service/api/UserService.java | 14 -------- .../mall/user/service/api/UserService.class | Bin 375 -> 136 bytes .../iocoder/mall/user/dataobject/UserDO.java | 30 +++++++++++++----- .../mall/user/service/OAuth2ServiceImpl.java | 6 +++- .../mall/user/service/UserServiceImpl.java | 30 ++++-------------- .../iocoder/mall/user/dataobject/UserDO.class | Bin 1235 -> 1357 bytes .../mall/user/service/OAuth2ServiceImpl.class | Bin 7273 -> 7440 bytes .../mall/user/service/UserServiceImpl.class | Bin 3474 -> 3089 bytes 10 files changed, 37 insertions(+), 51 deletions(-) rename user/user-application/src/main/java/cn/iocoder/mall/user/application/controller/{ => users}/PassportController.java (96%) rename user/user-application/src/main/java/cn/iocoder/mall/user/application/controller/{ => users}/UserController.java (90%) diff --git a/user/user-application/src/main/java/cn/iocoder/mall/user/application/controller/PassportController.java b/user/user-application/src/main/java/cn/iocoder/mall/user/application/controller/users/PassportController.java similarity index 96% rename from user/user-application/src/main/java/cn/iocoder/mall/user/application/controller/PassportController.java rename to user/user-application/src/main/java/cn/iocoder/mall/user/application/controller/users/PassportController.java index 27a25282a..d79cf0624 100644 --- a/user/user-application/src/main/java/cn/iocoder/mall/user/application/controller/PassportController.java +++ b/user/user-application/src/main/java/cn/iocoder/mall/user/application/controller/users/PassportController.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.user.application.controller; +package cn.iocoder.mall.user.application.controller.users; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.user.application.convert.PassportConvert; @@ -19,7 +19,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @RestController -@RequestMapping("user/passport") +@RequestMapping("users/passport") @Api("Passport 模块") public class PassportController { diff --git a/user/user-application/src/main/java/cn/iocoder/mall/user/application/controller/UserController.java b/user/user-application/src/main/java/cn/iocoder/mall/user/application/controller/users/UserController.java similarity index 90% rename from user/user-application/src/main/java/cn/iocoder/mall/user/application/controller/UserController.java rename to user/user-application/src/main/java/cn/iocoder/mall/user/application/controller/users/UserController.java index f6ad37d30..9e1c83899 100644 --- a/user/user-application/src/main/java/cn/iocoder/mall/user/application/controller/UserController.java +++ b/user/user-application/src/main/java/cn/iocoder/mall/user/application/controller/users/UserController.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.user.application.controller; +package cn.iocoder.mall.user.application.controller.users; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder; @@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController -@RequestMapping("/user") +@RequestMapping("users/user") @Api("用户模块") public class UserController { diff --git a/user/user-service-api/src/main/java/cn/iocoder/mall/user/service/api/UserService.java b/user/user-service-api/src/main/java/cn/iocoder/mall/user/service/api/UserService.java index bbd479d59..149cff1b5 100644 --- a/user/user-service-api/src/main/java/cn/iocoder/mall/user/service/api/UserService.java +++ b/user/user-service-api/src/main/java/cn/iocoder/mall/user/service/api/UserService.java @@ -1,19 +1,5 @@ package cn.iocoder.mall.user.service.api; -import cn.iocoder.common.framework.exception.ServiceException; -import cn.iocoder.mall.user.service.api.bo.UserBO; - public interface UserService { - /** - * 创建用户。一般在用户注册时,调用该方法 - * - * TODO 芋艿,此处要传递一些用户注册时的相关信息,例如说 ip、ua、客户端来源等等。用于数据分析、风控等等。 - * - * @param mobile 手机号 - * @param code 手机验证码 - * @return 用户 - */ - UserBO createUser(String mobile, String code) throws ServiceException; - } \ No newline at end of file diff --git a/user/user-service-api/target/classes/cn/iocoder/mall/user/service/api/UserService.class b/user/user-service-api/target/classes/cn/iocoder/mall/user/service/api/UserService.class index f97f928c470304afc1b83e75588e4be451df8f09..cedd1d7925e740bc0d17eb09124fe1a0cc9c7da6 100644 GIT binary patch delta 47 ycmey))WIll>ff$?3=9k=4D9R-tn3VI6PG55u`x0*GB5!}L4c8g8AviQumAu8Xa?y3 literal 375 zcmah_OHRWu5PcIu0_E3ZfP|P0V$&TGtcr?=IDq30#U+U=$1R+V1qa|zh%w(vELiw6 zPxC%AuW!#U08VjGVz createResult = userService.createUser(mobile); + if (createResult.isError()) { + return CommonResult.error(createResult); + } + userDO = createResult.getData(); Assert.notNull(userDO, "创建用户必然成功"); } // 创建刷新令牌 diff --git a/user/user-service-impl/src/main/java/cn/iocoder/mall/user/service/UserServiceImpl.java b/user/user-service-impl/src/main/java/cn/iocoder/mall/user/service/UserServiceImpl.java index bd9066caa..adbdf7e34 100644 --- a/user/user-service-impl/src/main/java/cn/iocoder/mall/user/service/UserServiceImpl.java +++ b/user/user-service-impl/src/main/java/cn/iocoder/mall/user/service/UserServiceImpl.java @@ -1,14 +1,13 @@ package cn.iocoder.mall.user.service; import cn.iocoder.common.framework.util.ServiceExceptionUtil; -import cn.iocoder.mall.user.convert.UserConvert; +import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.user.dao.UserMapper; import cn.iocoder.mall.user.dao.UserRegisterMapper; import cn.iocoder.mall.user.dataobject.UserDO; import cn.iocoder.mall.user.dataobject.UserRegisterDO; import cn.iocoder.mall.user.service.api.UserService; import cn.iocoder.mall.user.service.api.constant.UserErrorCodeEnum; -import cn.iocoder.mall.user.service.api.bo.UserBO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; @@ -32,38 +31,21 @@ public class UserServiceImpl implements UserService { return userMapper.selectByMobile(mobile); } - @Override @Transactional - public UserBO createUser(String mobile, String code) { + public CommonResult createUser(String mobile) { // TODO 芋艿,校验手机格式 - // 校验手机号的最后一个手机验证码是否有效 - mobileCodeService.validLastMobileCode(mobile, code); // 校验用户是否已经存在 if (getUser(mobile) != null) { - throw ServiceExceptionUtil.exception(UserErrorCodeEnum.USER_MOBILE_ALREADY_REGISTERED.getCode()); + return ServiceExceptionUtil.error(UserErrorCodeEnum.USER_MOBILE_ALREADY_REGISTERED.getCode()); } // 创建用户 - UserDO userDO = new UserDO().setMobile(mobile).setCreateTime(new Date()); + UserDO userDO = new UserDO().setMobile(mobile); + userDO.setCreateTime(new Date()); userMapper.insert(userDO); // 插入注册信息 createUserRegister(userDO); // 转换返回 - return UserConvert.INSTANCE.convert(userDO); - } - - @Transactional - public UserDO createUser(String mobile) { - // 校验用户是否已经存在 - if (getUser(mobile) != null) { - throw ServiceExceptionUtil.exception(UserErrorCodeEnum.USER_MOBILE_ALREADY_REGISTERED.getCode()); - } - // 创建用户 - UserDO userDO = new UserDO().setMobile(mobile).setCreateTime(new Date()); - userMapper.insert(userDO); - // 插入注册信息 - createUserRegister(userDO); - // 转换返回 - return userDO; + return CommonResult.success(userDO); } private void createUserRegister(UserDO userDO) { diff --git a/user/user-service-impl/target/classes/cn/iocoder/mall/user/dataobject/UserDO.class b/user/user-service-impl/target/classes/cn/iocoder/mall/user/dataobject/UserDO.class index a8d20ca3692aea93d6ab770d3b967b3f10f09cb9..ed7f0ec4f8054137d3f5ba57544c59a4bbfb132f 100644 GIT binary patch literal 1357 zcmb7?+iuf95QhJC;MmI%(oaq7(FehT2%}Fo^?|or?nRG~yxUE7Y0rm=;?>6eQaWrF!Ft zq5M{KDZS7RB7c7vcKrAQ@1zF`kN1yw9LPA^EGNgofT7;@A~z5owZ?A9`+avfpjDR? zMCZi!689s;I|l@)_xxm+*lYF17-2@Q57OlG`ed$gafRxhpB#(sdmht86F(+ClSKEj z!7QE=&PQXC^jXQ)xO`Ue9{@I~?dOBG>EKZ$NnU4@my%~|>rf11&wr=h&Q7QGSiY`< zOIUC)2h)KC+kqp^JZy&biw&LO(O97;!cau+CpnxiB0e2|q&Ixv?;K!-KAJ)QunbM= z(n^!k%9FbC1VG*dlXzsS6uIOXdA<1)?3*gPOtzvnE!1f3qy@NwMT!`%Vu|ee=I_wH zPBbqUHebVaB9qOp$ZO<{X6pyE=BV9L+pEyArjA%j%QAgxP#0vlLCrd&KtkQbtpcdh z=+yK^8--A}afdXfph{CvErNPD14>Rihq4sZav@ZC66#4I)ZJpJ@)Xo2K|P%TC7(Wr naun3PLMVL_>RBPwN->l^1@)4kwr4=ef0#qfE2ven8rJ>+kk;F@ literal 1235 zcmb7?+iuf95QhJC;ut#)4WSe$&{7Jm6A%W8E2!Y26%tZPE4B1~I{5)#jNtTNbu0cnpRdGPL_= z{44iE9*_Kf5|7?7G@@i6L&4A~-5se^X17j|3a-Slj3}bWo+ugmdvvO^cVsNpdxo0V zJz=QtCPNBb>dRPso?0i~vX#KX{^jA=FG ziYJ3J5h(u)?e`8y&KwE#iTdbx-4boli8;{B@Zj~bpyIFhI^E3GTLaU`&g}js?DnA9c@-ZJ-|cKSb(Z6 zKy4G0cL|h!P02gIv!U+)fb>%5!CBTp!Andp_&=g23Z47{sWi@ B;)ehL diff --git a/user/user-service-impl/target/classes/cn/iocoder/mall/user/service/OAuth2ServiceImpl.class b/user/user-service-impl/target/classes/cn/iocoder/mall/user/service/OAuth2ServiceImpl.class index d8a3be03cd090e28f9ab00deaed8b9d6b05261e6..e158d83b6e6e8cc6678cf283146de0505d4eaf10 100644 GIT binary patch delta 2216 zcmb7Ed0bRg6#nj;wNdH0@smhXJ$+LuKBn zW0wM3YYd^;^J@8m5-%#R-D>rc5_{D4Wj9{IUIY8^suHic@VX0c73CbmJ38KN zC=`=zE?G9KytKM}l)2BIYi_h>n406T7-Mb@O*g|_olIY(+Z^f99Ru?PCY+`n;7k(l zHIzE13H$p3K66)CV#5(VRm&cY%OpnPA{`${?8gL&5Al)2$M{6zLX6Pysl;daT;dB< zOMHp11X9cuu0-Z>dIe%yYS*+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