package org.jeecg.modules.system.vo;

import lombok.Data;

public class CallResult<T> {

    public static final String CODE_SUCCEED = "000000";        // 成功
    public static final String CODE_EXCEPTION = "000001";        // 异常错误

    public static final String CODE_SYS_SERIAL_PATTERN_NOT_DEFINE = "100001";   // 编号模式未定义
    public static final String CODE_SYS_SERIAL_PATTERN_FIELD_NOT_ENOUGH = "100002";   // 编号模式需要的数据库字段不够
    public static final String CODE_SYS_SERIAL_PATTERN_DEFINE_NULL = "100003";   // 编号模式定义为空
    public static final String CODE_SYS_SERIAL_PATTERN_DEFINE_INVALID = "100004"; // 编号模式定义无效

    public CallResult(){
        this.code = CODE_SUCCEED;
        this.message = "";
    }

    public boolean isSucceed(){
        return this.code.equals(CODE_SUCCEED);
    }

    public String GetFullMessage(){
        if (!message.equals(""))
            return message;
        String errorMessage = "";
        switch (code) {
            case CODE_SYS_SERIAL_PATTERN_NOT_DEFINE:
                errorMessage = "编号模式未定义，请先定义编号模式";
                break;
            case CODE_SYS_SERIAL_PATTERN_FIELD_NOT_ENOUGH:
                errorMessage = "编号模式需要的数据库字段不够";
                break;
            case CODE_SYS_SERIAL_PATTERN_DEFINE_NULL:
                errorMessage = "编号模式内容定义为空，请先定义编号模式内容";
                break;
            default:
                break;
        }
        return errorMessage;
    }

    public void setBaseInfo(String code, String message){
        this.code = code;
        this.message = message;
    }
    // 代码
    private String code;
    public String getCode(){
        return code;
    }
    public void  setCode(String code){
        this.code = code;
    }
    // 提示信息
    private String message;
    public String getMessage(){
        return message;
    }
    public void  setMessage(String message){
        this.message = message;
    }
    // 返回内容
    private T content;
    public T getContent(){
        return content;
    }
    public void  setContent(T content){
        this.content = content;
    }
}
