parent
38b03fa2ac
commit
02b7b10477
@ -0,0 +1,24 @@
|
||||
<?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>com.mashibing</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.mashibing</groupId>
|
||||
<artifactId>internal-common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<name>internal-common</name>
|
||||
<description>internal-common</description>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
||||
|
||||
</project>
|
@ -0,0 +1,30 @@
|
||||
package com.mashibing.internalcommon.constant;
|
||||
|
||||
public enum CommonStatusEnum {
|
||||
|
||||
/**
|
||||
* 1:成功
|
||||
*/
|
||||
SUCCESS(1,"success"),
|
||||
/**
|
||||
* 0:失败
|
||||
*/
|
||||
FAIL(0,"fail");
|
||||
|
||||
private Integer code;
|
||||
|
||||
private String value;
|
||||
|
||||
CommonStatusEnum(Integer code, String value) {
|
||||
this.code = code;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.mashibing.internalcommon.dto;
|
||||
|
||||
|
||||
import com.mashibing.internalcommon.constant.CommonStatusEnum;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ResponseResult<T> {
|
||||
|
||||
private Integer 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.getValue()).setData(data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 失败 自定义响应 错误码和错误信息
|
||||
* @param code
|
||||
* @param message
|
||||
* @return
|
||||
*/
|
||||
public static ResponseResult fail(Integer code,String message){
|
||||
return new ResponseResult().setCode(code).setMessage(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败 统一响应 只有错误结果体
|
||||
* @param data
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> ResponseResult fail(T data){
|
||||
return new ResponseResult().setData(data);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.mashibing.internalcommon.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class NumberCodeResponse {
|
||||
|
||||
private String numberCode;
|
||||
|
||||
}
|
Loading…
Reference in new issue