package com.bohuikeji.frame.module.admin.entity.sys;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.bohuikeji.frame.module.admin.base.EntityBase;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.text.MessageFormat;
import java.time.LocalDateTime;

/**
 * 错误记录
 * @author 10552
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class SysError extends EntityBase {

    /**
     * 自增ID
     */
    @TableId(value = "error_id", type = IdType.AUTO)
    private Integer errorId;

    /**
     * 错误内容
     */
    @TableField("error_desc")
    private String errorDesc;

    /**
     * 上报时间
     */
    @TableField("error_time")
    private LocalDateTime errorTime=LocalDateTime.now();

    public static boolean saveError(String desc,Object... args){
        SysError error=new SysError();
        error.setErrorDesc(MessageFormat.format(desc,args));
        return error.insert();
    }
}
