package org.jeecg.modules.database.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * @Description: 文档访问历史
 * @Author: jeecg-boot
 * @Date: 2024-11-14
 * @Version: V1.0
 */
@Data
@TableName("document_visit_history")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description = "文档访问历史")
public class DocumentVisitHistory implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @TableId(type = IdType.ASSIGN_ID)
    @Schema(description = "主键")
    private String  id;
    /**
     * 创建人
     */
    @Schema(description = "创建人")
    private String  createBy;
    /**
     * 创建日期
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    @Schema(description = "创建日期")
    private Date    createTime;
    /**
     * 更新人
     */
    @Schema(description = "更新人")
    private String  updateBy;
    /**
     * 更新日期
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    @Schema(description = "更新日期")
    private Date    updateTime;
    /**
     * 所属部门
     */
    @Schema(description = "所属部门")
    private String  sysOrgCode;
    /**
     * 文档ID
     */
    @Excel(name = "文档ID", width = 15)
    @Schema(description = "文档ID")
    private String  documentId;
    /**
     * 用户ID
     */
    @Excel(name = "用户ID", width = 15)
    @Schema(description = "用户ID")
    private String  userId;
    /**
     * 文档标题
     */
    @Excel(name = "文档标题", width = 15)
    @Schema(description = "文档标题")
    private String  documentTitle;
    /**
     * 访问次数
     */
    @Excel(name = "访问次数", width = 15)
    @Schema(description = "访问次数")
    private Integer visitCount;

    public void addVisitCount() {
        if (this.visitCount == null) {
            this.visitCount = 0;
        }
        this.visitCount++;
    }
}
