|
@@ -19,6 +19,8 @@ import com.github.pagehelper.PageInfo;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
@@ -105,24 +107,27 @@ public class DocumentAuthServiceImpl implements DocumentAuthService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public JsonModel mobileCodeLogin(String mobile, String code) {
|
|
|
|
|
|
+ public ResponseEntity<JsonModel> mobileCodeLogin(String mobile, String code) {
|
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
|
+ if (StringUtils.isEmpty(mobile) || StringUtils.isEmpty(code)) {
|
|
|
|
+ return new ResponseEntity<>(JsonModel.error("参数异常"), headers, HttpStatus.OK);
|
|
|
|
+ }
|
|
String mobileCode = (String) redisService.get(mobile + ":mobileCode");
|
|
String mobileCode = (String) redisService.get(mobile + ":mobileCode");
|
|
if (!StringUtils.isEmpty(mobileCode) && code.equals(mobileCode)) {
|
|
if (!StringUtils.isEmpty(mobileCode) && code.equals(mobileCode)) {
|
|
OssAuthorization ossAuthorization = documentAuthDao.findOssAuthorizationByMobile(mobile);
|
|
OssAuthorization ossAuthorization = documentAuthDao.findOssAuthorizationByMobile(mobile);
|
|
if (ossAuthorization != null) {
|
|
if (ossAuthorization != null) {
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
|
String cookie = new CookieBuilder().setKey("authorizationMobile")
|
|
String cookie = new CookieBuilder().setKey("authorizationMobile")
|
|
.setValue(mobile)
|
|
.setValue(mobile)
|
|
.setMaxAge(60 * 60 * 24 * 30)
|
|
.setMaxAge(60 * 60 * 24 * 30)
|
|
.setPath("/")
|
|
.setPath("/")
|
|
.build();
|
|
.build();
|
|
headers.add("Set-Cookie", cookie);
|
|
headers.add("Set-Cookie", cookie);
|
|
- return JsonModel.success();
|
|
|
|
|
|
+ return new ResponseEntity<>(JsonModel.success(), headers, HttpStatus.OK);
|
|
} else {
|
|
} else {
|
|
- return JsonModel.error(-2, "登录失败");
|
|
|
|
|
|
+ return new ResponseEntity<>(JsonModel.error(-2, "登录失败"), headers, HttpStatus.OK);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- return JsonModel.error("短信验证码不正确");
|
|
|
|
|
|
+ return new ResponseEntity<>(JsonModel.error("短信验证码不正确"), headers, HttpStatus.OK);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|