package com.gyee.wisdom.dao.sql.topic.entity;

import com.gyee.wisdom.common.data.ToData;
import com.gyee.wisdom.common.data.topic.TopicPoint;
import com.gyee.wisdom.dao.sql.ModelConstants;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;

import javax.persistence.*;
import java.util.List;

/**
 * @descrition:订阅功能，测点视图映射实体
 * @author:Wanghs
 * @date:2018-07-31
 */
@Data
@NoArgsConstructor
@ToString
@EqualsAndHashCode()
@Entity
@Table(name = ModelConstants.VIEW_TOPIC_POINT)
public class PointEntity implements ToData<TopicPoint> {

    @Id
    @Column(name = ModelConstants.ID_)
    private String id;

    @Column(name = ModelConstants.POINT_NAME)
    private String pointName;

    @Column(name = ModelConstants.POINT_TYPE)
    private String pointType;

    @Column(name = ModelConstants.STATION_ID)
    private String stationId;

    @Column(name = ModelConstants.WINDTURBINE_ID)
    private String windturbineId;

    @Column(name = ModelConstants.UNIFORM_CODE)
    private String uniformCode;

    @Column(name = ModelConstants.DATA_TYPE)
    private String dataType;

    @ManyToMany(mappedBy="pointEntityList")
    private List<TopicEntity> topicEntityList;

    @Override
    public TopicPoint toData() {
        TopicPoint point = new TopicPoint();
        point.setId(this.id);

        point.setPointName(this.pointName);
        point.setStationId(this.stationId);
        point.setWindturbineId(this.windturbineId);
        point.setDataType(this.dataType);
        point.setUniformCode(this.uniformCode);
        point.setPointType(this.pointType);
        return point;
    }

    public PointEntity(TopicPoint data)
    {
        this.id=data.getId();
        this.pointName=data.getPointName();
        this.setPointType(data.getPointType());
        this.setStationId(data.getStationId());
        this.setWindturbineId(data.getWindturbineId());
        this.setUniformCode(data.getUniformCode());
        this.setDataType(data.getDataType());

    }

}
