Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
34322 ranu 1
package com.spice.profitmandi.dao.entity.fofo;
2
 
3
import javax.persistence.*;
4
import java.time.LocalDateTime;
5
import java.util.Objects;
6
 
7
@Entity
8
@Table(name = "fofo.sales_rating")
9
@NamedQueries({
10
        @NamedQuery(name = "SalesRatingByMonth", query = "" +
11
                "SELECT r FROM SalesRating r WHERE r.fofoId = :fofoId AND r.salesL1Id = :salesL1Id AND r.createTimeStamp BETWEEN :startOfMonth AND :endOfMonth"
12
        ),
13
        @NamedQuery(
14
                name = "Visit.FindAverageRatingBySalesL1Ids",
15
                query = "SELECT new com.spice.profitmandi.dao.model.SalesRatingModel(v.salesL1Id, AVG(v.rating)) " +
16
                        "FROM SalesRating v WHERE v.salesL1Id IN :salesL1Ids GROUP BY v.salesL1Id"
17
        ),
18
        @NamedQuery(
19
                name = "Visit.FindSalesL1Feedback",
20
                query = "SELECT r FROM SalesRating r" +
21
                        " WHERE r.salesL1Id IN :salesL1Ids" +
22
                        " AND r.createTimeStamp BETWEEN :startDate AND :endDate"
23
        )
24
})
25
public class SalesRating {
26
    @Id
27
    @Column(name = "id", unique = true, updatable = false)
28
    private int id;
29
 
30
    @Column(name = "rating")
31
    private int rating;
32
 
33
    @Column(name = "comment")
34
    private String comment;
35
 
36
    @Column(name = "fofo_id")
37
    private int fofoId;
38
 
39
    @Column(name = "sales_l1_id")
40
    private int salesL1Id;
41
 
42
    @Column(name = "create_timestamp")
43
    private LocalDateTime createTimeStamp;
44
 
45
    public int getId() {
46
        return id;
47
    }
48
 
49
    public void setId(int id) {
50
        this.id = id;
51
    }
52
 
53
    public int getRating() {
54
        return rating;
55
    }
56
 
57
    public void setRating(int rating) {
58
        this.rating = rating;
59
    }
60
 
61
    public String getComment() {
62
        return comment;
63
    }
64
 
65
    public void setComment(String comment) {
66
        this.comment = comment;
67
    }
68
 
69
    public int getFofoId() {
70
        return fofoId;
71
    }
72
 
73
    public void setFofoId(int fofoId) {
74
        this.fofoId = fofoId;
75
    }
76
 
77
    public int getSalesL1Id() {
78
        return salesL1Id;
79
    }
80
 
81
    public void setSalesL1Id(int salesL1Id) {
82
        this.salesL1Id = salesL1Id;
83
    }
84
 
85
    public LocalDateTime getCreateTimeStamp() {
86
        return createTimeStamp;
87
    }
88
 
89
    public void setCreateTimeStamp(LocalDateTime createTimeStamp) {
90
        this.createTimeStamp = createTimeStamp;
91
    }
92
 
93
    @Override
94
    public boolean equals(Object o) {
95
        if (this == o) return true;
96
        if (o == null || getClass() != o.getClass()) return false;
97
        SalesRating that = (SalesRating) o;
98
        return id == that.id && rating == that.rating && fofoId == that.fofoId && salesL1Id == that.salesL1Id && Objects.equals(comment, that.comment) && Objects.equals(createTimeStamp, that.createTimeStamp);
99
    }
100
 
101
    @Override
102
    public int hashCode() {
103
        return Objects.hash(id, rating, comment, fofoId, salesL1Id, createTimeStamp);
104
    }
105
 
106
    @Override
107
    public String toString() {
108
        return "SalesRating{" +
109
                "id=" + id +
110
                ", rating=" + rating +
111
                ", comment='" + comment + '\'' +
112
                ", fofoId=" + fofoId +
113
                ", salesL1Id=" + salesL1Id +
114
                ", createTimeStamp=" + createTimeStamp +
115
                '}';
116
    }
117
}