package com.weather.modules.sys.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.weather.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;

/**
 * 系统通知
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("sys_alert")
public class SysAlertEntity extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 级别: info | warning | danger
     */
    private String level;
    /**
     * 通知标题
     */
    private String title;
    /**
     * 通知正文
     */
    private String content;
    /**
     * 来源: manual | import | schedule | datasource
     */
    private String sourceType;
    /**
     * 业务关联ID
     */
    private String sourceId;
    /**
     * 1=有效 0=已撤回
     */
    private Integer isActive;
    /**
     * 发布时间
     */
    private Date publishTime;
    /**
     * 过期时间（null=永不过期）
     */
    private Date expireTime;
    /**
     * 更新者
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Long updater;
    /**
     * 更新时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateDate;

    public boolean isActive() {
        return isActive != null && isActive == 1;
    }

    public boolean isExpired() {
        return expireTime != null && expireTime.before(new Date());
    }
}
