package org.springblade.file.pojo.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 业务附件信息表 数据传输对象实体类
 *
 * @author BladeX
 * @since 2024-09-04
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
@Schema(description = "业务附件查询参数")
public class BusinessAttachmentQueryDTO implements Serializable {
	@Serial
	private static final long serialVersionUID = 1L;
	/**
	 *  业务id列表
	 */
	@NotNull(message = "业务id列表不能为空")
	@Schema(description = "业务id列表")
	private List<@NotNull(message = "业务id不能为空") Long> bizIds;
	/**
	 * 业务code
	 */
	@Schema(description = "业务code")
	private String bizCode;
	/**
	 *  业务code列表
	 */
	@Schema(description = "业务code列表")
	private List<String> bizCodes;

	public BusinessAttachmentQueryDTO(Long bizId) {
		this.bizIds = List.of(bizId);
	}

	public BusinessAttachmentQueryDTO(List<Long> bizIds) {
		this.bizIds = bizIds;
	}

	/**
	 *  兼容历史参数
	 * @param bizId
	 */
	public void setBizId(Long bizId) {
		if (this.bizIds == null) {
			this.bizIds = new ArrayList<>();
		}
		this.bizIds.add(bizId);
	}
}
