package com.fzm.mall.customer.service.repo;

import com.fzm.mall.customer.service.config.i18n.MallMessage;
import com.fzm.mall.customer.service.enums.MallResponseEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author lyz
 * @mail lyz@disanbo.com
 * @create 2021/1/25 10:24
 * @description
 */
@Data
@ApiModel("返回对象")
public class ResponseVO<T> {

    @ApiModelProperty("应答码，00000:成功，其它：失败")
    private String code;
    @ApiModelProperty("应答消息")
    private String msg;
    @ApiModelProperty("应答数据")
    private T data;

    public ResponseVO(MallResponseEnum responseEnum) {
        this.code = responseEnum.code();
        this.msg = responseEnum.msgKey();
    }

    public ResponseVO(MallResponseEnum responseEnum, T data) {
        this.code = responseEnum.code();
        this.msg = responseEnum.msgKey();
        this.data = data;
    }

    public ResponseVO(String code) {
        this.code = code;
        this.msg = MallMessage.getMsg(code);
    }

    public ResponseVO(String code, T data) {
        this.code = code;
        this.msg = MallMessage.getMsg(code);
        this.data = data;
    }

}
