Skip to content

Commit

Permalink
做了一些更改
Browse files Browse the repository at this point in the history
  • Loading branch information
fengwenyi committed Sep 23, 2022
1 parent b85bd66 commit f1b06b6
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 19 deletions.
3 changes: 3 additions & 0 deletions LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
:star: New Features

- 新增 Boolean 结果类型响应类:`BooleanResponse`
- `com.fengwenyi.api.result.StringUtils` 改为只为本包使用
- `Builder` -> `IBuilder`
- `Result` -> `IResult`

:memo: Document

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @author <a href="https://www.fengwenyi.com">Erwin Feng</a>
* @since 2.5.2
*/
public interface Builder<T> {
public interface IBuilder<T> {

/**
* 构建一个对象
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @author Erwin Feng
* @since 2.7.0
*/
public interface Result {
public interface IResult {

/**
* 结果码
Expand All @@ -25,13 +25,13 @@ public interface Result {
/**
* 默认
*/
class Default implements Result {
class Default implements IResult {

/* -----------------成功---------------------------- */
public static final Result SUCCESS = new Default("SUCCESS", "Success");
public static final IResult SUCCESS = new Default("SUCCESS", "Success");

/* ------------------错误--------------------------- */
public static final Result ERROR = new Default("ERROR", "错误");
public static final IResult ERROR = new Default("ERROR", "错误");

/** 结果码 */
private final String code;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/fengwenyi/api/result/PageTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public PageTemplate<T> setTotalPage(long totalPage) {
* PageResponse构造者,可通过该类构造出PageResponseVo
* @param <T> 范型
*/
public static class Builder<T> implements com.fengwenyi.api.result.Builder<PageTemplate<T>> {
public static class Builder<T> implements IBuilder<PageTemplate<T>> {

// PageResponseVo 对象
private final PageTemplate<T> pageTemplate;
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/fengwenyi/api/result/ResultTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ public class ResultTemplate<T> implements Serializable {
/**
* 默认操作成功
*/
private static final Result SUCCESS = Result.Default.SUCCESS;
private static final IResult SUCCESS = IResult.Default.SUCCESS;

/**
* 默认操作失败
*/
private static final Result ERROR = Result.Default.ERROR;
private static final IResult ERROR = IResult.Default.ERROR;

/**
* 构造方法:无参数
Expand Down Expand Up @@ -176,11 +176,11 @@ public static <T> ResultTemplate<T> fail(String msg) {
/**
* 操作失败
*
* @param returnCode {@link Result}
* @param returnCode {@link IResult}
* @param <T> {@link Void}
* @return 响应封装类 {@link ResultTemplate}
*/
public static <T> ResultTemplate<T> fail(Result returnCode) {
public static <T> ResultTemplate<T> fail(IResult returnCode) {
return new ResultTemplate<T>()
.setCode(returnCode.getCode())
.setMsg(returnCode.getMsg())
Expand All @@ -190,13 +190,13 @@ public static <T> ResultTemplate<T> fail(Result returnCode) {
/**
* 操作失败
*
* @param returnCode {@link Result}
* @param returnCode {@link IResult}
* @param msg 描述信息
* @param <T> {@link Void}
* @return 响应封装类 {@link ResultTemplate}
*/
@SuppressWarnings("all")
public static <T> ResultTemplate<T> fail(Result returnCode, String msg) {
public static <T> ResultTemplate<T> fail(IResult returnCode, String msg) {
msg = StringUtils.isBlank(msg) ? returnCode.getMsg() : msg;
return new ResultTemplate<T>()
.setCode(returnCode.getCode())
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/fengwenyi/api/result/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
* @author <a href="https://www.fengwenyi.com">Erwin Feng</a>
* @since 2.5.2
*/
public class StringUtils {
class StringUtils {

/**
* 字符串判空
* @param str 待判断的字符串
* @return 判断结果
*/
public static boolean isBlank(String str) {
static boolean isBlank(String str) {
if (null == str) {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/fengwenyi/api/result/MyResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @author <a href="https://fengwenyi.com">Erwin Feng</a>
* @since 2022-07-14
*/
public class MyResult extends Result.Default {
public class MyResult extends IResult.Default {

/**
* 构造方法
Expand All @@ -16,6 +16,6 @@ public class MyResult extends Result.Default {
super(code, msg);
}

public static final Result BIZ_ERROR = new MyResult("BIZ_ERROR", "业务异常");
public static final IResult BIZ_ERROR = new MyResult("BIZ_ERROR", "业务异常");

}
2 changes: 1 addition & 1 deletion src/test/java/com/fengwenyi/api/result/ResultEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @author <a href="https://www.fengwenyi.com">Erwin Feng</a>
* @since 2021-07-02
*/
public enum ResultEnum implements Result {
public enum ResultEnum implements IResult {

CUSTOM_ERROR("CUSTOM_ERROR", "自定义错误")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.fengwenyi.api.result.util;
package com.fengwenyi.api.result;

import com.fengwenyi.api.result.StringUtils;
import org.junit.Test;

/**
Expand Down

0 comments on commit f1b06b6

Please sign in to comment.