package cn.axzo.msg.center.service.pending.request;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotNull;
import java.util.Collections;
import java.util.List;

import static java.util.stream.Collectors.toList;

/**
 * @author haiyangjin
 * @date 2023/11/16
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class PendingMessageByBizCodeRequest {
    /**
     * bizCodes
     */
    @NotNull(message = "bizParam不能为空")
    private List<String> bizCodes;

    /**
     * 操作人ID
     * <p>operatorPersonId和operatorIdentityId使用其中一个进行查询, operatorPersonId的优先级更高
     */
    private Long operatorIdentityId;

    /**
     * 操作自然人id
     * <p>operatorPersonId和operatorIdentityId使用其中一个进行查询, operatorPersonId的优先级更高
     */
    private Long operatorPersonId;

    public List<String> determineBizCodes() {
        if (bizCodes == null)
            return Collections.emptyList();
        return bizCodes.stream()
                .filter(StringUtils::isNotBlank)
                .distinct()
                .collect(toList());
    }
}
