Feat:添加默认的查询实体

This commit is contained in:
wangyu 2020-11-21 15:16:25 +08:00
parent b7d6628ac4
commit 66a1f23216
3 changed files with 43 additions and 3 deletions

View File

@ -1,6 +1,6 @@
package com.flyfish.framework.bean;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.flyfish.framework.constant.Frameworks;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
@ -144,7 +144,11 @@ public class Result<T> {
}
public T getData() {
return data;
return Frameworks.config.isResultStyle() ? null : data;
}
public T getResult() {
return Frameworks.config.isResultStyle() ? data : null;
}
public void setData(T data) {
@ -160,7 +164,11 @@ public class Result<T> {
}
public String getMsg() {
return msg;
return Frameworks.config.isResultStyle() ? null : msg;
}
public String getMessage() {
return Frameworks.config.isResultStyle() ? msg : null;
}
public void setMsg(String msg) {

View File

@ -0,0 +1,15 @@
package com.flyfish.framework.config;
import lombok.Getter;
import lombok.Setter;
/**
* 框架配置
* @author wangyu
*/
@Setter
@Getter
public class FrameworkConfiguration {
private boolean resultStyle = false;
}

View File

@ -0,0 +1,17 @@
package com.flyfish.framework.constant;
import com.flyfish.framework.config.FrameworkConfiguration;
/**
* 框架静态配置
*
* @author wangyu
*/
public interface Frameworks {
FrameworkConfiguration config = new FrameworkConfiguration();
static void resultStyle() {
config.setResultStyle(true);
}
}