package com.qmth.sop.business.bean.params;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qmth.sop.business.entity.TBSopInfo;
import com.qmth.sop.common.contant.SystemConstant;
import com.qmth.sop.common.enums.FormWidgetMetadataOperation;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;

/**
 * @Description: sop列表param
 * @Param:
 * @return:
 * @Author: wngliang
 * @Date: 2023/9/4
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SopInfoListParam extends TBSopInfo implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "流程类型str")
    private String typeStr;

    @ApiModelProperty(value = "版本号")
    private Integer version;

    @ApiModelProperty(value = "元数据显示字段数组")
    private List<FormWidgetMetadataParam> formWidgetMetadataViewList;

    @ApiModelProperty(value = "元数据排序字段数组")
    private List<FormWidgetMetadataParam> formWidgetMetadataOrderList;

    @ApiModelProperty(value = "元数据筛选字段数组")
    private List<FormWidgetMetadataParam> formWidgetMetadataConditionList;

    @ApiModelProperty(value = "元数据条件操作符")
    FormWidgetMetadataOperation formWidgetMetadataOperation;

    @ApiModelProperty(value = "页码")
    @NotNull(message = "页码不能为空")
    @Min(SystemConstant.PAGE_NUMBER_MIN)
    private Integer pageNumber;

    @ApiModelProperty(value = "页数")
    @NotNull(message = "页数不能为空")
    @Max(SystemConstant.PAGE_SIZE_MAX)
    private Integer pageSize;

    @ApiModelProperty(value = "用户id数组")
    @JsonSerialize(using = ToStringSerializer.class)
    private List<Long> userIdList;

    public FormWidgetMetadataOperation getFormWidgetMetadataOperation() {
        return formWidgetMetadataOperation;
    }

    public void setFormWidgetMetadataOperation(FormWidgetMetadataOperation formWidgetMetadataOperation) {
        this.formWidgetMetadataOperation = formWidgetMetadataOperation;
    }

    public List<FormWidgetMetadataParam> getFormWidgetMetadataOrderList() {
        return formWidgetMetadataOrderList;
    }

    public void setFormWidgetMetadataOrderList(List<FormWidgetMetadataParam> formWidgetMetadataOrderList) {
        this.formWidgetMetadataOrderList = formWidgetMetadataOrderList;
    }

    public List<Long> getUserIdList() {
        return userIdList;
    }

    public void setUserIdList(List<Long> userIdList) {
        this.userIdList = userIdList;
    }

    public String getTypeStr() {
        if (Objects.nonNull(this.getType())) {
            return this.getType().getTitle();
        } else {
            return typeStr;
        }
    }

    public void setTypeStr(String typeStr) {
        this.typeStr = typeStr;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public List<FormWidgetMetadataParam> getFormWidgetMetadataViewList() {
        return formWidgetMetadataViewList;
    }

    public void setFormWidgetMetadataViewList(List<FormWidgetMetadataParam> formWidgetMetadataViewList) {
        this.formWidgetMetadataViewList = formWidgetMetadataViewList;
    }

    public List<FormWidgetMetadataParam> getFormWidgetMetadataConditionList() {
        return formWidgetMetadataConditionList;
    }

    public void setFormWidgetMetadataConditionList(List<FormWidgetMetadataParam> formWidgetMetadataConditionList) {
        this.formWidgetMetadataConditionList = formWidgetMetadataConditionList;
    }

    public Integer getPageNumber() {
        return pageNumber;
    }

    public void setPageNumber(Integer pageNumber) {
        this.pageNumber = pageNumber;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }
}
