From c6efd829dab006dc3ca206e82767be8a9c4db395 Mon Sep 17 00:00:00 2001 From: msb_89821 Date: Sun, 16 Oct 2022 22:49:50 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E5=AE=9E=E7=8E=B0=E5=8A=9F=E8=83=BD1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../onelinetextplublic/api-passinger/pom.xml | 5 +++ .../text/controller/PassengerController.java | 13 +++---- .../src/main/resources/application.yml | 6 ++- oneLineTxt/v1/onelinetextplublic/pom.xml | 5 ++- .../controller/SendSmsCodeController.java | 12 +++--- .../service-passenger-user/pom.xml | 39 +++++++++++++++++++ .../ServicePassengerUserApplication.java | 15 +++++++ .../src/main/resources/application.yml | 1 + .../ServicePassengerUserApplicationTests.java | 10 +++++ 9 files changed, 91 insertions(+), 15 deletions(-) create mode 100644 oneLineTxt/v1/onelinetextplublic/service-passenger-user/pom.xml create mode 100644 oneLineTxt/v1/onelinetextplublic/service-passenger-user/src/main/java/com/example/servicepassengeruser/ServicePassengerUserApplication.java create mode 100644 oneLineTxt/v1/onelinetextplublic/service-passenger-user/src/main/resources/application.yml create mode 100644 oneLineTxt/v1/onelinetextplublic/service-passenger-user/src/test/java/com/example/servicepassengeruser/ServicePassengerUserApplicationTests.java diff --git a/oneLineTxt/v1/onelinetextplublic/api-passinger/pom.xml b/oneLineTxt/v1/onelinetextplublic/api-passinger/pom.xml index 6bfd45c..35321b7 100644 --- a/oneLineTxt/v1/onelinetextplublic/api-passinger/pom.xml +++ b/oneLineTxt/v1/onelinetextplublic/api-passinger/pom.xml @@ -25,6 +25,11 @@ com.alibaba.cloud spring-cloud-starter-alibaba-nacos-discovery + + org.springframework.cloud + spring-cloud-starter-loadbalancer + 2.2.0.RELEASE + org.springframework.cloud diff --git a/oneLineTxt/v1/onelinetextplublic/api-passinger/src/main/java/mashibing/online/text/controller/PassengerController.java b/oneLineTxt/v1/onelinetextplublic/api-passinger/src/main/java/mashibing/online/text/controller/PassengerController.java index 8549a04..76d09c4 100644 --- a/oneLineTxt/v1/onelinetextplublic/api-passinger/src/main/java/mashibing/online/text/controller/PassengerController.java +++ b/oneLineTxt/v1/onelinetextplublic/api-passinger/src/main/java/mashibing/online/text/controller/PassengerController.java @@ -5,16 +5,14 @@ import com.alibaba.fastjson.JSON; import com.mashibing.dto.PassengerRequestDto; import com.mashibing.dto.ResponseResult; import com.mashibing.util.JwtUtils; +import lombok.extern.slf4j.Slf4j; import mashibing.online.text.consonant.PassengerConsonant; import mashibing.online.text.dto.UserInfo; import mashibing.online.text.feign.SendSMSCodeService; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.concurrent.TimeUnit; @@ -24,8 +22,9 @@ import java.util.concurrent.TimeUnit; * @Description * @date 2022/10/5 */ +@Slf4j @RestController - +@RequestMapping("/passenger") public class PassengerController { @Resource @@ -45,7 +44,7 @@ public class PassengerController { // 调服务获取验证码 String smsCode = sendSMSCodeService.getSmsCode(6,passengerRequestDto.getPhoneNumber()); - System.out.println(""+ JSON.toJSONString(smsCode)); + log.info(""+ JSON.toJSONString(smsCode)); // 存入redis 有限时间 stringRedisTemplate.opsForValue().set(PassengerConsonant.phoneNumberCodePreKey+passengerRequestDto.getPhoneNumber(), smsCode,2, TimeUnit.MINUTES); @@ -74,7 +73,7 @@ public class PassengerController { throw new RuntimeException("短信验证码错误!"); } // 用户注册 - System.out.println("phone 短信验证码正确"); + log.info("phone {} 短信验证码正确!",phone); // 返回token String token = JwtUtils.genaroteToken(phone, PassengerConsonant.PassengerIdendity); diff --git a/oneLineTxt/v1/onelinetextplublic/api-passinger/src/main/resources/application.yml b/oneLineTxt/v1/onelinetextplublic/api-passinger/src/main/resources/application.yml index 9f34a23..1cf84ec 100644 --- a/oneLineTxt/v1/onelinetextplublic/api-passinger/src/main/resources/application.yml +++ b/oneLineTxt/v1/onelinetextplublic/api-passinger/src/main/resources/application.yml @@ -8,4 +8,8 @@ spring: discovery: server-addr: 127.0.0.1:8848 application: - name: api-passinger \ No newline at end of file + name: api-passinger + redis: + host: 127.0.0.1 + database: 0 + port: 6379 \ No newline at end of file diff --git a/oneLineTxt/v1/onelinetextplublic/pom.xml b/oneLineTxt/v1/onelinetextplublic/pom.xml index 21c6cbd..ad7744f 100644 --- a/oneLineTxt/v1/onelinetextplublic/pom.xml +++ b/oneLineTxt/v1/onelinetextplublic/pom.xml @@ -60,7 +60,7 @@ org.springframework.boot spring-boot-starter-data-redis - 2.2.1.RELEASE + 2.2.1.RELEASE @@ -69,6 +69,7 @@ api-passinger send-server untitled4 + service-passenger-user @@ -83,7 +84,7 @@ org.springframework.cloud spring-cloud-dependencies - Finchley.SR2 + 2020.0.1 pom import diff --git a/oneLineTxt/v1/onelinetextplublic/send-server/src/main/java/com/mashibing/sendserver/controller/SendSmsCodeController.java b/oneLineTxt/v1/onelinetextplublic/send-server/src/main/java/com/mashibing/sendserver/controller/SendSmsCodeController.java index f61695b..71cbc7d 100644 --- a/oneLineTxt/v1/onelinetextplublic/send-server/src/main/java/com/mashibing/sendserver/controller/SendSmsCodeController.java +++ b/oneLineTxt/v1/onelinetextplublic/send-server/src/main/java/com/mashibing/sendserver/controller/SendSmsCodeController.java @@ -23,10 +23,7 @@ import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; import org.apache.tomcat.util.security.MD5Encoder; import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import sun.security.provider.MD5; import javax.annotation.Resource; @@ -44,7 +41,8 @@ import java.util.UUID; * @date 2022/10/7 */ @Slf4j -@RestController("/send") +@RestController +@RequestMapping("/send") public class SendSmsCodeController { public static final String CHARSET_UTF8 = "UTF-8"; @@ -83,6 +81,10 @@ public class SendSmsCodeController { UUID.randomUUID().toString()); String rutlet=post(smsAccount.getUrl() + PATH_SEND_SMS, params); log.info("==="+rutlet); + if(StringUtils.isBlank(rutlet)){ + log.error("获取验证码异常!"); + return String.valueOf(radom); + } JSONObject jsonObject=JSON.parseObject(rutlet); Integer status=jsonObject.getInteger("status"); if (!Integer.valueOf(0).equals(status)){ diff --git a/oneLineTxt/v1/onelinetextplublic/service-passenger-user/pom.xml b/oneLineTxt/v1/onelinetextplublic/service-passenger-user/pom.xml new file mode 100644 index 0000000..3f03853 --- /dev/null +++ b/oneLineTxt/v1/onelinetextplublic/service-passenger-user/pom.xml @@ -0,0 +1,39 @@ + + + 4.0.0 + + oneline-text-plublic + com.mashibing + 1.0-SNAPSHOT + + com.example + service-passenger-user + 0.0.1-SNAPSHOT + service-passenger-user + service-passenger-user + + 1.8 + + + + org.springframework.boot + spring-boot-starter-web + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/oneLineTxt/v1/onelinetextplublic/service-passenger-user/src/main/java/com/example/servicepassengeruser/ServicePassengerUserApplication.java b/oneLineTxt/v1/onelinetextplublic/service-passenger-user/src/main/java/com/example/servicepassengeruser/ServicePassengerUserApplication.java new file mode 100644 index 0000000..cf1d82e --- /dev/null +++ b/oneLineTxt/v1/onelinetextplublic/service-passenger-user/src/main/java/com/example/servicepassengeruser/ServicePassengerUserApplication.java @@ -0,0 +1,15 @@ +package com.example.servicepassengeruser; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +@SpringBootApplication +@EnableDiscoveryClient +public class ServicePassengerUserApplication { + + public static void main(String[] args) { + SpringApplication.run(ServicePassengerUserApplication.class, args); + } + +} diff --git a/oneLineTxt/v1/onelinetextplublic/service-passenger-user/src/main/resources/application.yml b/oneLineTxt/v1/onelinetextplublic/service-passenger-user/src/main/resources/application.yml new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/oneLineTxt/v1/onelinetextplublic/service-passenger-user/src/main/resources/application.yml @@ -0,0 +1 @@ + diff --git a/oneLineTxt/v1/onelinetextplublic/service-passenger-user/src/test/java/com/example/servicepassengeruser/ServicePassengerUserApplicationTests.java b/oneLineTxt/v1/onelinetextplublic/service-passenger-user/src/test/java/com/example/servicepassengeruser/ServicePassengerUserApplicationTests.java new file mode 100644 index 0000000..9429270 --- /dev/null +++ b/oneLineTxt/v1/onelinetextplublic/service-passenger-user/src/test/java/com/example/servicepassengeruser/ServicePassengerUserApplicationTests.java @@ -0,0 +1,10 @@ +package com.example.servicepassengeruser; + + + + +class ServicePassengerUserApplicationTests { + + + +}