package com.sptg.permissions.api.entity;

import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

@Getter
@Setter
@TableName(value = "sys_api_log")
public class ApiLog {

    @TableId(value = "l_id", type = IdType.AUTO)
    private Long id;

    /**
     * 请求方法名
     */
    @TableField(value = "s_method")
    private String method;

    /**
     * 方法描述
     */
    @TableField(value = "s_method_desc")
    private String methodDesc;

    /**
     * 请求参数
     */
    @TableField(value = "s_req_data")
    private String reqData;

    /**
     * 请求来源
     * 后台、小程序、app
     */
    @TableField(value = "s_from")
    private String from;

    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @TableField(value = "t_create_date")
    private Date createDate;

    public ApiLog(String method, String methodDesc, String reqData, String from){
        this.method = method;
        this.methodDesc = methodDesc;
        this.reqData = reqData;
        this.from = from;
        this.createDate = new Date();
    }

    public ApiLog(){}
}
