package com.ruoyi.cai.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.cai.enums.account.AccountChangeCodeEnum;
import lombok.Data;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 账户明细对象 cai_account_change_log
 *
 * @author 77
 * @date 2024-01-05
 */
@Data
@TableName("cai_account_change_log")
public class AccountChangeLog implements Serializable {

    private static final long serialVersionUID=1L;

    @TableId(value = "id")
    private Long id;
    /**
     * 用户ID
     */
    private Long userId;
    /**
     * 蜜瓜号
     */
    private String usercode;
    private Long tarUserId;
    private String tarParam;
    private String tarImg;
    /**
     * 账户类型 1-余额 2-收益
     */
    private Integer accountType;
    /**
     * 类别
     */
    private Integer cateId;
    /**
     * 名称
     */
    private String cateAdminName;
    private Integer changeType;
    private Long traceId;
    private String traceLinkType;
    /**
     * 变化值，为正 或者为负
     */
    private Long changeValue;
    /**
     * 备注
     */
    private String remark;
    /**
     * 操作IP
     */
    @Deprecated
    private String operateIp;
    /**
     * 是否为后台用户手动调整
     */
    private Integer isAdmin;

    private LocalDateTime createTime;

    @TableField(exist = false)
    private String showMessage;


    public void init(AccountChangeCodeEnum change){
        this.setAccountType(change.getAccountType().getCode());
        this.setChangeType(change.getCode());
        this.setCateId(change.getCate().getCode());
        this.setCateAdminName(change.getText());
        this.setTraceLinkType(change.getCate().name());
        this.setRemark(change.getDesc());
    }

}
