Subversion Repositories SmartDukaan

Rev

Rev 22243 | Rev 23202 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
21714 ashik.ali 1
package com.spice.profitmandi.dao.entity.fofo;
21596 ashik.ali 2
 
3
import java.io.Serializable;
4
import java.time.LocalDateTime;
22243 ashik.ali 5
import java.time.format.DateTimeFormatter;
21984 kshitij.so 6
import java.util.List;
21596 ashik.ali 7
 
21984 kshitij.so 8
import javax.persistence.CascadeType;
21596 ashik.ali 9
import javax.persistence.Column;
22009 ashik.ali 10
import javax.persistence.Convert;
21596 ashik.ali 11
import javax.persistence.Entity;
21984 kshitij.so 12
import javax.persistence.FetchType;
21596 ashik.ali 13
import javax.persistence.GeneratedValue;
14
import javax.persistence.GenerationType;
15
import javax.persistence.Id;
21984 kshitij.so 16
import javax.persistence.JoinColumn;
17
import javax.persistence.ManyToOne;
21596 ashik.ali 18
import javax.persistence.NamedQueries;
19
import javax.persistence.NamedQuery;
21984 kshitij.so 20
import javax.persistence.OneToMany;
21596 ashik.ali 21
import javax.persistence.Table;
22
 
22009 ashik.ali 23
import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
24
 
21596 ashik.ali 25
@Entity
26
@Table(name="fofo.fofo_order", schema = "fofo")
27
@NamedQueries({
28
	@NamedQuery(name = "FofoOrder.selectCount", query = "select count(fo) from FofoOrder fo"),
29
	@NamedQuery(name = "FofoOrder.selectById", query = "select fo from FofoOrder fo where fo.id = :id"),
30
	@NamedQuery(name = "FofoOrder.selectByFofoId", query = "select fo from FofoOrder fo where fo.fofoId = :fofoId"),
31
	@NamedQuery(name = "FofoOrder.selectTotolAmountByFofoId", query = "select sum(fo.totalAmount) from FofoOrder fo where fo.fofoId = :fofoId group by fo.fofoId"),
32
	@NamedQuery(name = "FofoOrder.selectByInvoiceNumber", query = "select fo from FofoOrder fo where fo.invoiceNumber = :invoiceNumber")
33
})
34
public class FofoOrder implements Serializable{
35
 
36
	private static final long serialVersionUID = 1L;
37
 
38
	@Id
39
	@Column(name = "id")
40
	@GeneratedValue(strategy = GenerationType.IDENTITY)
41
	private int id;
42
 
43
	@Column(name = "fofo_id")
44
	private int fofoId;
45
 
46
	@Column(name = "customer_id")
47
	private int customerId;
48
 
21710 ashik.ali 49
	@Column(name = "customer_address_id")
50
	private int customerAddressId;
51
 
21596 ashik.ali 52
	@Column(name = "total_amount")
53
	private float totalAmount;
54
 
21609 ashik.ali 55
	@Column(name = "invoice_number", length = 50)
21596 ashik.ali 56
	private String invoiceNumber;
57
 
22859 ashik.ali 58
	@Column(name = "cashback")
59
	private float cashback;
60
 
22009 ashik.ali 61
	@Convert(converter = LocalDateTimeAttributeConverter.class)
21596 ashik.ali 62
	@Column(name = "create_timestamp")
63
	private LocalDateTime createTimestamp = LocalDateTime.now();
64
 
21984 kshitij.so 65
	@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY)
66
	@JoinColumn(name="order_id",insertable=false,updatable=false,nullable=false)
22859 ashik.ali 67
	private List<FofoOrderItem> fofoLineItem;	
21924 ashik.ali 68
 
22009 ashik.ali 69
 
21984 kshitij.so 70
	@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY)
71
	@JoinColumn(name="order_id",insertable=false,updatable=false,nullable=false)
72
	private List<PaymentOption> paymentOption;	
73
 
74
	public List<PaymentOption> getPaymentOption() {
75
		return paymentOption;
76
	}
77
	public void setPaymentOption(List<PaymentOption> paymentOption) {
78
		this.paymentOption = paymentOption;
79
	}
22859 ashik.ali 80
	public List<FofoOrderItem> getFofoLineItem() {
21984 kshitij.so 81
		return fofoLineItem;
82
	}
22859 ashik.ali 83
	public void setFofoLineItem(List<FofoOrderItem> fofoLineItem) {
21984 kshitij.so 84
		this.fofoLineItem = fofoLineItem;
85
	}
86
	@ManyToOne(cascade=CascadeType.ALL,fetch=FetchType.LAZY)
87
	@JoinColumn(name="customer_id",insertable=false,updatable=false,nullable=false, referencedColumnName="id")
88
	private Customer customer;	
89
 
21988 kshitij.so 90
	@ManyToOne(cascade=CascadeType.ALL,fetch=FetchType.LAZY)
91
	@JoinColumn(name="customer_address_id",insertable=false,updatable=false,nullable=false, referencedColumnName="id")
92
	private CustomerAddress customerAddress;	
93
 
94
	public CustomerAddress getCustomerAddress() {
95
		return customerAddress;
96
	}
97
	public void setCustomerAddress(CustomerAddress customerAddress) {
98
		this.customerAddress = customerAddress;
99
	}
21984 kshitij.so 100
	public Customer getCustomer() {
101
		return customer;
102
	}
103
	public void setCustomer(Customer customer) {
104
		this.customer = customer;
105
	}
106
	public int getId() {
107
		return id;
108
	}
109
	public void setId(int id) {
110
		this.id = id;
111
	}
112
	public int getFofoId() {
113
		return fofoId;
114
	}
115
	public void setFofoId(int fofoId) {
116
		this.fofoId = fofoId;
117
	}
118
	public int getCustomerId() {
119
		return customerId;
120
	}
121
	public void setCustomerId(int customerId) {
122
		this.customerId = customerId;
123
	}
124
	public int getCustomerAddressId() {
125
		return customerAddressId;
126
	}
127
	public void setCustomerAddressId(int customerAddressId) {
128
		this.customerAddressId = customerAddressId;
129
	}
130
	public float getTotalAmount() {
131
		return totalAmount;
132
	}
133
	public void setTotalAmount(float totalAmount) {
134
		this.totalAmount = totalAmount;
135
	}
136
	public String getInvoiceNumber() {
137
		return invoiceNumber;
138
	}
139
	public void setInvoiceNumber(String invoiceNumber) {
140
		this.invoiceNumber = invoiceNumber;
141
	}
22859 ashik.ali 142
	public float getCashback() {
143
		return cashback;
144
	}
145
	public void setCashback(float cashback) {
146
		this.cashback = cashback;
147
	}
21984 kshitij.so 148
	public LocalDateTime getCreateTimestamp() {
149
		return createTimestamp;
150
	}
151
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
152
		this.createTimestamp = createTimestamp;
153
	}
22009 ashik.ali 154
 
22243 ashik.ali 155
	public String getFormattedDate(){
156
    	DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-YYYY HH:mm");
157
		return this.createTimestamp.format(formatter);
158
    }
22009 ashik.ali 159
 
21924 ashik.ali 160
	@Override
22009 ashik.ali 161
	public int hashCode() {
162
		final int prime = 31;
163
		int result = 1;
164
		result = prime * result + id;
165
		return result;
166
	}
22859 ashik.ali 167
 
22009 ashik.ali 168
	@Override
169
	public boolean equals(Object obj) {
170
		if (this == obj)
171
			return true;
172
		if (obj == null)
173
			return false;
174
		if (getClass() != obj.getClass())
175
			return false;
176
		FofoOrder other = (FofoOrder) obj;
177
		if (id != other.id)
178
			return false;
179
		return true;
180
	}
22859 ashik.ali 181
 
22009 ashik.ali 182
	@Override
21602 ashik.ali 183
	public String toString() {
21710 ashik.ali 184
		return "FofoOrder [id=" + id + ", fofoId=" + fofoId + ", customerId=" + customerId + ", customerAddressId="
185
				+ customerAddressId + ", totalAmount=" + totalAmount + ", invoiceNumber=" + invoiceNumber
22859 ashik.ali 186
				+ ", cashback=" + cashback + ", createTimestamp=" + createTimestamp + ", fofoLineItem=" + fofoLineItem
187
				+ ", paymentOption=" + paymentOption + ", customer=" + customer + ", customerAddress=" + customerAddress
188
				+ "]";
21602 ashik.ali 189
	}
190
 
21596 ashik.ali 191
}