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.annotation.TableKeyField;
import com.bohuikeji.frame.module.admin.annotation.TableNewField;
import com.bohuikeji.frame.module.admin.annotation.TableQueryField;
import com.bohuikeji.frame.module.admin.annotation.TableShowField;
import com.bohuikeji.frame.module.admin.base.EntityBase;
import com.bohuikeji.frame.module.admin.entity.web.block.SelectBlock;
import com.bohuikeji.frame.module.admin.entity.web.block.TextBlock;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;

/**
 * 系统日志记录
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class SysLog extends EntityBase {

    @TableId(value = "log_id", type = IdType.AUTO)
    @TableShowField(value = "ID",id = true)
    @TableNewField(show = false)
    private Integer logId;

    @TableField("log_type")
    @TableQueryField(like = false)
    @TableNewField(edit = false)
    @TableShowField("日志类型")
    private String logType;

    @TableField("log_user")
    @TableShowField("操作用户")
    @TableNewField(edit = false,block = SelectBlock.class)
    @TableQueryField(like = false)
    @TableKeyField(table = "sys_user",keyShowFields = "user_name",keyLikeFields = "user_name",key = SysUser.class)
    private Integer logUser;

    @TableField("log_ip")
    @TableQueryField(show = false)
    @TableShowField("操作IP")
    @TableNewField(edit = false)
    private String logIp;

    @TableNewField(edit = false)
    @TableQueryField(like = false)
    @TableField("log_model")
    @TableShowField("所属模块")
    private String logModel;

    @TableNewField(edit = false)
    @TableField("log_url")
    @TableShowField(value = "请求地址",show = false)
    private String logUrl;

    @TableNewField(edit = false)
    @TableQueryField(like = false)
    @TableField("log_menu")
    @TableShowField("所属菜单")
    private String logMenu;

    @TableNewField(edit = false)
    @TableQueryField(like = false)
    @TableField("log_cation")
    @TableShowField("执行动作")
    private String logAction;

    @TableNewField(edit = false)
    @TableQueryField(show = false)
    @TableField("log_name")
    @TableShowField("操作项")
    private String logName;

    @TableNewField(edit = false,block = TextBlock.class)
    @TableField("log_detail")
    @TableQueryField(show = false)
    @TableShowField(value = "操作详情",show = false)
    private String logDetail;

    @TableNewField(edit = false,block = TextBlock.class)
    @TableField("log_method")
    @TableQueryField(show = false)
    @TableShowField(value = "调用方法",show = false)
    private String logMethod;

    @TableNewField(edit = false,block = TextBlock.class)
    @TableField("log_parms")
    @TableShowField(value = "执行参数",show = false)
    @TableQueryField(show = false)
    private String logParams;

    @TableNewField(edit = false,block = TextBlock.class)
    @TableField("log_return")
    @TableShowField(value = "返回值",show = false)
    @TableQueryField(show = false)
    private String logReturn;

    @TableNewField(edit = false)
    @TableQueryField(like = false)
    @TableField("log_result")
    @TableShowField("执行结果")
    private String logResult;

    @TableNewField(edit = false)
    @TableQueryField(like = false)
    @TableField("log_node")
    @TableShowField("服务节点")
    private String logNode;

    @TableNewField(block = TextBlock.class)
    @TableField("log_rmk")
    @TableQueryField(show = false)
    @TableShowField("日志备注")
    private String logRmk;

    @TableNewField(edit = false)
    @TableQueryField(like = false,sort = 0)
    @TableField("create_time")
    @TableShowField("操作时间")
    private LocalDateTime createTime=LocalDateTime.now();

    @TableNewField(edit = false)
    @TableField("run_time")
    @TableShowField("耗时")
    private String runTime;
}
