Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.spice.profitmandi.dao.entity.fofo;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Objects;

@Entity
@Table(name = "fofo.sales_rating")
@NamedQueries({
        @NamedQuery(name = "SalesRatingByMonth", query = "" +
                "SELECT r FROM SalesRating r WHERE r.fofoId = :fofoId AND r.salesL1Id = :salesL1Id AND r.createTimeStamp BETWEEN :startOfMonth AND :endOfMonth"
        ),
        @NamedQuery(
                name = "Visit.FindAverageRatingBySalesL1Ids",
                query = "SELECT new com.spice.profitmandi.dao.model.SalesRatingModel(v.salesL1Id, AVG(v.rating)) " +
                        "FROM SalesRating v WHERE v.salesL1Id IN :salesL1Ids GROUP BY v.salesL1Id"
        ),
        @NamedQuery(
                name = "Visit.FindSalesL1Feedback",
                query = "SELECT r FROM SalesRating r" +
                        " WHERE r.salesL1Id IN :salesL1Ids" +
                        " AND r.createTimeStamp BETWEEN :startDate AND :endDate"
        )
})
public class SalesRating {
    @Id
    @Column(name = "id", unique = true, updatable = false)
    private int id;

    @Column(name = "rating")
    private int rating;

    @Column(name = "comment")
    private String comment;

    @Column(name = "fofo_id")
    private int fofoId;

    @Column(name = "sales_l1_id")
    private int salesL1Id;

    @Column(name = "create_timestamp")
    private LocalDateTime createTimeStamp;

    public int getId() {
        return id;
    }

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

    public int getRating() {
        return rating;
    }

    public void setRating(int rating) {
        this.rating = rating;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public int getFofoId() {
        return fofoId;
    }

    public void setFofoId(int fofoId) {
        this.fofoId = fofoId;
    }

    public int getSalesL1Id() {
        return salesL1Id;
    }

    public void setSalesL1Id(int salesL1Id) {
        this.salesL1Id = salesL1Id;
    }

    public LocalDateTime getCreateTimeStamp() {
        return createTimeStamp;
    }

    public void setCreateTimeStamp(LocalDateTime createTimeStamp) {
        this.createTimeStamp = createTimeStamp;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        SalesRating that = (SalesRating) o;
        return id == that.id && rating == that.rating && fofoId == that.fofoId && salesL1Id == that.salesL1Id && Objects.equals(comment, that.comment) && Objects.equals(createTimeStamp, that.createTimeStamp);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, rating, comment, fofoId, salesL1Id, createTimeStamp);
    }

    @Override
    public String toString() {
        return "SalesRating{" +
                "id=" + id +
                ", rating=" + rating +
                ", comment='" + comment + '\'' +
                ", fofoId=" + fofoId +
                ", salesL1Id=" + salesL1Id +
                ", createTimeStamp=" + createTimeStamp +
                '}';
    }
}