package com.ruoyi.ibs.rules.domain.entity;


import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.ibs.rules.domain.dto.RelationRuleDTO;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.Date;

/**
 * 分配引擎规则;对象 relation_rule
 *
 * @author ruoyi
 * @date 2024-09-20
 */
public class RelationRule {
    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    private Long id;

    /**
     * 规则id
     */
    @Excel(name = "规则id")
    private String ruleId;

    /**
     * 规则名
     */
    @Excel(name = "规则名")
    private String ruleName;

    /**
     * 规则类型（1个人2企业3商户）
     */
    @Excel(name = "规则类型", readConverterExp = "1=个人2企业3商户")
    private String ruleType;

    /**
     * 规则优先级
     */
    @Excel(name = "规则优先级")
    private long ruleLevel;

    /**
     * 规则参数
     */
    @Excel(name = "规则参数")
    private String param;

    /**
     * $column.columnComment
     */
    @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
    private String deptId;

    @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
    private String updateBy;

    @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
    private Date updateTime;

    @ApiModelProperty("规则编码")
    private String ruleNameId;

    /**
     * 1年2半年3季度4月0手动
     */
    @Excel(name = "1年2半年3季度4月0手动")
    private String updateCounts;

    @Excel(name = "1有效0无效")
    private String status;

    @Excel(name ="地址来源")
    private String addSource;
    @Excel(name ="地址来源码值")
    private String addSourceId;

    public RelationRule(RelationRuleDTO relationRule) {
        this.ruleId = relationRule.getId();
        this.ruleType = relationRule.getRuleType();
        this.updateCounts = relationRule.getUpdateCounts();
        this.ruleLevel = relationRule.getLevel();
        this.ruleName = relationRule.getName();
        this.param = relationRule.getParam();
        this.updateBy = SecurityUtils.getUsername();
        this.updateTime = new Date();
        this.deptId = StringUtils.isNotEmpty(relationRule.getDeptId()) ? relationRule.getDeptId() : SecurityUtils.getDeptId().toString();
        this.status = "1";
        this.ruleNameId = relationRule.getRuleNameId();
        this.addSource = relationRule.getAddSource();
        this.addSourceId = relationRule.getAddSourceId();
    }

    public RelationRule() {
    }


    public void setId(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setRuleId(String ruleId) {
        this.ruleId = ruleId;
    }

    public String getRuleId() {
        return ruleId;
    }

    public void setRuleName(String ruleName) {
        this.ruleName = ruleName;
    }

    public String getRuleName() {
        return ruleName;
    }

    public void setRuleType(String ruleType) {
        this.ruleType = ruleType;
    }

    public String getRuleType() {
        return ruleType;
    }

    public void setRuleLevel(Long ruleLevel) {
        this.ruleLevel = ruleLevel;
    }

    public long getRuleLevel() {
        return ruleLevel;
    }

    public void setParam(String param) {
        this.param = param;
    }

    public String getParam() {
        return param;
    }

    public void setDeptId(String updateDept) {
        this.deptId = updateDept;
    }

    public String getDeptId() {
        return deptId;
    }


    public void setUpdateCounts(String updateCounts) {
        this.updateCounts = updateCounts;
    }

    public String getUpdateCounts() {
        return updateCounts;
    }


    public void setUpdateBy(String updateBy) {
        this.updateBy = updateBy;
    }

    public String getUpdateBy() {
        return updateBy;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getStatus() {
        return status;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("id", getId())
                .append("ruleId", getRuleId())
                .append("ruleName", getRuleName())
                .append("ruleType", getRuleType())
                .append("ruleLevel", getRuleLevel())
                .append("param", getParam())
                .append("updateBy", getUpdateBy())
                .append("updateDept", getDeptId())
                .append("updateTime", getUpdateTime())
                .append("updateCounts", getUpdateCounts())
                .append("status", getStatus())
                .append("ruleNameId", getRuleNameId())
                .toString();
    }

    public String getRuleNameId() {
        return ruleNameId;
    }

    public void setRuleNameId(String ruleNameId) {
        this.ruleNameId = ruleNameId;
    }

    public String getAddSource() {
        return addSource;
    }

    public void setAddSource(String addSource) {
        this.addSource = addSource;
    }

    public String getAddSourceId() {
        return addSourceId;
    }

    public void setAddSourceId(String addSourceId) {
        this.addSourceId = addSourceId;
    }
}
