diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/api-passenger/pom.xml b/api-passenger/pom.xml new file mode 100644 index 0000000..b7a2d0a --- /dev/null +++ b/api-passenger/pom.xml @@ -0,0 +1,52 @@ + + + + online-taxi-public + com.mashibing + 1.0-SNAPSHOT + + 4.0.0 + + api-passenger + + + 8 + 8 + + + + + org.springframework.boot + spring-boot-starter-web + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + + org.springframework.cloud + spring-cloud-starter-loadbalancer + + + + org.springframework.boot + spring-boot-starter-data-redis + + + + + + + + + \ No newline at end of file diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/ApiPassengerApplication.java b/api-passenger/src/main/java/com/mashibing/apipassenger/ApiPassengerApplication.java new file mode 100644 index 0000000..4bed353 --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/ApiPassengerApplication.java @@ -0,0 +1,15 @@ +package com.mashibing.apipassenger; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; + +@SpringBootApplication +@EnableDiscoveryClient +@EnableFeignClients +public class ApiPassengerApplication { + public static void main(String[] args) { + SpringApplication.run(ApiPassengerApplication.class); + } +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/Service/VerificationCodeService.java b/api-passenger/src/main/java/com/mashibing/apipassenger/Service/VerificationCodeService.java new file mode 100644 index 0000000..ae6e618 --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/Service/VerificationCodeService.java @@ -0,0 +1,113 @@ +package com.mashibing.apipassenger.Service; + +import com.mashibing.apipassenger.remote.ServicePassengerUserClient; +import com.mashibing.apipassenger.remote.ServiceVerificationCodeClient; +import com.mashibing.internal.common.constant.CommonStatusEnum; +import com.mashibing.internal.common.dto.ResponseResult; +import com.mashibing.internal.common.request.VerificationCodeDTO; +import com.mashibing.internal.common.response.NumberCodeResponse; +import com.mashibing.internal.common.response.TokenResponse; +import net.sf.json.JSONObject; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Service; + +import java.util.concurrent.TimeUnit; + +@Service +public class VerificationCodeService { + + @Autowired + private + ServiceVerificationCodeClient serviceVerificationCodeClient; + //乘客验证码的前缀 + private String verificationCodePrefix = "passenger-verification-code-"; + + @Autowired + private StringRedisTemplate stringRedisTemplate; + + + /** + * 生成验证码 + * @param passengerPhone + * @return + */ + public ResponseResult generatorCode(String passengerPhone) { + // 调用验证码服务,获取验证码 + System.out.println("调用验证码服务,获取验证码"); + + ResponseResult numberCodeResponse = serviceVerificationCodeClient.getNumberCode(6); + int numberCode = numberCodeResponse.getData().getNumberCode(); + + System.out.println("remote numberCode "+numberCode); + String code ="101111"; + + //存入redis + System.out.println("存入redis"); + + //key,value,过期时间 + String key = generatorKeyByPhone(passengerPhone); + + stringRedisTemplate.opsForValue().set(key,numberCode+"",2, TimeUnit.MINUTES); + + // 通过短信服务商,将对应的验证码发送到手机上,阿里短信服务,腾讯短信通,华信,容联 + + return ResponseResult.success(); + } + + /** + * 根据手机号生成key + * @param passengerPhone + * @return + */ + private String generatorKeyByPhone(String passengerPhone){ + return verificationCodePrefix+passengerPhone; + } + + @Autowired + private ServicePassengerUserClient servicePassengerUserClient; + + /** + * 校验验证码 + * @param passengerPhone + * @param verificationCode + * @return + */ + public ResponseResult checkCode(String passengerPhone,String verificationCode){ + + // 根据手机号,去redis读取验证码 + System.out.println("根据手机号,去redis读取验证码"); + + //生成key + String key = generatorKeyByPhone(passengerPhone); + + //根据key获取value + String codeRedis = stringRedisTemplate.opsForValue().get(key); + System.out.println("redis中的value:" + codeRedis); + + + // 校验验证码 + System.out.println("校验验证码"); + if(StringUtils.isBlank(codeRedis)){ + return ResponseResult.fail(CommonStatusEnum.VERIFICATION_CODE_ERROR.getCode(),CommonStatusEnum.VERIFICATION_CODE_ERROR.getValue()); + } + + if(!verificationCode.trim().equals(codeRedis.trim())){ + return ResponseResult.fail(CommonStatusEnum.VERIFICATION_CODE_ERROR.getCode(),CommonStatusEnum.VERIFICATION_CODE_ERROR.getValue()); + } + + // 判断原来是否有用户,并进行对应得处理 + VerificationCodeDTO verificationCodeDTO=new VerificationCodeDTO(); + verificationCodeDTO.setPassengerPhone(passengerPhone); + servicePassengerUserClient.loginOrRegister(verificationCodeDTO); + + // 颁发令牌 + System.out.println("颁发令牌"); + + //响应 + TokenResponse tokenResponse = new TokenResponse(); + tokenResponse.setToken("token value"); + return ResponseResult.success(tokenResponse); + } +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/controller/TestController.java b/api-passenger/src/main/java/com/mashibing/apipassenger/controller/TestController.java new file mode 100644 index 0000000..4949760 --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/controller/TestController.java @@ -0,0 +1,12 @@ +package com.mashibing.apipassenger.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class TestController { + @GetMapping("/test") + public String test(){ + return "test api passenger"; + } +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/controller/VerificationCodeController.java b/api-passenger/src/main/java/com/mashibing/apipassenger/controller/VerificationCodeController.java new file mode 100644 index 0000000..9c1327a --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/controller/VerificationCodeController.java @@ -0,0 +1,34 @@ +package com.mashibing.apipassenger.controller; + +import com.mashibing.apipassenger.Service.VerificationCodeService; +import com.mashibing.internal.common.request.VerificationCodeDTO; +import com.mashibing.internal.common.dto.ResponseResult; +import org.springframework.beans.factory.annotation.Autowired; +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; + +@RestController +public class VerificationCodeController { + + @Autowired + private VerificationCodeService verificationCodeService; + @GetMapping("/verification-code") + private ResponseResult verificationCode(@RequestBody VerificationCodeDTO verificationCodeDTO ){ + String passengerPhone = verificationCodeDTO.getPassengerPhone(); + System.out.println(passengerPhone); + return verificationCodeService.generatorCode(passengerPhone); + } + + @PostMapping("/verification-code-check") + public ResponseResult checkVerificationCode(@RequestBody VerificationCodeDTO verificationCodeDTO){ + + String passengerPhone = verificationCodeDTO.getPassengerPhone(); + System.out.println(passengerPhone); + String verificationCode = verificationCodeDTO.getVerificationCode(); + + System.out.println("手机号"+ passengerPhone + ",验证码:"+verificationCode); + return verificationCodeService.checkCode(passengerPhone,verificationCode); + } +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch01/MyArray.java b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch01/MyArray.java new file mode 100644 index 0000000..87ba855 --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch01/MyArray.java @@ -0,0 +1,88 @@ +package com.mashibing.apipassenger.mashibing.ch01; + +public class MyArray { + + private long[] arr; + //表示有效数据的长度 + private int elements; + + public MyArray(){ + arr =new long[50]; + } + + public MyArray(int maxSize){ + arr = new long[maxSize]; + } + + /** + * 添加数据 + */ + public void insert(long value){ + arr[elements] =value; + elements++; + } + /** + * 显示数据 + */ + public void display(){ + System.out.print("["); + for(int i=0;i=elements || index<0){ + throw new ArrayIndexOutOfBoundsException(); + }else{ + return arr[index]; + } + } + + /** + * 删除数据 + */ + + public void delete(int index){ + if(index>=elements || index < 0){ + throw new ArrayIndexOutOfBoundsException(); + }else{ + for(int i =index;i=elements || index < 0){ + throw new ArrayIndexOutOfBoundsException(); + }else { + arr[index] =newValue; + } + } +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch01/MyOrderArray.java b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch01/MyOrderArray.java new file mode 100644 index 0000000..3bf770a --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch01/MyOrderArray.java @@ -0,0 +1,121 @@ +package com.mashibing.apipassenger.mashibing.ch01; + +public class MyOrderArray { + + private long[] arr; + //表示有效数据的长度 + private int elements; + + public MyOrderArray(){ + arr =new long[50]; + } + + public MyOrderArray(int maxSize){ + arr = new long[maxSize]; + } + + /** + * 添加数据 + */ + public void insert(long value){ + int i; + for(i=0;ivalue){ + break; + } + } + + for(int j=elements;j>i;j--){ + arr[j] =arr[j-1]; + } + arr[i] = value; + elements++; + } + /** + * 显示数据 + */ + public void display(){ + System.out.print("["); + for(int i=0;ipow){ + return -1; + }else{ + if(arr[middle] > value) { + pow =middle -1; + }else{ + low = middle +1; + } + } + } + } + + /** + * 查找数据,根据索引来查 + */ + public long get(int index){ + if(index>=elements || index<0){ + throw new ArrayIndexOutOfBoundsException(); + }else{ + return arr[index]; + } + } + + /** + * 删除数据 + */ + + public void delete(int index){ + if(index>=elements || index < 0){ + throw new ArrayIndexOutOfBoundsException(); + }else{ + for(int i =index;i=elements || index < 0){ + throw new ArrayIndexOutOfBoundsException(); + }else { + arr[index] =newValue; + } + } +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch01/TestArray.java b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch01/TestArray.java new file mode 100644 index 0000000..1b09062 --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch01/TestArray.java @@ -0,0 +1,16 @@ +package com.mashibing.apipassenger.mashibing.ch01; + +public class TestArray { + + public static void main(String[] args){ + + long[] arr = new long[]{ + 2,3,4 + }; + arr[0] =1; + System.out.println(arr[0]); + System.out.println(arr[1]); + System.out.println(arr[2]); + } + +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch01/TestMyArray.java b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch01/TestMyArray.java new file mode 100644 index 0000000..67ad1e7 --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch01/TestMyArray.java @@ -0,0 +1,19 @@ +package com.mashibing.apipassenger.mashibing.ch01; + +public class TestMyArray { + public static void main(String[] args) { + + + MyArray arr = new MyArray(); + arr.insert(13); + arr.insert(34); + arr.insert(90); + arr.display(); + System.out.println(arr.search(34)); + System.out.println(arr.get(1)); + arr.delete(1); + arr.display(); + arr.change(0,12); + arr.display(); +} +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch01/TestMyOrderArray.java b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch01/TestMyOrderArray.java new file mode 100644 index 0000000..5d648ea --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch01/TestMyOrderArray.java @@ -0,0 +1,16 @@ +package com.mashibing.apipassenger.mashibing.ch01; + +public class TestMyOrderArray { + public static void main(String[] args) { + + + MyOrderArray arr = new MyOrderArray(); + arr.insert(13); + arr.insert(34); + arr.insert(90); + arr.insert(10); + arr.display(); + + System.out.println(arr.binarySearch(90)); +} +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch02/BubbleSort.java b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch02/BubbleSort.java new file mode 100644 index 0000000..ae3de2f --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch02/BubbleSort.java @@ -0,0 +1,18 @@ +package com.mashibing.apipassenger.mashibing.ch02; + +public class BubbleSort { + + public static void sort(long[] arr){ + long temp =0; + for(int i =0;ii;j--){ + if(arr[j]0 && arr[j]>=temp){ + arr[j] =arr[j-1]; + j--; + } + arr[j] =temp; + } + } +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch02/SelectionSort.java b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch02/SelectionSort.java new file mode 100644 index 0000000..0e9582d --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch02/SelectionSort.java @@ -0,0 +1,20 @@ +package com.mashibing.apipassenger.mashibing.ch02; + +public class SelectionSort { + + public static void sort(long[] arr){ + int k=0; + long temp =0; + for(int i=0;i0){ + total=total+n; + n--; + } + return total; + } + + + public static int getNumberByRecursion(int n){ + if(n == 1){ + return 1; + }else{ + return n+getNumberByRecursion(n-1); + } + } +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch07/HanoiTower.java b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch07/HanoiTower.java new file mode 100644 index 0000000..b16b674 --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch07/HanoiTower.java @@ -0,0 +1,21 @@ +package com.mashibing.apipassenger.mashibing.ch07; + +public class HanoiTower { + + /** + * 移动盘子 + * topN:移动的盘子数 + * from:起始塔座 + * inter:中间塔座 + * to:目标塔座 + */ + public static void doTower(int topN,char from,char inter,char to){ + if(topN ==1){ + System.out.println("盘子1,从" +from+"塔座到"+to+"塔座"); + }else{ + doTower(topN-1,from,to,inter); + System.out.println("盘子"+topN +",从"+from +"塔座到"+to +"塔座"); + doTower(topN-1,inter,from,to); + } + } +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch07/TestHanoiTower.java b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch07/TestHanoiTower.java new file mode 100644 index 0000000..4d20bd7 --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch07/TestHanoiTower.java @@ -0,0 +1,7 @@ +package com.mashibing.apipassenger.mashibing.ch07; + +public class TestHanoiTower { + public static void main(String[] args){ + HanoiTower.doTower(3,'A','B','C'); + } +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch08/ShellSort.java b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch08/ShellSort.java new file mode 100644 index 0000000..d374ae7 --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch08/ShellSort.java @@ -0,0 +1,31 @@ +package com.mashibing.apipassenger.mashibing.ch08; + +public class ShellSort { + /** + * 排序方法 + */ + public static void sort(long[] arr){ + //初始化一个间隔 + int h=1; + //计算最大间隔 + while(h0){ + //进行插入排序 + long temp =0; + for(int i=h;ih-1 && arr[j-h] >= temp){ + arr[j]=arr[j-h]; + j-=h; + } + arr[j] = temp; + } + //减小间隔 + h= (h-1)/3; + } + } +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch08/TestShellSort.java b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch08/TestShellSort.java new file mode 100644 index 0000000..9901547 --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch08/TestShellSort.java @@ -0,0 +1,28 @@ +package com.mashibing.apipassenger.mashibing.ch08; + +import com.mashibing.apipassenger.mashibing.ch02.BubbleSort; + +public class TestShellSort { + public static void main(String[] args){ + long[] arr = new long[5]; + arr[0] =34; + arr[1] =23; + arr[2] =2; + arr[3] =1; + arr[4] =-4; + System.out.print("["); + for(long num:arr){ + System.out.print(num+" "); + } + System.out.print("]"); + System.out.println(); + ShellSort.sort(arr); + + System.out.print("["); + for(long num:arr){ + System.out.print(num+" "); + } + System.out.print("]"); + System.out.println(); + } +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch09/QuickSort.java b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch09/QuickSort.java new file mode 100644 index 0000000..7af132c --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch09/QuickSort.java @@ -0,0 +1,26 @@ +package com.mashibing.apipassenger.mashibing.ch09; + +public class QuickSort { + + /** + * 划分数组 + */ + + public static void partition(long arr[] ,int left,int right,int point){ + int leftPtr = left-1; + int rightPtr = right + 1; + while(true){ + //循环,将比关键字小的留在左端 + while(leftPtrleftPtr && arr[--rightPtr] >point) ; + if(leftPtr>=rightPtr){ + return; + }else{ + long temp = arr[leftPtr]; + arr[leftPtr] = arr[rightPtr]; + arr[rightPtr] =temp; + } + } + } +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch09/TestQuickSort.java b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch09/TestQuickSort.java new file mode 100644 index 0000000..e9a7dc0 --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch09/TestQuickSort.java @@ -0,0 +1,27 @@ +package com.mashibing.apipassenger.mashibing.ch09; + +public class TestQuickSort { + + public static void main(String[] args){ + long[] arr =new long[10]; + for(int i=0;i<10;i++){ + arr[i] = (long)(Math.random()*99); + } + + System.out.print("["); + for(long num:arr){ + System.out.print(num+" "); + } + System.out.print("]"); + System.out.println(); + + QuickSort.partition(arr,0,arr.length-1,45); + + System.out.print("["); + for(long num:arr){ + System.out.print(num+" "); + } + System.out.print("]"); + System.out.println(); + } +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch10/Node.java b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch10/Node.java new file mode 100644 index 0000000..270f03b --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch10/Node.java @@ -0,0 +1,25 @@ +package com.mashibing.apipassenger.mashibing.ch10; + +import lombok.Data; + +@Data +public class Node { + //数据项 + public long data; + + //数据项 + public String sData; + //左子节点 + public Node leftChild; + + //右子节点 + public Node rightChild; + + public Node(long data) { + this.data = data; + } + public Node(long data,String sData){ + this.data = data; + this.sData=sData; + } +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch10/Tree.java b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch10/Tree.java new file mode 100644 index 0000000..b6152cc --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch10/Tree.java @@ -0,0 +1,67 @@ +package com.mashibing.apipassenger.mashibing.ch10; + +/** + * 二叉树 + */ +public class Tree { + //根节点 + public Node root; + + /** + * 插入节点 + * @param value + */ + public void insert(long value){ + //封装节点 + Node newNode = new Node(value); + //引用当前节点 + Node current = root; + //易怒用父节点 + Node parent; + //如果root为努力了,也就是第一插入的时候 + if(root == null){ + root = newNode; + return; + }else{ + while(true) { + //父节点指向当前 + parent = current; + if (current.data > value) { + current = current.leftChild; + if(current == null){ + parent.leftChild = newNode; + return; + } + } else { + current = current.rightChild; + if(current == null){ + parent.rightChild = newNode; + return; + } + } + } + } + } + + /** + * 查找节点 + * @param value + */ + public Node find(long value){ + //引用当前节点,从根节点开始 + Node current = root; + //循环,只要查找值不等于当前节点的数据项 + while(current.data != value){ + //进行比较,比较查找值和当前节点的大小 + if(current.data >value){ + current = current.leftChild; + }else{ + current = current.rightChild; + } + if(current == null){ + return null; + } + } + return current; + } +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch18/Graph.java b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch18/Graph.java new file mode 100644 index 0000000..2f34dc9 --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/ch18/Graph.java @@ -0,0 +1,26 @@ +package com.mashibing.apipassenger.mashibing.ch18; + +/** + * 图 + */ +public class Graph { + + //顶点数组 + private Vertex[] vertexList; + //邻接矩阵 + private int[][] adjMat; + //顶点的最大数目 + private int maxSize; + //当前顶点 + private int nVertex; + public Graph(){ + vertexList = new Vertex[maxSize]; + adjMat = new int[maxSize][maxSize]; + for(int i=0;i0;i--){ + for(int j=0;j a[j + 1]) { + swap(a, j, j + 1); + } + } + } + } + + static void swap(int[] a,int i,int j){ + int temp = a[i]; + a[i] = a[j]; + a[j] =temp; + } + + static void print(int[] arr){ + for(int i=0;i0;j--){ + if(a[j] 0;gap=(gap-1)/3) { + for (int i = gap; i < a.length; i++) { + for (int j = i; j > gap - 1; j -= gap) { + if (a[j] < a[j - gap]) { + swap(a, j, j - gap); + } + } + } + } + } + static void swap(int[] a,int i,int j){ + int temp =a[i]; + a[i]= a[j]; + a[j]=temp; + } + + static void print(int[] arr){ + for(int i=0;i list =new ArrayList<>(); + Scanner in = new Scanner(System.in); + // 注意 hasNext 和 hasNextLine 的区别 + + while (in.hasNextLine()) { // 注意 while 处理多个 case + + String a = in.nextLine(); + int c = Integer.valueOf(a); + for(int i=0;i map1=new HashMap<>(); + Map map2=new HashMap<>(); + //被禁用的单词放入map1 + for(String str:banned){ + map1.put(str,1); + } + //把没有禁用的单词放入map2 + for(String str : s){ + if(!map1.containsKey(str)&&!str.equals("")){ + map2.put(str,map2.getOrDefault(str,0)+1); + } + } + //在map2找出出现最多的单词 + int max=-1; + String res=null; + for(String str:map2.keySet()){ + if(map2.get(str)>max){ + max=map2.get(str); + res=str; + } + } + System.out.println(res); + + } +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/test01/Test03.java b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/test01/Test03.java new file mode 100644 index 0000000..9dbeade --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/test01/Test03.java @@ -0,0 +1,7 @@ +package com.mashibing.apipassenger.mashibing.test01; + +public class Test03 { + public static void main(String[] args) { + + } +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/test01/Test04.java b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/test01/Test04.java new file mode 100644 index 0000000..0533e30 --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/mashibing/test01/Test04.java @@ -0,0 +1,15 @@ +package com.mashibing.apipassenger.mashibing.test01; + +public class Test04 { + public static void main(String[] args) { + long a = 2000000014; + + for(long i=2;i<=a;i++){ + + while(a % i==0){ + System.out.print(i+" "); + a /= i; + } + } + } +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/remote/ServicePassengerUserClient.java b/api-passenger/src/main/java/com/mashibing/apipassenger/remote/ServicePassengerUserClient.java new file mode 100644 index 0000000..0d582b8 --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/remote/ServicePassengerUserClient.java @@ -0,0 +1,14 @@ +package com.mashibing.apipassenger.remote; + +import com.mashibing.internal.common.dto.ResponseResult; +import com.mashibing.internal.common.request.VerificationCodeDTO; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +@FeignClient("service-passenger-user") +public interface ServicePassengerUserClient { + @RequestMapping(method = RequestMethod.POST,value = "/user") + public ResponseResult loginOrRegister(@RequestBody VerificationCodeDTO verificationCodeDTO); +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/remote/ServiceVerificationCodeClient.java b/api-passenger/src/main/java/com/mashibing/apipassenger/remote/ServiceVerificationCodeClient.java new file mode 100644 index 0000000..00948a8 --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/remote/ServiceVerificationCodeClient.java @@ -0,0 +1,15 @@ +package com.mashibing.apipassenger.remote; + +import com.mashibing.internal.common.dto.ResponseResult; +import com.mashibing.internal.common.response.NumberCodeResponse; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +@FeignClient("service-verificationcode") +public interface ServiceVerificationCodeClient { + + @RequestMapping(method = RequestMethod.GET,value = "/numberCode/{size}") + ResponseResult getNumberCode(@PathVariable("size") int size); +} diff --git a/api-passenger/src/main/resources/application.yml b/api-passenger/src/main/resources/application.yml new file mode 100644 index 0000000..e71ce3f --- /dev/null +++ b/api-passenger/src/main/resources/application.yml @@ -0,0 +1,17 @@ +server: + port: 8081 + +spring: + cloud: + nacos: + discovery: + access-key: 127.0.0.1:8848 + + application: + name: api-passenger + + + redis: + host: 127.0.0.1 + port: 6379 + database: 0 \ No newline at end of file diff --git a/api-passenger/src/test/java/test/Test01.java b/api-passenger/src/test/java/test/Test01.java new file mode 100644 index 0000000..3a4e856 --- /dev/null +++ b/api-passenger/src/test/java/test/Test01.java @@ -0,0 +1,102 @@ +package test; + +import org.junit.Test; + +import java.util.Arrays; + +public class Test01 { + + static void print(int[] arr){ + for(int i =0;i pivot){ + right--; + } + if(left= rightBound){ + return; + } + int mid= partition(arr,leftBound,rightBound); + sort(arr,leftBound,mid -1); + sort(arr,mid+1,rightBound); + } + @Test + public void test01(){ + /** + * 1.通读程序 + * 2.输出中间值 + * 3.剪功能 + */ + int[] arr = {7,3,2,8,1,9,5,4,6,10}; + sort(arr,0,arr.length -1); + print(arr); + } + + @Test + public void test02(){ + int[] arr = {2,4,2,3,7,1,1,0,0,5,6,9,8,5,7,4,0,9}; + int[] result = sort(arr); + System.out.println(Arrays.toString(result)); + } + + static int[] sort(int[] arr){ + int[] result = new int[arr.length]; + int[] count = new int[10]; + for(int i=0;i0){ +// result[j++]=i; +// } +// +// } + + for(int i=1;i=0;i--){ + result[--count[arr[i]]]=arr[i]; + } + return result; + } + + @Test + public void test03(){ + StringBuilder result = new StringBuilder(); + result.append('a'); + result.append('b'); + System.out.println(result.toString()); + if(result.length()>0){ + result.deleteCharAt(result.length()-1); + } + System.out.println(result.toString()); + } +} diff --git a/api-passenger/src/test/java/test/test02.java b/api-passenger/src/test/java/test/test02.java new file mode 100644 index 0000000..4323ac4 --- /dev/null +++ b/api-passenger/src/test/java/test/test02.java @@ -0,0 +1,176 @@ +package test; + +import org.junit.Test; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +public class test02 { + @Test + public void test01() { + int[] arr = {421, 240, 115, 532, 305, 430, 124}; +// int[] result = sort(arr); +// System.out.println(Arrays.toString(result)); + } + + /*public static int[] sort(int[] arr) { + int[] result = new int[arr.length]; + int[] count = new int[10]; + for(int i=0;i<3;i++){ + int division = (int)Math.pow(10,i); + System.out.println(division); + + } + }*/ + @Test + public void test02() { + int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 6}; + int x1 = 0; + for (int i = 1; i <= 10; i++) { + x1 = (x1 ^ i); + } + System.out.println(x1); + for (int i = 0; i < 11; i++) { + x1 = x1 ^ arr[i]; + } + System.out.println(x1); + + int[] helper = new int[11]; + for (int i = 0; i < 11; i++) { + helper[arr[i]]++; + } + for (int i = 0; i < 11; i++) { + if (helper[i] == 2) { + System.out.println(i); + break; + } + } + } + + + @Test + public void test03() { + int N = 9; + int count = 0; + while (N != 0) { + N = ((N - 1) & N); + count++; + } + System.out.println(count); + } + + @Test + public void test04() { + /** + * 用一条语句判断一个整数是不是2的整数次方 + */ + + int N = 8; + if (((N - 1) & N) == 0) { + System.out.println(N + ":是2的整数次方"); + } else { + System.out.println(N + ":不是2的整数次方"); + } + } + + @Test + public void test05() { + /** + * 题5:将整数的奇偶位互换 + */ + int i = 6; + int out = i & 0xaaaaaaaa; + int ji = i & 0x55555555; + System.out.println(out >> 1 ^ ji << 1); + } + + @Test + public void test06() { + /** + * 题6:0-1间浮点实数的二进制表示 + * 给定一个介于0和1之间的实数,(如0.625),类型为double, + * 打印它的二进制表示(0.101, + * 因为小数点后的二进制分别表示0.5,0.25,0.125.。。)。 + * 如果该数字无法精确地用32位以内的二进制表示,则打印“ERROR" + */ + double num = 0.625; + StringBuilder sb = new StringBuilder("0."); + while (num > 0) { + //乘2挪整 + double r = num * 2; + //判断整数部分 + if (r >= 1) { + sb.append("1"); + //消掉整数部分 + num = r - 1; + } else { + sb.append("0"); + num = r; + } + if (sb.length() > 34) { + System.out.println("ERROR"); + return; + } + } + System.out.println(sb.toString()); + } + + @Test + public void test07() { + /** + * 数组中只有一个数出现乐1次,其他的数都出现乐k次,请输出只出现了1次的数。 + * + */ + int[] arr = {2, 2, 2, 9, 7, 7, 7, 3, 3, 3, 6, 6, 6, 0, 0, 0}; + int len = arr.length; + char[][] kRadix = new char[len][]; + int k = 3; + int maxLen = 0; + //转成k进制字符数组 + //对于每个数字 + for (int i = 0; i < len; i++) { + //求每个数字的三进制字符串并反转,然后转为字符数组 + kRadix[i] = new StringBuilder(Integer.toString(arr[i], k)).reverse().toString().toCharArray(); + if (kRadix[i].length > maxLen) { + maxLen = kRadix[i].length; + } + } + int[] resArr = new int[maxLen]; + for (int j = 0; j < len; j++) { + //不进位加法 + for (int m = 0; m < maxLen; m++) { + if (m >= kRadix[j].length) { + resArr[m] += 0; + } else { + resArr[m] += (kRadix[j][m] - '0'); + } + } + } + int res = 0; + for (int j = 0; j < maxLen; j++) { + res += (resArr[j] % k) * (int) (Math.pow(k, j)); + } + System.out.println(res); + } + + @Test + public void test08(){ + /** + * 数组中只有一个数出现乐1次,其他的数都出现乐k次,请输出只出现了1次的数。 + * 暴力破解 + */ + int[] arr = {2, 2, 2, 9, 7, 7, 7, 3, 3, 3, 6, 6, 6, 0, 0, 0}; + Map map = new HashMap<>(); + for(int i=0;i + \ No newline at end of file diff --git a/internal-common/pom.xml b/internal-common/pom.xml new file mode 100644 index 0000000..cb9f322 --- /dev/null +++ b/internal-common/pom.xml @@ -0,0 +1,15 @@ + + + + online-taxi-public + com.mashibing + 1.0-SNAPSHOT + + 4.0.0 + + internal-common + + + \ No newline at end of file diff --git a/internal-common/src/main/java/com/mashibing/internal/common/constant/CommonStatusEnum.java b/internal-common/src/main/java/com/mashibing/internal/common/constant/CommonStatusEnum.java new file mode 100644 index 0000000..e75637c --- /dev/null +++ b/internal-common/src/main/java/com/mashibing/internal/common/constant/CommonStatusEnum.java @@ -0,0 +1,30 @@ +package com.mashibing.internal.common.constant; + +import lombok.Getter; + +public enum CommonStatusEnum { + /** + * 验证码错误提示:1000-1099 + */ + VERIFICATION_CODE_ERROR(1099,"验证码不正确"), + /** + * 成功 + */ + SUCCESS(1,"success"), + + /** + * 失败 + */ + FAIL(0,"fail"); + + @Getter + private int code; + @Getter + private String value; + + + CommonStatusEnum(int code, String value) { + this.code = code; + this.value = value; + } +} diff --git a/internal-common/src/main/java/com/mashibing/internal/common/dto/ResponseResult.java b/internal-common/src/main/java/com/mashibing/internal/common/dto/ResponseResult.java new file mode 100644 index 0000000..1718541 --- /dev/null +++ b/internal-common/src/main/java/com/mashibing/internal/common/dto/ResponseResult.java @@ -0,0 +1,64 @@ +package com.mashibing.internal.common.dto; + +import com.mashibing.internal.common.constant.CommonStatusEnum; +import lombok.Data; +import lombok.experimental.Accessors; + +@Data +@Accessors(chain = true) +public class ResponseResult { + + private int code; + private String message; + private T data; + + /** + * 成功响应的方法 + * @param + * @return + */ + public static ResponseResult success(){ + return new ResponseResult().setCode(CommonStatusEnum.SUCCESS.getCode()).setMessage(CommonStatusEnum.SUCCESS.getValue()); + } + /** + * 成功响应的方法 + * @param data + * @param + * @return + */ + public static ResponseResult success(T data){ + + return new ResponseResult().setCode(CommonStatusEnum.SUCCESS.getCode()).setMessage(CommonStatusEnum.SUCCESS.getValue()).setData(data); + } + + /** + * 失败:统一的失败 + * @param data + * @param + * @return + */ + public static ResponseResult fail(T data){ + return new ResponseResult().setData(data); + } + + /** + * 失败,自定义失败,错误码和提示信息 + * @param code + * @param message + * @return + */ + public static ResponseResult fail(int code,String message){ + return new ResponseResult().setCode(code).setMessage(message); + } + + /** + * 失败:自定义失败 错误码和提示信息 + * @param code + * @param message + * @param data + * @return + */ + public static ResponseResult fail(int code,String message,String data){ + return new ResponseResult().setCode(code).setMessage(message).setData(data); + } +} diff --git a/internal-common/src/main/java/com/mashibing/internal/common/request/VerificationCodeDTO.java b/internal-common/src/main/java/com/mashibing/internal/common/request/VerificationCodeDTO.java new file mode 100644 index 0000000..3d0c674 --- /dev/null +++ b/internal-common/src/main/java/com/mashibing/internal/common/request/VerificationCodeDTO.java @@ -0,0 +1,13 @@ +package com.mashibing.internal.common.request; + +import lombok.Data; + +@Data +public class VerificationCodeDTO { + + private String passengerPhone; + + private String verificationCode; + + +} diff --git a/internal-common/src/main/java/com/mashibing/internal/common/response/NumberCodeResponse.java b/internal-common/src/main/java/com/mashibing/internal/common/response/NumberCodeResponse.java new file mode 100644 index 0000000..4ac8f51 --- /dev/null +++ b/internal-common/src/main/java/com/mashibing/internal/common/response/NumberCodeResponse.java @@ -0,0 +1,8 @@ +package com.mashibing.internal.common.response; + +import lombok.Data; + +@Data +public class NumberCodeResponse { + private int numberCode; +} diff --git a/internal-common/src/main/java/com/mashibing/internal/common/response/TokenResponse.java b/internal-common/src/main/java/com/mashibing/internal/common/response/TokenResponse.java new file mode 100644 index 0000000..cfd6dd2 --- /dev/null +++ b/internal-common/src/main/java/com/mashibing/internal/common/response/TokenResponse.java @@ -0,0 +1,8 @@ +package com.mashibing.internal.common.response; + +import lombok.Data; + +@Data +public class TokenResponse { + private String token; +} diff --git a/internal-common/src/main/java/com/mashibing/internal/common/util/JwtUtils.java b/internal-common/src/main/java/com/mashibing/internal/common/util/JwtUtils.java new file mode 100644 index 0000000..44f5d63 --- /dev/null +++ b/internal-common/src/main/java/com/mashibing/internal/common/util/JwtUtils.java @@ -0,0 +1,43 @@ +package com.mashibing.internal.common.util; + +import com.auth0.jwt.JWT; +import com.auth0.jwt.JWTCreator; +import com.auth0.jwt.algorithms.Algorithm; + +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +public class JwtUtils { + //盐 + private static final String SIGN = "CPFmsb!@#$$"; + + //生成token + public static String generatorToken(Map map){ + //token过期时间 + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DATE,1); + Date date = calendar.getTime(); + + JWTCreator.Builder builder = JWT.create(); + map.forEach((k,v)->{ + builder.withClaim(k,v); + }); + //整合过期时间 + builder.withExpiresAt(date); + + String sign = builder.sign(Algorithm.HMAC256(SIGN)); + return sign; + } + + //解析token + + public static void main(String[] args) { + Map map = new HashMap<>(); + map.put("name","zhangsan"); + map.put("age","18"); + String s = generatorToken(map); + System.out.println("生成的token:"+s); + } +} diff --git a/internal-common/target/classes/com/mashibing/internal/common/constant/CommonStatusEnum.class b/internal-common/target/classes/com/mashibing/internal/common/constant/CommonStatusEnum.class new file mode 100644 index 0000000..345d652 Binary files /dev/null and b/internal-common/target/classes/com/mashibing/internal/common/constant/CommonStatusEnum.class differ diff --git a/internal-common/target/classes/com/mashibing/internal/common/dto/ResponseResult.class b/internal-common/target/classes/com/mashibing/internal/common/dto/ResponseResult.class new file mode 100644 index 0000000..e2c6db9 Binary files /dev/null and b/internal-common/target/classes/com/mashibing/internal/common/dto/ResponseResult.class differ diff --git a/internal-common/target/classes/com/mashibing/internal/common/request/VerificationCodeDTO.class b/internal-common/target/classes/com/mashibing/internal/common/request/VerificationCodeDTO.class new file mode 100644 index 0000000..72fad15 Binary files /dev/null and b/internal-common/target/classes/com/mashibing/internal/common/request/VerificationCodeDTO.class differ diff --git a/internal-common/target/classes/com/mashibing/internal/common/response/NumberCodeResponse.class b/internal-common/target/classes/com/mashibing/internal/common/response/NumberCodeResponse.class new file mode 100644 index 0000000..eea1015 Binary files /dev/null and b/internal-common/target/classes/com/mashibing/internal/common/response/NumberCodeResponse.class differ diff --git a/internal-common/target/classes/com/mashibing/internal/common/response/TokenResponse.class b/internal-common/target/classes/com/mashibing/internal/common/response/TokenResponse.class new file mode 100644 index 0000000..3beb1f4 Binary files /dev/null and b/internal-common/target/classes/com/mashibing/internal/common/response/TokenResponse.class differ diff --git a/internal-common/target/classes/com/mashibing/internal/common/util/JwtUtils.class b/internal-common/target/classes/com/mashibing/internal/common/util/JwtUtils.class new file mode 100644 index 0000000..2076d72 Binary files /dev/null and b/internal-common/target/classes/com/mashibing/internal/common/util/JwtUtils.class differ diff --git a/online-taxi-public.iml b/online-taxi-public.iml new file mode 100644 index 0000000..78b2cc5 --- /dev/null +++ b/online-taxi-public.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..66a6c52 --- /dev/null +++ b/pom.xml @@ -0,0 +1,97 @@ + + + 4.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 2.4.13 + + + + com.mashibing + online-taxi-public + 1.0-SNAPSHOT + + + api-passenger + internal-common + service-passenger-user + + + pom + + + 8 + 8 + + + + + net.sf.json-lib + json-lib + 2.4 + jdk15 + + + + + org.projectlombok + lombok + 1.18.24 + + + + + com.auth0 + java-jwt + 3.14.0 + + + + + junit + junit + 4.12 + test + + + + com.mashibing + internal-common + 1.0-SNAPSHOT + + + + com.auth0 + java-jwt + 3.14.0 + + + + + + + + + com.alibaba.cloud + spring-cloud-alibaba-dependencies + 2021.1 + pom + import + + + + org.springframework.cloud + spring-cloud-dependencies + 2020.0.1 + pom + import + + + + + + \ No newline at end of file diff --git a/service-passenger-user/pom.xml b/service-passenger-user/pom.xml new file mode 100644 index 0000000..4d919bb --- /dev/null +++ b/service-passenger-user/pom.xml @@ -0,0 +1,40 @@ + + + + online-taxi-public + com.mashibing + 1.0-SNAPSHOT + + 4.0.0 + + service-passenger-user + + + + + org.springframework.boot + spring-boot-starter-web + + + + + + com.baomidou + mybatis-plus-boot-starter + 3.4.3.1 + + + + mysql + mysql-connector-java + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + \ No newline at end of file diff --git a/service-passenger-user/service-passenger-user.iml b/service-passenger-user/service-passenger-user.iml new file mode 100644 index 0000000..78b2cc5 --- /dev/null +++ b/service-passenger-user/service-passenger-user.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/service-passenger-user/src/main/java/com/mashibing/servicepassengeruser/ServicePassengerUserApplication.java b/service-passenger-user/src/main/java/com/mashibing/servicepassengeruser/ServicePassengerUserApplication.java new file mode 100644 index 0000000..cd0d7a2 --- /dev/null +++ b/service-passenger-user/src/main/java/com/mashibing/servicepassengeruser/ServicePassengerUserApplication.java @@ -0,0 +1,15 @@ +package com.mashibing.servicepassengeruser; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +@SpringBootApplication +@EnableDiscoveryClient +@MapperScan("com.mashibing.servicepassengeruser.mapper") +public class ServicePassengerUserApplication { + public static void main(String[] args){ + SpringApplication.run(ServicePassengerUserApplication.class); + } +} diff --git a/service-passenger-user/src/main/java/com/mashibing/servicepassengeruser/controller/TestController.java b/service-passenger-user/src/main/java/com/mashibing/servicepassengeruser/controller/TestController.java new file mode 100644 index 0000000..978495e --- /dev/null +++ b/service-passenger-user/src/main/java/com/mashibing/servicepassengeruser/controller/TestController.java @@ -0,0 +1,12 @@ +package com.mashibing.servicepassengeruser.controller; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class TestController { + @RequestMapping("/test") + public String test(){ + return "service-passenger-user"; + } +} diff --git a/service-passenger-user/src/main/java/com/mashibing/servicepassengeruser/controller/UserController.java b/service-passenger-user/src/main/java/com/mashibing/servicepassengeruser/controller/UserController.java new file mode 100644 index 0000000..e04cff3 --- /dev/null +++ b/service-passenger-user/src/main/java/com/mashibing/servicepassengeruser/controller/UserController.java @@ -0,0 +1,24 @@ +package com.mashibing.servicepassengeruser.controller; + +import com.mashibing.internal.common.dto.ResponseResult; +import com.mashibing.internal.common.request.VerificationCodeDTO; +import com.mashibing.servicepassengeruser.service.UserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class UserController { + + @Autowired + private UserService userService; + + @PostMapping("/user") + public ResponseResult loginOrRegister(@RequestBody VerificationCodeDTO verificationCodeDTO){ + + String passengerPhone = verificationCodeDTO.getPassengerPhone(); + System.out.println("手机号:"+ passengerPhone); + return userService.loginOrRegister(passengerPhone); + } +} diff --git a/service-passenger-user/src/main/java/com/mashibing/servicepassengeruser/dto/PassengerUser.java b/service-passenger-user/src/main/java/com/mashibing/servicepassengeruser/dto/PassengerUser.java new file mode 100644 index 0000000..7932644 --- /dev/null +++ b/service-passenger-user/src/main/java/com/mashibing/servicepassengeruser/dto/PassengerUser.java @@ -0,0 +1,22 @@ +package com.mashibing.servicepassengeruser.dto; + +import lombok.Data; + +import java.time.LocalDateTime; +@Data +public class PassengerUser { + + private Long id; + + private LocalDateTime gmtCreate; + + private LocalDateTime gmtModified; + + private String passengerPhone; + + private String passengerName; + + private byte passengerGender; + + private byte state; +} diff --git a/service-passenger-user/src/main/java/com/mashibing/servicepassengeruser/mapper/PassengerUserMapper.java b/service-passenger-user/src/main/java/com/mashibing/servicepassengeruser/mapper/PassengerUserMapper.java new file mode 100644 index 0000000..73702b7 --- /dev/null +++ b/service-passenger-user/src/main/java/com/mashibing/servicepassengeruser/mapper/PassengerUserMapper.java @@ -0,0 +1,9 @@ +package com.mashibing.servicepassengeruser.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mashibing.servicepassengeruser.dto.PassengerUser; +import org.springframework.stereotype.Repository; + +@Repository +public interface PassengerUserMapper extends BaseMapper { +} diff --git a/service-passenger-user/src/main/java/com/mashibing/servicepassengeruser/service/UserService.java b/service-passenger-user/src/main/java/com/mashibing/servicepassengeruser/service/UserService.java new file mode 100644 index 0000000..a2d669f --- /dev/null +++ b/service-passenger-user/src/main/java/com/mashibing/servicepassengeruser/service/UserService.java @@ -0,0 +1,53 @@ +package com.mashibing.servicepassengeruser.service; + +import com.mashibing.internal.common.dto.ResponseResult; +import com.mashibing.servicepassengeruser.dto.PassengerUser; +import com.mashibing.servicepassengeruser.mapper.PassengerUserMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class UserService { + + @Autowired + private PassengerUserMapper passengerUserMapper; + + public ResponseResult loginOrRegister(String passengerPhone){ + System.out.println("user service被调用"+passengerPhone); + //根据手机号查询用户信息 + + Map map = new HashMap<>(); + map.put("passenger_phone",passengerPhone); + List passengerUsers = passengerUserMapper.selectByMap(map); + System.out.println(passengerUsers.size() == 0 ? "无记录":passengerUsers.get(0).getPassengerName()); + + + //判断用户信息是否存在 + if(passengerUsers.size()==0){ + + //如果不存在,插入用户信息 + PassengerUser passengerUser= new PassengerUser(); + passengerUser.setPassengerName("张三"); + passengerUser.setPassengerGender((byte)0); + passengerUser.setPassengerPhone(passengerPhone); + passengerUser.setState((byte)0); + + LocalDateTime now = LocalDateTime.now(); + passengerUser.setGmtCreate(now); + passengerUser.setGmtModified(now); + + passengerUserMapper.insert(passengerUser); + + } + + //如果不存在,插入用户信息 + + + return ResponseResult.success(); + } +} diff --git a/service-passenger-user/src/main/resources/application.yml b/service-passenger-user/src/main/resources/application.yml new file mode 100644 index 0000000..c2e5593 --- /dev/null +++ b/service-passenger-user/src/main/resources/application.yml @@ -0,0 +1,17 @@ +server: + port: 8083 + +spring: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:3306/service-passenger-user?characterEncoding=utf-8 + username: root + password: root + + cloud: + nacos: + discovery: + server-addr: 127.0.0.1:8848 + + application: + name: service-passenger-user \ No newline at end of file diff --git a/service-passenger-user/target/classes/application.yml b/service-passenger-user/target/classes/application.yml new file mode 100644 index 0000000..c2e5593 --- /dev/null +++ b/service-passenger-user/target/classes/application.yml @@ -0,0 +1,17 @@ +server: + port: 8083 + +spring: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:3306/service-passenger-user?characterEncoding=utf-8 + username: root + password: root + + cloud: + nacos: + discovery: + server-addr: 127.0.0.1:8848 + + application: + name: service-passenger-user \ No newline at end of file diff --git a/service-passenger-user/target/classes/com/mashibing/servicepassengeruser/ServicePassengerUserApplication.class b/service-passenger-user/target/classes/com/mashibing/servicepassengeruser/ServicePassengerUserApplication.class new file mode 100644 index 0000000..bc5ca67 Binary files /dev/null and b/service-passenger-user/target/classes/com/mashibing/servicepassengeruser/ServicePassengerUserApplication.class differ diff --git a/service-passenger-user/target/classes/com/mashibing/servicepassengeruser/controller/TestController.class b/service-passenger-user/target/classes/com/mashibing/servicepassengeruser/controller/TestController.class new file mode 100644 index 0000000..beb43fd Binary files /dev/null and b/service-passenger-user/target/classes/com/mashibing/servicepassengeruser/controller/TestController.class differ diff --git a/service-passenger-user/target/classes/com/mashibing/servicepassengeruser/controller/UserController.class b/service-passenger-user/target/classes/com/mashibing/servicepassengeruser/controller/UserController.class new file mode 100644 index 0000000..19a80f4 Binary files /dev/null and b/service-passenger-user/target/classes/com/mashibing/servicepassengeruser/controller/UserController.class differ diff --git a/service-passenger-user/target/classes/com/mashibing/servicepassengeruser/dto/PassengerUser.class b/service-passenger-user/target/classes/com/mashibing/servicepassengeruser/dto/PassengerUser.class new file mode 100644 index 0000000..0dc80b1 Binary files /dev/null and b/service-passenger-user/target/classes/com/mashibing/servicepassengeruser/dto/PassengerUser.class differ diff --git a/service-passenger-user/target/classes/com/mashibing/servicepassengeruser/mapper/PassengerUserMapper.class b/service-passenger-user/target/classes/com/mashibing/servicepassengeruser/mapper/PassengerUserMapper.class new file mode 100644 index 0000000..760958b Binary files /dev/null and b/service-passenger-user/target/classes/com/mashibing/servicepassengeruser/mapper/PassengerUserMapper.class differ diff --git a/service-passenger-user/target/classes/com/mashibing/servicepassengeruser/service/UserService.class b/service-passenger-user/target/classes/com/mashibing/servicepassengeruser/service/UserService.class new file mode 100644 index 0000000..95680fb Binary files /dev/null and b/service-passenger-user/target/classes/com/mashibing/servicepassengeruser/service/UserService.class differ diff --git a/service-verificationcode/.gitignore b/service-verificationcode/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/service-verificationcode/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/service-verificationcode/.mvn/wrapper/maven-wrapper.jar b/service-verificationcode/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..cb28b0e Binary files /dev/null and b/service-verificationcode/.mvn/wrapper/maven-wrapper.jar differ diff --git a/service-verificationcode/.mvn/wrapper/maven-wrapper.properties b/service-verificationcode/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..462686e --- /dev/null +++ b/service-verificationcode/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.3/apache-maven-3.9.3-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar diff --git a/service-verificationcode/mvnw b/service-verificationcode/mvnw new file mode 100644 index 0000000..66df285 --- /dev/null +++ b/service-verificationcode/mvnw @@ -0,0 +1,308 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Apache Maven Wrapper startup batch script, version 3.2.0 +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "$(uname)" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME + else + JAVA_HOME="/Library/Java/Home"; export JAVA_HOME + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=$(java-config --jre-home) + fi +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$JAVA_HOME" ] && + JAVA_HOME=$(cygpath --unix "$JAVA_HOME") + [ -n "$CLASSPATH" ] && + CLASSPATH=$(cygpath --path --unix "$CLASSPATH") +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] && + JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="$(which javac)" + if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=$(which readlink) + if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then + if $darwin ; then + javaHome="$(dirname "\"$javaExecutable\"")" + javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac" + else + javaExecutable="$(readlink -f "\"$javaExecutable\"")" + fi + javaHome="$(dirname "\"$javaExecutable\"")" + javaHome=$(expr "$javaHome" : '\(.*\)/bin') + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=$(cd "$wdir/.." || exit 1; pwd) + fi + # end of workaround + done + printf '%s' "$(cd "$basedir" || exit 1; pwd)" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + # Remove \r in case we run on Windows within Git Bash + # and check out the repository with auto CRLF management + # enabled. Otherwise, we may read lines that are delimited with + # \r\n and produce $'-Xarg\r' rather than -Xarg due to word + # splitting rules. + tr -s '\r\n' ' ' < "$1" + fi +} + +log() { + if [ "$MVNW_VERBOSE" = true ]; then + printf '%s\n' "$1" + fi +} + +BASE_DIR=$(find_maven_basedir "$(dirname "$0")") +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR +log "$MAVEN_PROJECTBASEDIR" + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" +if [ -r "$wrapperJarPath" ]; then + log "Found $wrapperJarPath" +else + log "Couldn't find $wrapperJarPath, downloading it ..." + + if [ -n "$MVNW_REPOURL" ]; then + wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + else + wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + fi + while IFS="=" read -r key value; do + # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) + safeValue=$(echo "$value" | tr -d '\r') + case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;; + esac + done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" + log "Downloading from: $wrapperUrl" + + if $cygwin; then + wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") + fi + + if command -v wget > /dev/null; then + log "Found wget ... using wget" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + else + wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + log "Found curl ... using curl" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + else + curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + fi + else + log "Falling back to using Java to download" + javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" + javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaSource=$(cygpath --path --windows "$javaSource") + javaClass=$(cygpath --path --windows "$javaClass") + fi + if [ -e "$javaSource" ]; then + if [ ! -e "$javaClass" ]; then + log " - Compiling MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/javac" "$javaSource") + fi + if [ -e "$javaClass" ]; then + log " - Running MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +# If specified, validate the SHA-256 sum of the Maven wrapper jar file +wrapperSha256Sum="" +while IFS="=" read -r key value; do + case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;; + esac +done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" +if [ -n "$wrapperSha256Sum" ]; then + wrapperSha256Result=false + if command -v sha256sum > /dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then + wrapperSha256Result=true + fi + elif command -v shasum > /dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then + wrapperSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." + echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." + exit 1 + fi + if [ $wrapperSha256Result = false ]; then + echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 + echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 + echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 + exit 1 + fi +fi + +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$JAVA_HOME" ] && + JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") + [ -n "$CLASSPATH" ] && + CLASSPATH=$(cygpath --path --windows "$CLASSPATH") + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +# shellcheck disable=SC2086 # safe args +exec "$JAVACMD" \ + $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/service-verificationcode/mvnw.cmd b/service-verificationcode/mvnw.cmd new file mode 100644 index 0000000..95ba6f5 --- /dev/null +++ b/service-verificationcode/mvnw.cmd @@ -0,0 +1,205 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version 3.2.0 +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %WRAPPER_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file +SET WRAPPER_SHA_256_SUM="" +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B +) +IF NOT %WRAPPER_SHA_256_SUM%=="" ( + powershell -Command "&{"^ + "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ + "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ + " Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ + " Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ + " Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ + " exit 1;"^ + "}"^ + "}" + if ERRORLEVEL 1 goto error +) + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%"=="on" pause + +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% diff --git a/service-verificationcode/pom.xml b/service-verificationcode/pom.xml new file mode 100644 index 0000000..79f0d62 --- /dev/null +++ b/service-verificationcode/pom.xml @@ -0,0 +1,49 @@ + + + 4.0.0 + + + online-taxi-public + com.mashibing + 1.0-SNAPSHOT + + + com.mashibing + service-verificationcode + 0.0.1-SNAPSHOT + service-verificationcode + Demo project for Spring Boot + + 1.8 + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/service-verificationcode/src/main/java/com/mashibing/serviceverificationcode/ServiceVerificationcodeApplication.java b/service-verificationcode/src/main/java/com/mashibing/serviceverificationcode/ServiceVerificationcodeApplication.java new file mode 100644 index 0000000..3641d96 --- /dev/null +++ b/service-verificationcode/src/main/java/com/mashibing/serviceverificationcode/ServiceVerificationcodeApplication.java @@ -0,0 +1,15 @@ +package com.mashibing.serviceverificationcode; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +@SpringBootApplication +@EnableDiscoveryClient +public class ServiceVerificationcodeApplication { + + public static void main(String[] args) { + SpringApplication.run(ServiceVerificationcodeApplication.class, args); + } + +} diff --git a/service-verificationcode/src/main/java/com/mashibing/serviceverificationcode/controller/NumberCodeController.java b/service-verificationcode/src/main/java/com/mashibing/serviceverificationcode/controller/NumberCodeController.java new file mode 100644 index 0000000..40565b7 --- /dev/null +++ b/service-verificationcode/src/main/java/com/mashibing/serviceverificationcode/controller/NumberCodeController.java @@ -0,0 +1,32 @@ +package com.mashibing.serviceverificationcode.controller; + +import com.mashibing.internal.common.dto.ResponseResult; +import com.mashibing.internal.common.response.NumberCodeResponse; +import net.sf.json.JSONObject; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class NumberCodeController { + + @GetMapping("/numberCode/{size}") + public ResponseResult numberCode(@PathVariable("size") int size){ + System.out.println("size"+ size); + + // 获取随机值 + double mathRandom = (Math.random()*9 +1)*(Math.pow(10,size-1)); + System.out.println(mathRandom); + + int resultInt = (int)mathRandom; + System.out.println("generator src code" +resultInt); + + + // 定义返回值 + NumberCodeResponse response =new NumberCodeResponse(); + response.setNumberCode(resultInt); + + return ResponseResult.success(response); + } + +} diff --git a/service-verificationcode/src/main/java/com/mashibing/serviceverificationcode/controller/TestController.java b/service-verificationcode/src/main/java/com/mashibing/serviceverificationcode/controller/TestController.java new file mode 100644 index 0000000..7087c54 --- /dev/null +++ b/service-verificationcode/src/main/java/com/mashibing/serviceverificationcode/controller/TestController.java @@ -0,0 +1,13 @@ +package com.mashibing.serviceverificationcode.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class TestController { + + @GetMapping("/test") + public String test(){ + return "service-verificationcode"; + } +} diff --git a/service-verificationcode/src/main/resources/application.yml b/service-verificationcode/src/main/resources/application.yml new file mode 100644 index 0000000..4b549b2 --- /dev/null +++ b/service-verificationcode/src/main/resources/application.yml @@ -0,0 +1,11 @@ +server: + port: 8082 + +spring: + cloud: + nacos: + discovery: + access-key: 127.0.0.1:8848 + + application: + name: service-verificationcode \ No newline at end of file diff --git a/service-verificationcode/src/test/java/com/mashibing/serviceverificationcode/ServiceVerificationcodeApplicationTests.java b/service-verificationcode/src/test/java/com/mashibing/serviceverificationcode/ServiceVerificationcodeApplicationTests.java new file mode 100644 index 0000000..aa05bec --- /dev/null +++ b/service-verificationcode/src/test/java/com/mashibing/serviceverificationcode/ServiceVerificationcodeApplicationTests.java @@ -0,0 +1,13 @@ +package com.mashibing.serviceverificationcode; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class ServiceVerificationcodeApplicationTests { + + @Test + void contextLoads() { + } + +}