package com.lingyue.common.domain.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.Date;

/**
 * 创建信息模型基类
 *
 * @author lingyue
 */
@Data
public abstract class CreationModel extends AssignUuidModel {

    public static final String[] IGNORE_FIELDS = {"id", "createBy", "createTime", "createByUsername"};

    public static void clearBaseInfo(CreationModel model) {
        if (model != null) {
            model.createBy = null;
            model.createTime = null;
            model.createByUsername = null;
        }
    }

    /**
     * 创建有关字段
     */
    @Schema(description = "创建者 id")
    @TableField("create_by")
    private String createBy; // 创建者id
    
    @Schema(description = "创建者 username 冗余字段")
    @TableField("create_by_name")
    private String createByUsername; // 创建者 username 冗余字段
    
    @TableField("create_time")
    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime; // 创建时间

    @Schema(description = "创建者用户所属部门（关联查询）")
    @TableField(exist = false)
    private String createByDeptName;
}

