package com.microservices.zone.resource.domain.vo;

import com.microservices.common.security.utils.SecurityUtils;
import com.microservices.zone.resource.domain.ZoneResource;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;

/**
 * @author otto
 */
@Data
@ApiModel("资源搜索对象")
public class ZoneResourceSearchVo extends ZoneResourceOpenSearchVo {

    @ApiModelProperty(value = "所属专区",required = true)
    @NotNull
    private Long zoneId;

    @ApiModelProperty(value = "审核状态（0：待审核，1：审核通过 2：审核不通过 3：已下架 4：草稿 all：所有）")
    private String auditStatus;

    @ApiModelProperty(value = "资源分类：SKILL/MODEL/DATASET，NULL或者不传代表所有资源")
    private String resourceCategory;

    @ApiModelProperty(value = "是否只查询我的")
    private Boolean isMine;

    public ZoneResource toZoneResource() {
        ZoneResource zoneResource = super.toZoneResource();
        zoneResource.setZoneId(zoneId);
        if (Boolean.TRUE.equals(isMine)) {
            zoneResource.setCreateBy(SecurityUtils.getUsername());
        }
        return zoneResource;
    }
}
