package com.bocloud.ims.entity.topology;

import com.bocloud.common.utils.DateSerializer;
import com.bocloud.entity.annotations.Column;
import com.bocloud.entity.annotations.IgnoreAll;
import com.bocloud.entity.annotations.PK;
import com.bocloud.entity.annotations.Table;
import com.bocloud.entity.bean.Generic;
import com.bocloud.entity.meta.PKStrategy;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.List;

/**
 * instance_relation实体类
 *
 * @author lyy
 * @Version 1.0
 * @since 2017年9月13日
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Table("ci_instance_relation")
public class InstanceRelation extends Generic {
    @PK(value = PKStrategy.AUTO)
    private Long id;
    @Column("source_id")
    private Long sourceId;
    @Column("relation_id")
    private Long relationId;
    @Column("target_id")
    private Long targetId;
    @Column("source_module_id")
    private Long sourceModuleId;
    @Column("target_module_id")
    private Long targetModuleId;
    @Column("module_relation_id")
    private Long moduleRelationId;
    // 创建时间
    @Column("gmt_create")
    @JsonSerialize(using = DateSerializer.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date gmtCreate;
    // 创建人
    @Column("creator_id")
    private Long creatorId;
    @Column("is_deleted")
    private Boolean deleted;
    @Column("is_manual")
    private Boolean manual;
    @Column("category_id")
    private Long categoryId;
    @IgnoreAll
    private List<Instance> instances;
    @IgnoreAll
    private String guidTemp;

    public InstanceRelation(Long sourceId, Long relationId, Long targetId, Long sourceModuleId, Long targetModuleId,
                            Long moduleRelationId, Date gmtCreate, Long creatorId, Boolean deleted, Long categoryId, Boolean manual) {
        super();
        this.sourceId = sourceId;
        this.relationId = relationId;
        this.targetId = targetId;
        this.sourceModuleId = sourceModuleId;
        this.targetModuleId = targetModuleId;
        this.moduleRelationId = moduleRelationId;
        this.gmtCreate = gmtCreate;
        this.creatorId = creatorId;
        this.deleted = deleted;
        this.categoryId = categoryId;
        this.manual = manual;
    }

    public InstanceRelation(Long sourceId, Long relationId, Long targetId, Date gmtCreate, Long creatorId,
                            Boolean deleted, List<Instance> instances, Long categoryId, Boolean manual) {
        super();
        this.sourceId = sourceId;
        this.relationId = relationId;
        this.targetId = targetId;
        this.gmtCreate = gmtCreate;
        this.creatorId = creatorId;
        this.deleted = deleted;
        this.instances = instances;
        this.categoryId = categoryId;
        this.manual = manual;
    }

    /**
     * @return the categoryId
     */
    public Long getRelation() {
        return relationId;
    }

    /**
     * @param relationId the categoryId to set
     */
    public void setRelation(Long relationId) {
        this.relationId = relationId;
    }
}
