All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.afu.utils.common.dto.BaseRespDto Maven / Gradle / Ivy

There is a newer version: 0.0.55-RELEASE
Show newest version
package io.afu.utils.common.dto;


import io.afu.utils.common.constant.CodeConstant;
import io.afu.utils.common.constant.MsgConstant;

import java.util.List;

/**
 * @author: RffanLAB.方露宇
 */
public class BaseRespDto {
    private Boolean status;
    private Integer code;
    private String msg;
    private T data;
    private List datas;

    public Boolean getStatus() {
        return status;
    }

    public void setStatus(Boolean status) {
        this.status = status;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        this.status = true;
        this.code = CodeConstant.OPERATION_SUCCESS;
        this.msg = MsgConstant.OPERATION_SUCCESS;
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public List getDatas() {
        return datas;
    }

    public void setDatas(List datas) {
        this.status = true;
        this.code = CodeConstant.OPERATION_SUCCESS;
        this.msg = MsgConstant.OPERATION_SUCCESS;
        this.datas = datas;
    }


    /**
     * 自定义添加方法
     */
    public static BaseRespDto fail(String msg,Integer code){
        BaseRespDto baseRespDto = new BaseRespDto<>();
        baseRespDto.setStatus(false);
        baseRespDto.setCode(code);
        baseRespDto.setMsg(msg);
        return baseRespDto;
    }

    public static BaseRespDto fail(String msg) {
        BaseRespDto baseRespDto = new BaseRespDto<>();
        baseRespDto.setStatus(false);
        baseRespDto.setCode(-1);
        baseRespDto.setMsg(msg);
        return baseRespDto;
    }

    public static BaseRespDto success(){
        BaseRespDto baseRespDto = new BaseRespDto<>();
        baseRespDto.setStatus(true);
        baseRespDto.setCode(CodeConstant.OPERATION_SUCCESS);
        baseRespDto.setMsg(MsgConstant.OPERATION_SUCCESS);
        return baseRespDto;
    }

    public static BaseRespDto success(String data){
        BaseRespDto baseRespDto = new BaseRespDto<>();
        baseRespDto.setStatus(true);
        baseRespDto.setCode(CodeConstant.OPERATION_SUCCESS);
        baseRespDto.setMsg(MsgConstant.OPERATION_SUCCESS);
        baseRespDto.setData(data);
        return baseRespDto;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy