package com.purui.prims.headless.api.pojo.request;


import com.google.common.collect.Lists;
import com.purui.prims.common.pojo.PageBaseReq;
import com.purui.prims.headless.api.pojo.enums.AppStatus;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.stream.Collectors;

@Data
@ApiModel(value = "应用查询Req")
public class AppQueryReq extends PageBaseReq {

    @ApiModelProperty(value = "应用名称")
    private String name;

    @ApiModelProperty(value = "状态")
    private List<AppStatus> appStatus;

    @ApiModelProperty(value = "创建人")
    private String createdBy;

    public List<Integer> getStatus() {
        if (CollectionUtils.isEmpty(appStatus)) {
            return Lists.newArrayList();
        }
        return appStatus.stream().map(AppStatus::getCode).collect(Collectors.toList());
    }

}
