第四修改

master
31353 2024-01-08 09:22:21 +08:00
parent 8178dc9cae
commit afe4128893
2 changed files with 17 additions and 16 deletions

View File

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<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/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-common/src/main/java" charset="UTF-8" />

View File

@ -48,13 +48,11 @@ public class AuthServicelmpl implements AuthService{
public Result login(UserRequest userRequest) {
//判断姓名是否为空
Optional<String> optional = Optional.ofNullable(userRequest.getUsername());
//判断
if (!optional.isPresent()){
//为null定义一个默认值
String defaultName = optional.orElse("张三");
userRequest.setUsername(defaultName);
}
//判断
String orDefault = optionalUtils.getOrDefault(optional, defaultName);
//为null 返回默认值
userRequest.setUsername(orDefault);
User user = remoteUserService.findName(userRequest.getUsername()).getData();
if (null==user){
return Result.error("用户名不存在!!!!!!!");
@ -75,11 +73,10 @@ public class AuthServicelmpl implements AuthService{
public Result sendCode(String tel) {
//判断手机号是否为空
Optional<String> optional = Optional.ofNullable(tel);
if (!optional.isPresent()){
//默认值
String defaultPhone = optional.orElse("18098734205");
tel = defaultPhone;
}
String defaultTel = optionalUtils.getOrDefault(optional, defaultPhone);
tel = defaultTel;
//格式验证
if (!tel.matches("^1[3-9]\\d{9}$")){
return Result.error("手机号格式有误");
@ -105,11 +102,12 @@ public class AuthServicelmpl implements AuthService{
public Result TelLogin(TelLogin telLogin) {
//判断手机号是否为空
Optional<String> optional = Optional.ofNullable(telLogin.getTel());
if (!optional.isPresent()){
//默认值
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}$")){
return Result.error("手机号格式有误");