package cn.reghao.tnb.content.app.exam.model.query;

import cn.reghao.jutil.jdk.db.Page;
import cn.reghao.tnb.common.auth.UserContext;
import lombok.Getter;
import lombok.Setter;

/**
 * @author reghao
 * @date 2024-08-27 17:24:31
 */
@Setter
@Getter
public class PaperQuery {
    private Integer pageNumber;
    private Integer pageSize;
    private Long loginUser;
    private Integer subjectId;
    private Integer type;
    private Integer level;

    public PaperQuery() {
        this.pageNumber = 1;
        this.pageSize = 10;
        this.loginUser = UserContext.getUser();
    }

    private PaperQuery(Builder builder) {
        this.subjectId = builder.subjectId;
        this.pageNumber = builder.pageNumber;
        this.pageSize = builder.pageSize;
        this.type = builder.type;
        this.level = builder.level;
    }

    public Page getPage() {
        return new Page(pageNumber, pageSize);
    }

    public static final class Builder {
        private Integer pageNumber;
        private Integer pageSize;
        private Integer subjectId;
        private Integer type;
        private Integer level;

        public Builder() {
            this.pageNumber = 1;
            this.pageSize = 10;
        }

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

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

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

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

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

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