package cn.estsh.i3plus.pojo.softswitch.bean;

import cn.estsh.i3plus.pojo.base.annotation.AnnoOutputColumn;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;

/**
 * @Description :
 * @Reference :
 * @Author : yunhao
 * @CreateDate : 2019-09-18 16:53
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "BS_SUIT_CASE_REST")
@Api(value = "适配器出入参", description = "适配器出入参")
public class BsSuitCaseREST extends BaseBean {

    private static final long serialVersionUID = 3871469059124604719L;
    @Column(name = "SUIT_CASE_ID")
    @ApiParam(value = "套件id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long suitCaseId;

    //CommonEnumUtil.HTTP_METHOD_TYPE
    @Column(name = "REQUEST_METHOD_ID")
    @ApiParam(value = "请求方式id")
    @AnnoOutputColumn(refClass = CommonEnumUtil.HTTP_METHOD_TYPE.class)
    private Integer requestMethodId;

    public String getRequestMethodIdTxt(){
        return requestMethodId == null ? "无" : CommonEnumUtil.HTTP_METHOD_TYPE.valueOfDescription(requestMethodId);
    }

    //CommonEnumUtil.TRUE_OR_FALSE
    @Column(name = "IS_REQUEST_BODY")
    @ApiParam(value = "是否使用requestBody")
    @AnnoOutputColumn(refClass = CommonEnumUtil.TRUE_OR_FALSE.class)
    private Integer isRequestBody;

    public int getIsRequestBodyVal() {
        return isRequestBody == null ? CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue() : isRequestBody;
    }

    @Transient
    @ApiParam(value = "请求头转换")
    private List<BsSuitCaseParam> requestHeaderList;
}
