| | |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.JwtUtils; |
| | | import com.xinquan.common.core.utils.StringUtils; |
| | | import com.xinquan.common.redis.service.RedisService; |
| | | import com.xinquan.common.security.auth.AuthUtil; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | |
| | | @Resource |
| | | private RemoteAppUserService remoteAppUserService; |
| | | |
| | | |
| | | /** |
| | | * 发送验证码 |
| | | * @param cellPhone 手机号码 |
| | |
| | | @ApiOperation(value = "发送验证码",tags = {"APP端"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "cellPhone", value = "手机号码", required = true, dataType = "String", paramType = "query"), |
| | | @ApiImplicitParam(name = "type", value = "类型 1=注册 2=验证码登录 3=找回密码 4=第三方登录后验证手机 5=切换手机号 6= 添加银行卡", required = true, dataType = "Integer", paramType = "query")}) |
| | | @ApiImplicitParam(name = "type", value = "类型 1=注册 2=验证码登录 3=找回密码 4=第三方登录后验证手机 5=切换手机号 6= 添加银行卡,7=管理后台修改密码", required = true, dataType = "Integer", paramType = "query")}) |
| | | public R<?> sendCaptchaCode( |
| | | @RequestParam(value = "cellPhone", required = true) String cellPhone, |
| | | @RequestParam("type") Integer type) { |
| | | |
| | | if(type==5){ |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | AppUser data1 = remoteAppUserService.getAppUserById(loginUser.getUserid() + "").getData(); |
| | | if (!cellPhone.equals(data1.getCellPhone())){ |
| | | return R.fail("手机号错误"); |
| | | } |
| | | } |
| | | if(type==5){ |
| | | AppUser data = remoteAppUserService.getUserByPhone(cellPhone).getData(); |
| | | if (data!=null){ |
| | |
| | | AppUser data = remoteAppUserService.getUserByPhone(cellPhone).getData(); |
| | | if (data!=null && (data.getWxOpenId()!=null||data.getAppleId()!=null)){ |
| | | return R.fail("当前手机号已被绑定"); |
| | | } |
| | | } |
| | | if(type==1){ |
| | | AppUser data = remoteAppUserService.getUserByPhone(cellPhone).getData(); |
| | | if (data!=null){ |
| | | return R.fail("当前手机号已注册"); |
| | | } |
| | | } |
| | | if(type==3){ |
| | | AppUser data = remoteAppUserService.getUserByPhone(cellPhone).getData(); |
| | | if (data==null){ |
| | | return R.fail("当前手机号未注册"); |
| | | } |
| | | } |
| | | sysLoginService.sendCaptchaCode(cellPhone, type); |
| | |
| | | @PostMapping("/app/login") |
| | | public R<AppLoginUser> appLogin(@Validated @RequestBody AppLoginBody body) { |
| | | AppLoginUser appLoginUser = sysLoginService.appLogin(body); |
| | | Long appUserId = appLoginUser.getAppUserId(); |
| | | AppUser data = remoteAppUserService.getAppUserById(appUserId + "").getData(); |
| | | if (data.getUserStatus() == 2){ |
| | | return R.fail("您的账号已被冻结"); |
| | | } |
| | | return R.ok(tokenService.createToken4AppLoginUser(appLoginUser)); |
| | | } |
| | | |
| | |
| | | @PostMapping("/app/captchaLogin") |
| | | public R<AppLoginUser> appCaptchaLogin(@Validated @RequestBody AppCaptchaBody body) { |
| | | AppLoginUser appLoginUser = sysLoginService.appCaptchaLogin(body); |
| | | Long appUserId = appLoginUser.getAppUserId(); |
| | | AppUser data = remoteAppUserService.getAppUserById(appUserId + "").getData(); |
| | | if (data.getUserStatus() == 2){ |
| | | return R.fail("您的账号已被冻结"); |
| | | } |
| | | return R.ok(tokenService.createToken4AppLoginUser(appLoginUser)); |
| | | } |
| | | |
| | |
| | | @PostMapping("/app/wxLogin") |
| | | public R<AppLoginUser> thirdLogin(@Validated @RequestBody AppWXLoginBody body) { |
| | | AppLoginUser appLoginUser = sysLoginService.wxLogin(body); |
| | | Long appUserId = appLoginUser.getAppUserId(); |
| | | AppUser data = remoteAppUserService.getAppUserById(appUserId + "").getData(); |
| | | if (data.getUserStatus() == 2){ |
| | | return R.fail("您的账号已被冻结"); |
| | | } |
| | | return R.ok(tokenService.createToken4AppLoginUser(appLoginUser)); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "苹果登录", tags = {"APP端"}) |
| | | @PostMapping("/app/appleLogin") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "appleId", value = "苹果ID", required = true, dataType = "String", paramType = "query"), |
| | | @ApiImplicitParam(name = "appleId", value = "苹果ID", required = true, dataType = "String", paramType = "query") |
| | | // @ApiImplicitParam(name = "device", value = "设备码", required = false, dataType = "String", paramType = "query"), |
| | | } |
| | | ) |
| | | public R<AppLoginUser> appleLogin( |
| | | @RequestParam(value = "appleId", required = true) String appleId) { |
| | | AppLoginUser appLoginUser = sysLoginService.appleLogin(appleId); |
| | | @RequestParam(value = "appleId", required = true) String appleId, |
| | | @RequestParam(value = "device", required = false) String device |
| | | ) { |
| | | |
| | | AppLoginUser appLoginUser = sysLoginService.appleLogin(appleId, org.springframework.util.StringUtils.hasLength(device)?device:""); |
| | | Long appUserId = appLoginUser.getAppUserId(); |
| | | AppUser data = remoteAppUserService.getAppUserById(appUserId + "").getData(); |
| | | if (data.getUserStatus() == 2){ |
| | | return R.fail("您的账号已被冻结"); |
| | | } |
| | | return R.ok(tokenService.createToken4AppLoginUser(appLoginUser)); |
| | | } |
| | | |