xiangpei
2024-06-03 a6c64679fa5f9b927fd01f85a627d63828912a3f
响应体修改
2个文件已修改
23 ■■■■■ 已修改文件
src/main/java/com/ycl/jxkg/base/Result.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/config/spring/security/RestUtil.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/base/Result.java
@@ -11,7 +11,10 @@
public class Result<T> extends HashMap<String, Object> {
    private int code;
    private String message;
    private T response;
    private T data;
    public Result() {
    }
    /**
     * Instantiates a new Rest response.
@@ -31,10 +34,12 @@
     * @param message  the message
     * @param response the response
     */
    public Result(int code, String message, T response) {
        this.code = code;
        this.message = message;
        this.response = response;
    public static Result response(int code, String message, Object response) {
        Result restResponse = new Result();
        restResponse.put("code", code);
        restResponse.put("message", message);
        restResponse.put("data", response);
        return restResponse;
    }
    /**
@@ -67,7 +72,7 @@
     */
    public static <F> Result<F> ok(F response) {
        SystemCode systemCode = SystemCode.OK;
        return new Result<>(systemCode.getCode(), systemCode.getMessage(), response);
        return Result.response(systemCode.getCode(), systemCode.getMessage(), response);
    }
    /**
@@ -112,7 +117,7 @@
     * @return the response
     */
    public T getResponse() {
        return response;
        return data;
    }
    /**
@@ -121,7 +126,7 @@
     * @param response the response
     */
    public void setResponse(T response) {
        this.response = response;
        this.data = response;
    }
    @Override
src/main/java/com/ycl/jxkg/config/spring/security/RestUtil.java
@@ -52,7 +52,7 @@
     */
    public static void response(HttpServletResponse response, int systemCode, String msg, Object content) {
        try {
            Result res = new Result<>(systemCode, msg, content);
            Result res = Result.response(systemCode, msg, content);
            String resStr = JsonUtil.toJsonStr(res);
            response.setContentType("application/json;charset=utf-8");
            response.getWriter().write(resStr);