第四修改
parent
8178dc9cae
commit
afe4128893
|
@ -1,6 +1,9 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="Encoding">
|
<component name="Encoding">
|
||||||
|
<file url="file://$PROJECT_DIR$/bwie-api/bwie-user-api/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/bwie-api/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/bwie-api/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/bwie-auth/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/bwie-auth/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/bwie-auth/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/bwie-auth/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/bwie-common/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/bwie-common/src/main/java" charset="UTF-8" />
|
||||||
|
|
|
@ -48,13 +48,11 @@ public class AuthServicelmpl implements AuthService{
|
||||||
public Result login(UserRequest userRequest) {
|
public Result login(UserRequest userRequest) {
|
||||||
//判断姓名是否为空
|
//判断姓名是否为空
|
||||||
Optional<String> optional = Optional.ofNullable(userRequest.getUsername());
|
Optional<String> optional = Optional.ofNullable(userRequest.getUsername());
|
||||||
|
|
||||||
//判断
|
|
||||||
if (!optional.isPresent()){
|
|
||||||
//为null定义一个默认值
|
|
||||||
String defaultName = optional.orElse("张三");
|
String defaultName = optional.orElse("张三");
|
||||||
userRequest.setUsername(defaultName);
|
//判断
|
||||||
}
|
String orDefault = optionalUtils.getOrDefault(optional, defaultName);
|
||||||
|
//为null 返回默认值
|
||||||
|
userRequest.setUsername(orDefault);
|
||||||
User user = remoteUserService.findName(userRequest.getUsername()).getData();
|
User user = remoteUserService.findName(userRequest.getUsername()).getData();
|
||||||
if (null==user){
|
if (null==user){
|
||||||
return Result.error("用户名不存在!!!!!!!");
|
return Result.error("用户名不存在!!!!!!!");
|
||||||
|
@ -75,11 +73,10 @@ public class AuthServicelmpl implements AuthService{
|
||||||
public Result sendCode(String tel) {
|
public Result sendCode(String tel) {
|
||||||
//判断手机号是否为空
|
//判断手机号是否为空
|
||||||
Optional<String> optional = Optional.ofNullable(tel);
|
Optional<String> optional = Optional.ofNullable(tel);
|
||||||
if (!optional.isPresent()){
|
|
||||||
//默认值
|
//默认值
|
||||||
String defaultPhone = optional.orElse("18098734205");
|
String defaultPhone = optional.orElse("18098734205");
|
||||||
tel = defaultPhone;
|
String defaultTel = optionalUtils.getOrDefault(optional, defaultPhone);
|
||||||
}
|
tel = defaultTel;
|
||||||
//格式验证
|
//格式验证
|
||||||
if (!tel.matches("^1[3-9]\\d{9}$")){
|
if (!tel.matches("^1[3-9]\\d{9}$")){
|
||||||
return Result.error("手机号格式有误");
|
return Result.error("手机号格式有误");
|
||||||
|
@ -105,11 +102,12 @@ public class AuthServicelmpl implements AuthService{
|
||||||
public Result TelLogin(TelLogin telLogin) {
|
public Result TelLogin(TelLogin telLogin) {
|
||||||
//判断手机号是否为空
|
//判断手机号是否为空
|
||||||
Optional<String> optional = Optional.ofNullable(telLogin.getTel());
|
Optional<String> optional = Optional.ofNullable(telLogin.getTel());
|
||||||
if (!optional.isPresent()){
|
|
||||||
//默认值
|
//默认值
|
||||||
String defaultPhone = optional.orElse("18098734205");
|
String defaultPhone = optional.orElse("18098734205");
|
||||||
telLogin.setTel(defaultPhone);
|
|
||||||
}
|
String orDefault = optionalUtils.getOrDefault(optional, defaultPhone);
|
||||||
|
|
||||||
|
telLogin.setTel(orDefault);
|
||||||
//格式验证
|
//格式验证
|
||||||
if (!telLogin.getTel().matches("^1[3-9]\\d{9}$")){
|
if (!telLogin.getTel().matches("^1[3-9]\\d{9}$")){
|
||||||
return Result.error("手机号格式有误");
|
return Result.error("手机号格式有误");
|
||||||
|
|
Loading…
Reference in New Issue