package cn.estsh.i3plus.pojo.platform.platbean;

import cn.estsh.i3plus.pojo.base.annotation.AnnoOutputColumn;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.mongodb.core.index.Indexed;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * @Description : 用户操作日志表
 * @Reference   :
 * @Author      : wei.peng
 * @Date        : 2018-10-22 16:58:42.720
 * @Modify      :
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="SYS_LOG_OPERATE")
@Api(value="操作日志表",description = "操作日志表")
public class SysLogOperate extends BaseBean {

    @Indexed
    @Column(name="OPERATE_MODULE")
    @ApiParam(value ="系统模块（枚举）", example = "1")
    @AnnoOutputColumn(refClass = CommonEnumUtil.SOFT_TYPE.class,refForeignKey = "value",value = "description")
    private Integer operateModule;

    private String operateModuleName;
    public String getOperateModuleName(){
        if(this.operateModule != null){
            return CommonEnumUtil.SOFT_TYPE.valueOfDescription(this.operateModule);
        }
        return operateModuleName;
    }

    @Indexed
    @Column(name="OPERATE_TYPE")
    @ApiParam(value ="操作类型" , example = "-1")
    @AnnoOutputColumn(refClass = ImppEnumUtil.OPERATE_TYPE.class,refForeignKey = "value",value = "description")
    private Integer operateType;

    @Column(name="OPERATE_MESSAGE")
    @ApiParam(value ="操作信息" , access ="操作信息")
    private String operateMessage;

    @Column(name="USER_LOGIN_NAME")
    @ApiParam(value ="登录用户名称" , access ="登录用户名称")
    private String userLoginName;

    @Column(name="REMOTE_IP")
    @ApiParam(value ="请求IP" , access ="请求IP")
    private String remoteIp;

    @Column(name="REQUEST_URL")
    @ApiParam(value ="请求路径" , access ="请求路径")
    private String requestUrl;

    @Column(name="HTTP_METHOD")
    @ApiParam(value ="http请求方法" , access ="http请求方法")
    private String httpMethod;

    @Column(name="LOG_ARGS")
    @ApiParam(value ="方法入参" , access ="方法入参")
    private String logArgs;

    @Column(name="EXECUTE_TIME")
    @ApiParam(value ="执行耗时")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long executeTime;
}
