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

import cn.reghao.jutil.jdk.web.db.BaseObject;
import cn.reghao.tnb.common.auth.UserContext;
import cn.reghao.tnb.content.api.constant.PostScope;
import cn.reghao.tnb.content.api.constant.PostType;
import cn.reghao.tnb.content.app.vod.model.dto.AlbumCreateDto;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

/**
 * @author reghao
 * @date 2024-10-31 13:55:19
 */
@NoArgsConstructor
@Setter
@Getter
public class PostAlbum extends BaseObject<Integer> {
    @NotNull
    private Long albumId;
    @NotBlank
    @Size(min = 1, max = 20, message = "合集名字不能超过 20 个字符")
    private String albumName;
    @NotNull
    private Integer channelCode;
    @NotNull
    private String coverUrl;
    @NotNull
    private Integer postType;
    @NotNull
    private Integer total;
    @NotNull
    private Integer scope;
    @NotNull
    private Long createAt;
    @NotNull
    private Long createBy;

    public PostAlbum(long albumId, AlbumCreateDto albumCreateDto) {
        this.albumId = albumId;
        this.albumName = albumCreateDto.getAlbumName();
        this.channelCode = 0;
        this.coverUrl = "";
        this.postType = PostType.Video.getCode();
        this.total = 0;
        this.scope = PostScope.PRIVATE.getCode();
        this.createAt = System.currentTimeMillis();
        this.createBy = UserContext.getUserId();
    }

    public PostAlbum(long albumId, String albumName, int scope, int postType, int channelCode) {
        this.albumId = albumId;
        this.albumName = albumName;
        this.channelCode = channelCode;
        this.coverUrl = "";
        this.postType = postType;
        this.total = 0;
        this.scope = scope;
        this.createAt = System.currentTimeMillis();
        this.createBy = UserContext.getUserId();
    }
}
