add new common module
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
<groupId>io.wdd</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
<!--<scope>compile</scope>-->
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
package io.wdd.server;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class R<T> {
|
||||
|
||||
|
||||
int code;
|
||||
|
||||
String msg;
|
||||
|
||||
T data;
|
||||
|
||||
private R(int code, String msg, T data) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public R() {
|
||||
|
||||
}
|
||||
|
||||
public static <T> R<T> ok(T data) {
|
||||
return resetResult(data, ResultStat.SUCCESS);
|
||||
}
|
||||
|
||||
public static <T> R<T> okNoData() {
|
||||
return new R();
|
||||
}
|
||||
|
||||
public static <T> R<T> failed(T data) {
|
||||
return resetResult(data, ResultStat.FAILED);
|
||||
}
|
||||
|
||||
// access from inner
|
||||
private static <T> R<T> resetResult(T data, ResultStat resultStat) {
|
||||
return new R(resultStat.getCode(), resultStat.getDescription(), data);
|
||||
}
|
||||
|
||||
// access to public
|
||||
public static <T> R<T> resetResult(int code, String msg, T data) {
|
||||
return new R<>(code
|
||||
, msg, data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package io.wdd.server;
|
||||
|
||||
public enum ResultStat {
|
||||
|
||||
SUCCESS(1000, "success"),
|
||||
|
||||
FAILED(5001, "failed"),
|
||||
|
||||
VALIDATE_FAILED(1002, "参数校验失败"),
|
||||
|
||||
PARAM_ERROR(1003, "请求参数错误!"),
|
||||
|
||||
|
||||
|
||||
BAD(5001, "all error !");
|
||||
|
||||
int code;
|
||||
|
||||
String description;
|
||||
|
||||
ResultStat(int code, String description){
|
||||
this.code = code;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDescription(){
|
||||
return description;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.wdd.server.controller;
|
||||
|
||||
|
||||
import io.wdd.server.R;
|
||||
import io.wdd.common.R;
|
||||
import io.wdd.server.beans.vo.AppInfoVO;
|
||||
import io.wdd.server.coreService.CoreAppService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.wdd.server.controller;
|
||||
|
||||
|
||||
import io.wdd.server.R;
|
||||
import io.wdd.common.R;
|
||||
import io.wdd.server.beans.po.ServerInfoPO;
|
||||
import io.wdd.server.beans.vo.ServerInfoVO;
|
||||
import io.wdd.server.coreService.CoreServerService;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package io.wdd.server.handler;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import io.wdd.server.R;
|
||||
import io.wdd.server.ResultStat;
|
||||
import io.wdd.common.R;
|
||||
import io.wdd.common.ResultStat;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.wdd.server.handler;
|
||||
|
||||
import io.wdd.server.ResultStat;
|
||||
import io.wdd.common.ResultStat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
Reference in New Issue
Block a user