loginOrRegisterResult = this.passengerUserRemote.loginOrRegister(passengerVerificationCode);
+ if (HttpStatus.SUCCESS.getCode() == loginOrRegisterResult.getCode()) {
+ return loginOrRegisterResult.getData();
+ }
+ return null;
+ }
}
diff --git a/common/common-annotation/src/main/java/com/greateme/springboot/EnableTaxiFeignClients.java b/common/common-annotation/src/main/java/com/greateme/springboot/EnableTaxiFeignClients.java
index 37efc5c..b430be9 100644
--- a/common/common-annotation/src/main/java/com/greateme/springboot/EnableTaxiFeignClients.java
+++ b/common/common-annotation/src/main/java/com/greateme/springboot/EnableTaxiFeignClients.java
@@ -1,6 +1,6 @@
package com.greateme.springboot;
-import com.greateme.contant.PackageContent;
+import com.greateme.constant.PackageContent;
import org.springframework.cloud.openfeign.EnableFeignClients;
import java.lang.annotation.ElementType;
diff --git a/common/common-annotation/src/main/java/com/greateme/springboot/TaxiSpringBootApplication.java b/common/common-annotation/src/main/java/com/greateme/springboot/TaxiSpringBootApplication.java
index d97003a..15870b8 100644
--- a/common/common-annotation/src/main/java/com/greateme/springboot/TaxiSpringBootApplication.java
+++ b/common/common-annotation/src/main/java/com/greateme/springboot/TaxiSpringBootApplication.java
@@ -1,6 +1,6 @@
package com.greateme.springboot;
-import com.greateme.contant.PackageContent;
+import com.greateme.constant.PackageContent;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import java.lang.annotation.ElementType;
diff --git a/common/common-constant/src/main/java/com/greateme/contant/PackageContent.java b/common/common-constant/src/main/java/com/greateme/constant/PackageContent.java
similarity index 92%
rename from common/common-constant/src/main/java/com/greateme/contant/PackageContent.java
rename to common/common-constant/src/main/java/com/greateme/constant/PackageContent.java
index 2aa5983..4b25fd4 100644
--- a/common/common-constant/src/main/java/com/greateme/contant/PackageContent.java
+++ b/common/common-constant/src/main/java/com/greateme/constant/PackageContent.java
@@ -1,4 +1,4 @@
-package com.greateme.contant;
+package com.greateme.constant;
/**
*
diff --git a/common/common-constant/src/main/java/com/greateme/contant/business/VerificationCodeConstant.java b/common/common-constant/src/main/java/com/greateme/constant/business/VerificationCodeConstant.java
similarity index 95%
rename from common/common-constant/src/main/java/com/greateme/contant/business/VerificationCodeConstant.java
rename to common/common-constant/src/main/java/com/greateme/constant/business/VerificationCodeConstant.java
index 85b9a81..dd54515 100644
--- a/common/common-constant/src/main/java/com/greateme/contant/business/VerificationCodeConstant.java
+++ b/common/common-constant/src/main/java/com/greateme/constant/business/VerificationCodeConstant.java
@@ -1,4 +1,4 @@
-package com.greateme.contant.business;
+package com.greateme.constant.business;
/**
*
diff --git a/common/common-constant/src/main/java/com/greateme/contant/http/HttpStatus.java b/common/common-constant/src/main/java/com/greateme/constant/http/HttpStatus.java
similarity index 95%
rename from common/common-constant/src/main/java/com/greateme/contant/http/HttpStatus.java
rename to common/common-constant/src/main/java/com/greateme/constant/http/HttpStatus.java
index 03d3511..db83257 100644
--- a/common/common-constant/src/main/java/com/greateme/contant/http/HttpStatus.java
+++ b/common/common-constant/src/main/java/com/greateme/constant/http/HttpStatus.java
@@ -1,4 +1,4 @@
-package com.greateme.contant.http;
+package com.greateme.constant.http;
/**
*
diff --git a/common/common-constant/src/main/java/com/greateme/contant/http/ServiceNameConstant.java b/common/common-constant/src/main/java/com/greateme/constant/http/ServiceNameConstant.java
similarity index 77%
rename from common/common-constant/src/main/java/com/greateme/contant/http/ServiceNameConstant.java
rename to common/common-constant/src/main/java/com/greateme/constant/http/ServiceNameConstant.java
index 4a981a7..7552cc1 100644
--- a/common/common-constant/src/main/java/com/greateme/contant/http/ServiceNameConstant.java
+++ b/common/common-constant/src/main/java/com/greateme/constant/http/ServiceNameConstant.java
@@ -1,4 +1,4 @@
-package com.greateme.contant.http;
+package com.greateme.constant.http;
/**
*
@@ -27,4 +27,9 @@ public class ServiceNameConstant {
* service-verification-code 的服务名称
*/
public static final String SERVICE_VERIFICATION_CODE = "service-verification-code";
+
+ /**
+ * service-passenger-user
+ */
+ public static final String SERVICE_PASSENGER_USER = "service-passenger-user";
}
diff --git a/common/common-entity/src/main/java/com/greateme/entity/respose/ResponseEntity.java b/common/common-entity/src/main/java/com/greateme/entity/respose/ResponseEntity.java
index 9009c39..ff29815 100644
--- a/common/common-entity/src/main/java/com/greateme/entity/respose/ResponseEntity.java
+++ b/common/common-entity/src/main/java/com/greateme/entity/respose/ResponseEntity.java
@@ -1,6 +1,6 @@
package com.greateme.entity.respose;
-import com.greateme.contant.http.HttpStatus;
+import com.greateme.constant.http.HttpStatus;
import com.greateme.util.JsonUtil;
import java.io.Serializable;
@@ -118,6 +118,10 @@ public class ResponseEntity implements Serializable {
return new ResponseEntity<>(HttpStatus.ERROR.getCode(), message);
}
+ public static ResponseEntity error(T data, String message) {
+ return new ResponseEntity<>(HttpStatus.ERROR.getCode(), data, message);
+ }
+
public int getCode() {
return code;
}
diff --git a/feign-client/passenger-user-client/pom.xml b/feign-client/passenger-user-client/pom.xml
new file mode 100644
index 0000000..afafb8a
--- /dev/null
+++ b/feign-client/passenger-user-client/pom.xml
@@ -0,0 +1,58 @@
+
+
+ 4.0.0
+
+ com.greateme
+ feign-client
+ 1.0-SNAPSHOT
+
+ jar
+ 乘客用户模块的远程调用
+
+ passenger-user-client
+
+
+ 11
+ 11
+ UTF-8
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-loadbalancer
+
+
+
+
+ com.greateme
+ common-util
+ provided
+
+
+
+
+ com.greateme
+ common-constant
+ provided
+
+
+
+
+ com.greateme
+ verification-code-client
+ provided
+
+
+
+
\ No newline at end of file
diff --git a/service/service-passenger-user/src/main/java/com/greateme/user/entity/PassengerUser.java b/feign-client/passenger-user-client/src/main/java/com/greateme/passenger/entity/PassengerUser.java
similarity index 98%
rename from service/service-passenger-user/src/main/java/com/greateme/user/entity/PassengerUser.java
rename to feign-client/passenger-user-client/src/main/java/com/greateme/passenger/entity/PassengerUser.java
index de3dc65..5eca8de 100644
--- a/service/service-passenger-user/src/main/java/com/greateme/user/entity/PassengerUser.java
+++ b/feign-client/passenger-user-client/src/main/java/com/greateme/passenger/entity/PassengerUser.java
@@ -1,4 +1,4 @@
-package com.greateme.user.entity;
+package com.greateme.passenger.entity;
import com.greateme.util.JsonUtil;
diff --git a/feign-client/passenger-user-client/src/main/java/com/greateme/passenger/entity/dto/PassengerLoginOrRegisterDTO.java b/feign-client/passenger-user-client/src/main/java/com/greateme/passenger/entity/dto/PassengerLoginOrRegisterDTO.java
new file mode 100644
index 0000000..b48529f
--- /dev/null
+++ b/feign-client/passenger-user-client/src/main/java/com/greateme/passenger/entity/dto/PassengerLoginOrRegisterDTO.java
@@ -0,0 +1,66 @@
+package com.greateme.passenger.entity.dto;
+
+import com.greateme.passenger.entity.PassengerUser;
+import com.greateme.util.JsonUtil;
+
+import java.io.Serializable;
+
+/**
+ *
+ * 乘客用户登陆或注册的数据传输对象
+ *
+ *
+ * @author XiaoHH
+ * @version 1.0.0
+ * @date 2023-07-06 星期四 16:41:40
+ * @file PassengerLoginOrRegisterDTO.java
+ */
+public class PassengerLoginOrRegisterDTO implements Serializable {
+
+ /**
+ * 登陆的用户实体
+ */
+ private PassengerUser passengerUser;
+
+ /**
+ * 短信验证码检测结果
+ */
+ private Integer verificationCheckResult;
+
+ /**
+ * 是否成功
+ */
+ private Boolean success;
+
+ public PassengerUser getPassengerUser() {
+ return passengerUser;
+ }
+
+ public PassengerLoginOrRegisterDTO setPassengerUser(PassengerUser passengerUser) {
+ this.passengerUser = passengerUser;
+ return this;
+ }
+
+ public Integer getVerificationCheckResult() {
+ return verificationCheckResult;
+ }
+
+ public PassengerLoginOrRegisterDTO setVerificationCheckResult(Integer verificationCheckResult) {
+ this.verificationCheckResult = verificationCheckResult;
+ return this;
+ }
+
+ public Boolean getSuccess() {
+ return success;
+ }
+
+ public PassengerLoginOrRegisterDTO setSuccess(Boolean success) {
+ this.success = success;
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ return JsonUtil.toJson(this);
+ }
+}
diff --git a/feign-client/passenger-user-client/src/main/java/com/greateme/passenger/feign/PassengerUserRemote.java b/feign-client/passenger-user-client/src/main/java/com/greateme/passenger/feign/PassengerUserRemote.java
new file mode 100644
index 0000000..51604c7
--- /dev/null
+++ b/feign-client/passenger-user-client/src/main/java/com/greateme/passenger/feign/PassengerUserRemote.java
@@ -0,0 +1,33 @@
+package com.greateme.passenger.feign;
+
+import com.greateme.constant.http.ServiceNameConstant;
+import com.greateme.entity.respose.ResponseEntity;
+import com.greateme.passenger.entity.dto.PassengerLoginOrRegisterDTO;
+import com.greateme.passenger.feign.fallback.PassengerUserFallback;
+import com.greateme.verification.entity.vo.PassengerVerificationCodeVO;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+/**
+ *
+ * 乘客用户的远程调用类
+ *
+ *
+ * @author XiaoHH
+ * @version 1.0.0
+ * @date 2023-07-06 星期四 16:13:36
+ * @file PassengerUserRemote.java
+ */
+@FeignClient(contextId = "passengerUserRemote", value = ServiceNameConstant.SERVICE_PASSENGER_USER, path = "/passengerUser", fallback = PassengerUserFallback.class)
+public interface PassengerUserRemote {
+
+ /**
+ * 登陆或注册的方法,需要传入手机验证码的验证对象
+ *
+ * @param passengerVerificationCode 手机验证码的验证对象
+ * @return 登陆的用户
+ */
+ @PostMapping("/loginOrRegister")
+ ResponseEntity loginOrRegister(@RequestBody PassengerVerificationCodeVO passengerVerificationCode);
+}
diff --git a/feign-client/passenger-user-client/src/main/java/com/greateme/passenger/feign/fallback/PassengerUserFallback.java b/feign-client/passenger-user-client/src/main/java/com/greateme/passenger/feign/fallback/PassengerUserFallback.java
new file mode 100644
index 0000000..05c2bd2
--- /dev/null
+++ b/feign-client/passenger-user-client/src/main/java/com/greateme/passenger/feign/fallback/PassengerUserFallback.java
@@ -0,0 +1,47 @@
+package com.greateme.passenger.feign.fallback;
+
+import com.greateme.entity.respose.ResponseEntity;
+import com.greateme.passenger.entity.dto.PassengerLoginOrRegisterDTO;
+import com.greateme.passenger.feign.PassengerUserRemote;
+import com.greateme.verification.entity.vo.PassengerVerificationCodeVO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.cloud.openfeign.FallbackFactory;
+import org.springframework.stereotype.Component;
+
+/**
+ *
+ * 乘客用户的远程调用回调
+ *
+ *
+ * @author XiaoHH
+ * @version 1.0.0
+ * @date 2023-07-06 星期四 16:15:53
+ * @file PassengerUserFallback.java
+ */
+@Component
+public class PassengerUserFallback implements FallbackFactory {
+
+ /**
+ * 记录日志的实体
+ */
+ private static final Logger log = LoggerFactory.getLogger(PassengerUserFallback.class);
+
+ @Override
+ public PassengerUserRemote create(Throwable cause) {
+ return new PassengerUserRemote() {
+
+ /**
+ * 登陆或注册的方法,需要传入手机验证码的验证对象
+ *
+ * @param passengerVerificationCode 手机验证码的验证对象
+ * @return 登陆的用户
+ */
+ @Override
+ public ResponseEntity loginOrRegister(PassengerVerificationCodeVO passengerVerificationCode) {
+ log.error("调用远程登陆或注册接口时候发生错误", cause);
+ return ResponseEntity.error(cause.getMessage());
+ }
+ };
+ }
+}
diff --git a/feign-client/passenger-user-client/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/feign-client/passenger-user-client/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
new file mode 100644
index 0000000..c8576a2
--- /dev/null
+++ b/feign-client/passenger-user-client/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -0,0 +1 @@
+com.greateme.passenger.feign.fallback.PassengerUserFallback
\ No newline at end of file
diff --git a/feign-client/pom.xml b/feign-client/pom.xml
index d4445f7..3bc91f9 100644
--- a/feign-client/pom.xml
+++ b/feign-client/pom.xml
@@ -14,6 +14,7 @@
pom
verification-code-client
+ passenger-user-client
\ No newline at end of file
diff --git a/feign-client/verification-code-client/src/main/java/com/greateme/verification/entity/vo/CheckPhoneVerificationCodeVO.java b/feign-client/verification-code-client/src/main/java/com/greateme/verification/entity/vo/CheckPhoneVerificationCodeVO.java
new file mode 100644
index 0000000..ba6f846
--- /dev/null
+++ b/feign-client/verification-code-client/src/main/java/com/greateme/verification/entity/vo/CheckPhoneVerificationCodeVO.java
@@ -0,0 +1,77 @@
+package com.greateme.verification.entity.vo;
+
+import com.greateme.util.JsonUtil;
+
+import java.io.Serializable;
+
+/**
+ *
+ * 检查手机验证码的视图类
+ *
+ *
+ * @author XiaoHH
+ * @version 1.0.0
+ * @date 2023-07-06 星期四 16:27:47
+ * @file CheckPhoneVerificationCodeVO.java
+ */
+public class CheckPhoneVerificationCodeVO implements Serializable {
+
+ /**
+ * 无参构造
+ */
+ public CheckPhoneVerificationCodeVO() {
+ }
+
+ /**
+ * 只传入检查结果的构造,用于验证码过期的情况
+ *
+ * @param checkResult 检查结果,返回值相见常量类:com.greateme.constant.business.VerificationCodeConstant
+ */
+ public CheckPhoneVerificationCodeVO(Integer checkResult) {
+ this.checkResult = checkResult;
+ }
+
+ /**
+ * 全参构造
+ *
+ * @param checkResult 检查结果,返回值相见常量类:com.greateme.constant.business.VerificationCodeConstant
+ * @param phone 验证的手机号码
+ */
+ public CheckPhoneVerificationCodeVO(Integer checkResult, String phone) {
+ this.checkResult = checkResult;
+ this.phone = phone;
+ }
+
+ /**
+ * 检查结果,返回值相见常量类:com.greateme.constant.business.VerificationCodeConstant
+ */
+ private Integer checkResult;
+
+ /**
+ * 验证的手机号码
+ */
+ private String phone;
+
+ public Integer getCheckResult() {
+ return checkResult;
+ }
+
+ public CheckPhoneVerificationCodeVO setCheckResult(Integer checkResult) {
+ this.checkResult = checkResult;
+ return this;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public CheckPhoneVerificationCodeVO setPhone(String phone) {
+ this.phone = phone;
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ return JsonUtil.toJson(this);
+ }
+}
diff --git a/feign-client/verification-code-client/src/main/java/com/greateme/verification/feign/VerificationCodeRemote.java b/feign-client/verification-code-client/src/main/java/com/greateme/verification/feign/VerificationCodeRemote.java
index 5fdfeba..3dd7bd2 100644
--- a/feign-client/verification-code-client/src/main/java/com/greateme/verification/feign/VerificationCodeRemote.java
+++ b/feign-client/verification-code-client/src/main/java/com/greateme/verification/feign/VerificationCodeRemote.java
@@ -1,8 +1,9 @@
package com.greateme.verification.feign;
-import com.greateme.contant.http.ServiceNameConstant;
+import com.greateme.constant.http.ServiceNameConstant;
import com.greateme.entity.respose.ResponseEntity;
import com.greateme.verification.entity.dto.PassengerVerificationCodeDTO;
+import com.greateme.verification.entity.vo.CheckPhoneVerificationCodeVO;
import com.greateme.verification.entity.vo.PassengerVerificationCodeVO;
import com.greateme.verification.feign.fallback.VerificationCodeFallback;
import org.springframework.cloud.openfeign.FeignClient;
@@ -20,7 +21,7 @@ import org.springframework.web.bind.annotation.RequestBody;
* @date 2023-05-31 星期三 14:32:59
* @file VerificationCodeRemote.java
*/
-@FeignClient(contextId = "verificationCodeRemote", value = ServiceNameConstant.SERVICE_VERIFICATION_CODE, fallback = VerificationCodeFallback.class)
+@FeignClient(contextId = "verificationCodeRemote", value = ServiceNameConstant.SERVICE_VERIFICATION_CODE, path = "/verificationCode", fallback = VerificationCodeFallback.class)
public interface VerificationCodeRemote {
/**
@@ -30,7 +31,7 @@ public interface VerificationCodeRemote {
* @param length 生成验证码的长度
* @return 生成后的详细数据
*/
- @PostMapping("/verificationCode/passengerPhone/{length}")
+ @PostMapping("/passengerPhone/{length}")
ResponseEntity passengerPhone(@RequestBody PassengerVerificationCodeDTO verificationCode, @PathVariable("length") int length);
/**
@@ -39,6 +40,6 @@ public interface VerificationCodeRemote {
* @param passengerVerificationCode 手机验证码的检查对象
* @return 检查结果,返回bool,判断是否正确
*/
- @PostMapping("/verificationCode/checkVerificationCode")
- ResponseEntity checkPhoneVerificationCode(@RequestBody PassengerVerificationCodeVO passengerVerificationCode);
+ @PostMapping("/checkVerificationCode")
+ ResponseEntity checkPhoneVerificationCode(@RequestBody PassengerVerificationCodeVO passengerVerificationCode);
}
diff --git a/feign-client/verification-code-client/src/main/java/com/greateme/verification/feign/fallback/VerificationCodeFallback.java b/feign-client/verification-code-client/src/main/java/com/greateme/verification/feign/fallback/VerificationCodeFallback.java
index 38352b5..21dd143 100644
--- a/feign-client/verification-code-client/src/main/java/com/greateme/verification/feign/fallback/VerificationCodeFallback.java
+++ b/feign-client/verification-code-client/src/main/java/com/greateme/verification/feign/fallback/VerificationCodeFallback.java
@@ -2,6 +2,7 @@ package com.greateme.verification.feign.fallback;
import com.greateme.entity.respose.ResponseEntity;
import com.greateme.verification.entity.dto.PassengerVerificationCodeDTO;
+import com.greateme.verification.entity.vo.CheckPhoneVerificationCodeVO;
import com.greateme.verification.entity.vo.PassengerVerificationCodeVO;
import com.greateme.verification.feign.VerificationCodeRemote;
import org.slf4j.Logger;
@@ -51,9 +52,9 @@ public class VerificationCodeFallback implements FallbackFactory checkPhoneVerificationCode(PassengerVerificationCodeVO passengerVerificationCode) {
+ public ResponseEntity checkPhoneVerificationCode(PassengerVerificationCodeVO passengerVerificationCode) {
log.error("跳用远程验证验证码是否正确的接口发生错误,验证码的token:{},验证码:{}", passengerVerificationCode.getVerificationToken(), passengerVerificationCode.getVerificationCode());
- return ResponseEntity.error();
+ return ResponseEntity.error(cause.getMessage());
}
};
}
diff --git a/pom.xml b/pom.xml
index 904695f..1c99c54 100644
--- a/pom.xml
+++ b/pom.xml
@@ -93,6 +93,13 @@
${online-taxi-public.version}