package cn.reghao.tnb.content.app.vod.model.dto;

import cn.reghao.tnb.content.api.constant.PostScope;
import cn.reghao.tnb.content.api.constant.VideoStatus;
import lombok.Getter;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.util.List;

/**
 * @author reghao
 * @date 2023-11-19 20:44:31
 */
@Getter
public class SearchCriteria {
    @NotEmpty
    @Size(min = 1, max = 10, message = "status 10 个元素")
    private final List<Integer> status;
    @NotEmpty
    @Size(min = 1, max = 10, message = "scope 10 个元素")
    private final List<Integer> scope;
    @NotBlank
    @Size(min = 1, max = 64, message = "视频名字不能超过 64 个字符")
    private final String title;
    @NotNull
    private final Integer nextId;

    private SearchCriteria(Builder builder) {
        this.status = builder.status;
        this.scope = builder.scope;
        this.title = builder.title;
        this.nextId = builder.nextId;
    }

    public static final class Builder {
        private List<Integer> status;
        private List<Integer> scope;
        private String title;
        private Integer nextId;

        public Builder() {
            this.status = List.of(VideoStatus.publish.getCode(), VideoStatus.noVideoFile.getCode());
            this.scope = List.of(PostScope.PUBLIC.getCode());
        }

        public Builder status(List<Integer> status) {
            this.status = status;
            return this;
        }

        public Builder scope(List<Integer> scope) {
            this.scope = scope;
            return this;
        }

        public Builder title(String title) {
            this.title = title;
            return this;
        }

        public Builder nextId(int nextId) {
            this.nextId = nextId;
            return this;
        }

        public SearchCriteria build() {
            return new SearchCriteria(this);
        }
    }
}
