package com.persagy.dmp.define.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.persagy.dmp.basic.dto.RelationCalRuleDTO;
import com.persagy.dmp.basic.dto.RelationCalDTO;
import com.persagy.dmp.common.model.entity.AuditableEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 关系定义
 * @author Charlie Yu
 * @date 2021-06-25
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "dt_define_rel", autoResultMap = true)
public class RelationDefine extends AuditableEntity {
    /** 编码 */
    @NotNull(message = "编码不允许为空")
    @Length(max = 40)
    private String code;
    /** 名称 */
    @NotNull(message = "名称不允许为空")
    @Length(max = 200)
    private String name;
    /** 图类型编码 */
    @NotNull(message = "图类型编码不允许为空")
    @Length(max = 40)
    private String graphCode;
    /** 边方向性 */
    private Integer directional;
    /** 边属性 */
    private String attribute;
    /** 主要连接对象 */
    private String targetObjs;
    /** 备注 */
    private String remark;
    /** 计算关系之前需要计算的关系 */
    @TableField(value = "before_cal_rel",typeHandler = JacksonTypeHandler.class)
    private List<RelationCalDTO> beforeCalRels;
    /** 计算器,就是计算规则 */
    @TableField(value = "cal_rule",typeHandler = JacksonTypeHandler.class)
    private RelationCalRuleDTO calRules;
    /** 关系左侧的对象分类 */
    @TableField(value = "from_obj_type")
    private String fromObjType;
    /** 关系右侧的对象分类 */
    @TableField(value = "to_obj_type")
    private String toObjType;
    /** 关系右侧的对象分类 */
    @TableField(value = "automatic_flag")
    private Integer automaticFlag;
}
