add: 实现功能1

master
msb_89821 2 years ago
parent 01db3ae4d7
commit c6efd829da

@ -25,6 +25,11 @@
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>

@ -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);

@ -9,3 +9,7 @@ spring:
server-addr: 127.0.0.1:8848
application:
name: api-passinger
redis:
host: 127.0.0.1
database: 0
port: 6379

@ -69,6 +69,7 @@
<module>api-passinger</module>
<module>send-server</module>
<module>untitled4</module>
<module>service-passenger-user</module>
</modules>
<dependencyManagement>
@ -83,7 +84,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.SR2</version>
<version>2020.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>

@ -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)){

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>oneline-text-plublic</artifactId>
<groupId>com.mashibing</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.example</groupId>
<artifactId>service-passenger-user</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>service-passenger-user</name>
<description>service-passenger-user</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

@ -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);
}
}

@ -0,0 +1,10 @@
package com.example.servicepassengeruser;
class ServicePassengerUserApplicationTests {
}
Loading…
Cancel
Save