/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package com.youchain.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @website https://eladmin.vip
* @description /
* @author houjianlan
* @date 2025-12-23
**/
@Entity
@Getter
@Setter
@Table(name = "sys_oper_log")
@NoArgsConstructor
public class OperLog  implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "ID")
    private Long id;

    @Column(name = "`description`")
    @ApiModelProperty(value = "描述")
    private String description;

    @Column(name = "`log_type`")
    @ApiModelProperty(value = "类型")
    private String logType;

    @Column(name = "`params`")
    @ApiModelProperty(value = "参数")
    private String params;

    @Column(name = "`return_data`")
    @ApiModelProperty(value = "返回")
    private String returnData;

    @Column(name = "`request_ip`")
    @ApiModelProperty(value = "requestIp")
    private String requestIp;

    @Column(name = "`time`")
    @ApiModelProperty(value = "耗时")
    private Long time;

    @Column(name = "`username`")
    @ApiModelProperty(value = "操作人")
    private String username;

    @Column(name = "`address`")
    @ApiModelProperty(value = "address")
    private String address;

    @Column(name = "`module`")
    @ApiModelProperty(value = "模块名")
    private String module;

    @Column(name = "`method`")
    @ApiModelProperty(value = "方法名")
    private String method;

    @Column(name = "`content`")
    @ApiModelProperty(value = "操作内容")
    private String content;

    @Column(name = "`source_id`")
    @ApiModelProperty(value = "来源序号")
    private Long sourceId;

    @Column(name = "`browser`")
    @ApiModelProperty(value = "browser")
    private String browser;

    @Column(name = "`exception_detail`")
    @ApiModelProperty(value = "exceptionDetail")
    private String exceptionDetail;

    @Column(name = "`create_time`")
    @ApiModelProperty(value = "创建时间")
    private Timestamp createTime;

    public void copy(OperLog source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
    public OperLog(String logType, Long time) {
        this.logType = logType;
        this.time = time;
    }
}
