src/main/java/com/ken/wms/common/util/Response.java

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

package com.ken.wms.common.util;

import org.apache.commons.collections.map.HashedMap;

import java.util.Map;

/**
 * controller 返回的信息载体 response
 * @author ken
 *
 * Created by Ken on 2017/1/18.
 */
public class Response {

    public static final String RESPONSE_RESULT_SUCCESS = "success";
    public static final String RESPONSE_RESULT_ERROR = "error";

    // response 中可能使用的值
    private static final String RESPONSE_RESULT = "result";
    private static final String RESPONSE_MSG = "msg";
    private static final String RESPONSE_DATA = "data";
    private static final String RESPONSE_TOTAL = "total";

    // 存放响应中的信息
    private Map<String,Object> responseContent;

    // Constructor
    Response() {
        this.responseContent = new HashedMap(10);
    }

    /**
     * 设置 response 的状态
     * @param result response 的状态,值为 success 或 error
     */
    public void setResponseResult(String result){
        this.responseContent.put(Response.RESPONSE_RESULT,result);
    }

    /**
     * 设置 response 的附加信息
     * @param msg response  的附加信息
     */
    public void setResponseMsg(String msg){
        this.responseContent.put(Response.RESPONSE_MSG,msg);
    }

    /**
     * 设置 response 中携带的数据
     * @param data response 中携带的数据
     */
    public void setResponseData(Object data){
        this.responseContent.put(Response.RESPONSE_DATA,data);
    }

    /**
     * 设置 response 中携带数据的数量,与 RESPONSE_DATA 配合使用
     * @param total 携带数据的数量
     */
    public void setResponseTotal(long total){
后面还有 20 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。