|
@@ -16,6 +16,8 @@ import com.ruoyi.common.core.redis.RedisCache;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -47,6 +49,10 @@ public class AppLoginController {
|
|
|
*/
|
|
|
@PassToken
|
|
|
@ApiOperation(value = "APP登录", notes = "APP登录")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "mobile", value = "手机号",paramType="string"),
|
|
|
+ @ApiImplicitParam(name = "captcha", value = "验证码",paramType="string")
|
|
|
+ })
|
|
|
@PostMapping("/login")
|
|
|
public AjaxResult login(String mobile, String captcha){
|
|
|
if (StringUtils.isBlank(mobile)) {
|
|
@@ -67,18 +73,18 @@ public class AppLoginController {
|
|
|
appUser.setNickName(mobile);
|
|
|
appUser.setQrcode(DateUtils.getCurrentTimeRandom());
|
|
|
appUser.setCreateTime(date);
|
|
|
- appUser.setUpdateTime(date);
|
|
|
ck = userService.save(appUser);
|
|
|
if (!ck){
|
|
|
return AjaxResult.error("未知异常,登录失败");
|
|
|
}
|
|
|
+ appUser.setCreateBy(appUser.getId());
|
|
|
}
|
|
|
|
|
|
//手机短信验证 // TODO 调试通过,以后测试在放开注释
|
|
|
-// boolean ckCaptcha = AliSMSUtil.getInstance().validateSmsCode(mobile, captcha);
|
|
|
-// if (!ckCaptcha) {
|
|
|
-// return AjaxResult.error("验证码错误");
|
|
|
-// }
|
|
|
+ boolean ckCaptcha = AliSMSUtil.getInstance().validateSmsCode(mobile, captcha);
|
|
|
+ if (!ckCaptcha) {
|
|
|
+ return AjaxResult.error("验证码错误");
|
|
|
+ }
|
|
|
|
|
|
//每次登录前,先删除缓存,保证登录唯一性
|
|
|
appTokenService.delLoginUser(mobile);
|
|
@@ -91,8 +97,8 @@ public class AppLoginController {
|
|
|
|
|
|
appUser.setLoginIp(loginUser.getIpaddr());
|
|
|
appUser.setLoginTime(date);
|
|
|
- appUser.setCreateBy(appUser.getId());
|
|
|
appUser.setUpdateBy(appUser.getId());
|
|
|
+ appUser.setUpdateTime(date);
|
|
|
ck = userService.updateById(appUser);
|
|
|
if (!ck){
|
|
|
return AjaxResult.error("未知异常,登录失败");
|
|
@@ -110,6 +116,10 @@ public class AppLoginController {
|
|
|
*/
|
|
|
@PassToken
|
|
|
@ApiOperation(value = "发送短信验证码", notes = "发送短信验证码")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "type", value = "1.用户注册;2.登录确认;3.身份验证;4.登录异常;5.修改密码;6.信息变更",paramType="string"),
|
|
|
+ @ApiImplicitParam(name = "mobile", value = "手机号",paramType="string")
|
|
|
+ })
|
|
|
@GetMapping("/captchaSend")
|
|
|
public AjaxResult sendCaptcha(Integer type, String mobile){
|
|
|
if(StringUtils.isBlank(mobile)){
|
|
@@ -131,6 +141,10 @@ public class AppLoginController {
|
|
|
@PassToken
|
|
|
@ApiOperation(value = "校验短信验证码", notes = "校验短信验证码")
|
|
|
@GetMapping("/captchaValidate")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "mobile", value = "手机号",paramType="string"),
|
|
|
+ @ApiImplicitParam(name = "captcha", value = "验证码",paramType="string")
|
|
|
+ })
|
|
|
public AjaxResult validateCaptcha(String mobile, String captcha){
|
|
|
if (StringUtils.isBlank(mobile)) {
|
|
|
return AjaxResult.error("手机号不能为空");
|
|
@@ -146,14 +160,6 @@ public class AppLoginController {
|
|
|
return AjaxResult.success("验证成功");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-// @ApiOperation(value = "getUser", notes = "getUser")
|
|
|
-// @GetMapping("/getLoginUser")
|
|
|
-// public AjaxResult getLoginUser(HttpServletRequest request){
|
|
|
-// AppLoginUser user = appTokenService.getLoginUser(request);
|
|
|
-// return AjaxResult.success(user);
|
|
|
-// }
|
|
|
-
|
|
|
public static void main(String[] args) {
|
|
|
// System.out.println(DateUtils.getCurrentTimeRandom());
|
|
|
|