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 class SimpleModel extends CreationModel {

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

    public static void clearBaseInfo(SimpleModel model) {
        CreationModel.clearBaseInfo(model);
        if (model != null) {
            model.updateBy = null;
            model.updateTime = null;
            model.updateByUsername = null;
        }
    }

    /**
     * 更新有关字段
     */
    @Schema(description = "更新者 id")
    @TableField("update_by")
    private String updateBy; // 更新者 id
    
    @Schema(description = "更新者 username 冗余字段")
    @TableField("update_by_name")
    private String updateByUsername; // 更新者 username 冗余字段
    
    @Schema(description = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField("update_time")
    private Date updateTime; //更新时间

    @Schema(description = "更新者所属部门（关联查询）")
    @TableField(exist = false)
    private String updateByDeptName;

}

