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 lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;

/**
 * @author reghao
 * @date 2022-03-21 13:19:49
 */
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Data
public class SearchRecord extends BaseObject<Integer> {
    @NotBlank
    @Size(min = 1, max = 64, message = "查询关键字不能超过 64 个字符")
    private String keyword;
    @NotNull
    private Long searchBy;
    @NotNull
    private LocalDateTime searchAt;

    public SearchRecord(String keyword) {
        this.keyword = keyword;
        this.searchBy = UserContext.getUserId();
        this.searchAt = LocalDateTime.now();
    }
}
