generated from msb_55675/Demo
Compare commits
4 Commits
5f90be193b
...
fac441d3e2
Author | SHA1 | Date |
---|---|---|
|
fac441d3e2 | 3 years ago |
|
539eafcb5e | 3 years ago |
|
49f2ff8725 | 3 years ago |
|
026a027ed1 | 3 years ago |
@ -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,8 @@
|
||||
package com.mashibing.common.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class NumberCodeResponse {
|
||||
private int numberCode;
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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
|
@ -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…
Reference in new issue