Compare commits

...

4 Commits

Author SHA1 Message Date
liuyuanqiang fac441d3e2 internal-common
3 years ago
liuyuanqiang 539eafcb5e internal-common
3 years ago
liuyuanqiang 49f2ff8725 internal-common
3 years ago
liuyuanqiang 026a027ed1 add NumberCodeController
3 years ago

@ -2,11 +2,13 @@
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="api-passenger" />
<module name="internal-common" />
<module name="service-verificationcode" />
</profile>
</annotationProcessing>
@ -14,6 +16,7 @@
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="api-passenger" options="-parameters" />
<module name="internal-common" options="-parameters" />
<module name="service-verificationcode" options="-parameters" />
</option>
</component>

@ -2,6 +2,7 @@
<project version="4">
<component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
<file url="file://$PROJECT_DIR$/api-passenger/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/internal-common/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/service-verificationcode/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />

@ -0,0 +1,16 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>online-taxi-public</artifactId>
<groupId>org.mashibing</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>internal-common</artifactId>
</project>

@ -0,0 +1,25 @@
package com.mashibing.common.constant;
import lombok.Data;
import lombok.Getter;
public enum CommonStatusEnum {
/**
*
*/
SUCCESS(1,"success"),
/**
*
*/
FAIL(0,"fail");
@Getter
private int code;
@Getter
private String msg;
CommonStatusEnum(int code,String msg){
this.code = code;
this.msg = msg;
}
}

@ -0,0 +1,57 @@
package com.mashibing.common.dto;
import com.mashibing.common.constant.CommonStatusEnum;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class ResponseResult<T> {
private int code;
private String message;
private T data;
/**
*
* @param data
* @param <T>
* @return
*/
public static <T> ResponseResult success(T data){
return new ResponseResult().setCode(CommonStatusEnum.SUCCESS.getCode())
.setMessage(CommonStatusEnum.SUCCESS.getMsg()).setData(data);
}
/**
*:
* @param data
* @return
*/
public static ResponseResult fail(String data){
return new ResponseResult().setData(data);
}
/**
* :
* @param code
* @param msg
* @return
*/
public static ResponseResult fail(int code, String msg){
return new ResponseResult().setCode(code).setMessage(msg);
}
/**
*:
* @param code
* @param msg
* @param data
* @return
*/
public static ResponseResult fail(int code, String msg, String data){
return new ResponseResult().setCode(code).setMessage(msg).setData(data);
}
}

@ -0,0 +1,8 @@
package com.mashibing.common.response;
import lombok.Data;
@Data
public class NumberCodeResponse {
private int numberCode;
}

@ -0,0 +1,3 @@
artifactId=internal-common
groupId=org.mashibing
version=1.0-SNAPSHOT

@ -0,0 +1,3 @@
com\mashibing\common\dto\ResponseResult.class
com\mashibing\common\constant\CommonStatusEnum.class
com\mashibing\common\response\NumberCodeResponse.class

@ -0,0 +1,3 @@
D:\Works\workspaces\online-taxi-public\internal-common\src\main\java\com\mashibing\common\constant\CommonStatusEnum.java
D:\Works\workspaces\online-taxi-public\internal-common\src\main\java\com\mashibing\common\dto\ResponseResult.java
D:\Works\workspaces\online-taxi-public\internal-common\src\main\java\com\mashibing\common\response\NumberCodeResponse.java

@ -17,6 +17,7 @@
<modules>
<module>api-passenger</module>
<module>service-verificationcode</module>
<module>internal-common</module>
</modules>
<packaging>pom</packaging>
@ -33,7 +34,11 @@
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
</dependency>
<!-- nacos 依赖 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>

@ -26,6 +26,12 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mashibing</groupId>
<artifactId>internal-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>

@ -0,0 +1,36 @@
package com.mashibing.service.controller;
import com.mashibing.common.dto.ResponseResult;
import com.mashibing.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;
import static java.lang.Math.pow;
@RestController
public class NumberCodeController {
@GetMapping("/numberCode/{size}")
public ResponseResult getNumberCode(@PathVariable("size") int size){
System.out.println("size:" + size);
//获取随机数
double mathRandom = (Math.random() * 9 + 1) * pow(10, size-1);
int resultInt = (int) mathRandom;
System.out.println(resultInt);
NumberCodeResponse response = new NumberCodeResponse();
response.setNumberCode(resultInt);
/*
JSONObject result = new JSONObject();
result.put("code",1);
result.put("message","success");
JSONObject data = new JSONObject();
data.put("numberCode",resultInt);
result.put("data",data);
*/
return ResponseResult.success(response);
}
}
Loading…
Cancel
Save