-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAd.java
More file actions
259 lines (222 loc) · 4.03 KB
/
Ad.java
File metadata and controls
259 lines (222 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
/*
*
*
*/
package com.easyshopping.entity;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
/**
* Entity - 广告
*
*
* @version 1.0
*/
@Entity
@Table(name = "xx_ad")
@SequenceGenerator(name = "sequenceGenerator", sequenceName = "xx_ad_sequence")
public class Ad extends OrderEntity {
private static final long serialVersionUID = -1307743303786909390L;
/**
* 类型
*/
public enum Type {
/** 文本 */
text,
/** 图片 */
image,
/** flash */
flash
}
/** 标题 */
private String title;
/** 类型 */
private Type type;
/** 内容 */
private String content;
/** 路径 */
private String path;
/** 起始日期 */
private Date beginDate;
/** 结束日期 */
private Date endDate;
/** 链接地址 */
private String url;
/** 广告位 */
private AdPosition adPosition;
/**
* 获取标题
*
* @return 标题
*/
@NotEmpty
@Length(max = 200)
@Column(nullable = false)
public String getTitle() {
return title;
}
/**
* 设置标题
*
* @param title
* 标题
*/
public void setTitle(String title) {
this.title = title;
}
/**
* 获取类型
*
* @return 类型
*/
@NotNull
@Column(nullable = false)
public Type getType() {
return type;
}
/**
* 设置类型
*
* @param type
* 类型
*/
public void setType(Type type) {
this.type = type;
}
/**
* 获取内容
*
* @return 内容
*/
@Lob
public String getContent() {
return content;
}
/**
* 设置内容
*
* @param content
* 内容
*/
public void setContent(String content) {
this.content = content;
}
/**
* 获取路径
*
* @return 路径
*/
@Length(max = 200)
public String getPath() {
return path;
}
/**
* 设置路径
*
* @param path
* 路径
*/
public void setPath(String path) {
this.path = path;
}
/**
* 获取起始日期
*
* @return 起始日期
*/
public Date getBeginDate() {
return beginDate;
}
/**
* 设置起始日期
*
* @param beginDate
* 起始日期
*/
public void setBeginDate(Date beginDate) {
this.beginDate = beginDate;
}
/**
* 获取结束日期
*
* @return 结束日期
*/
public Date getEndDate() {
return endDate;
}
/**
* 设置结束日期
*
* @param endDate
* 结束日期
*/
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
/**
* 获取链接地址
*
* @return 链接地址
*/
@Length(max = 200)
public String getUrl() {
return url;
}
/**
* 设置链接地址
*
* @param url
* 链接地址
*/
public void setUrl(String url) {
this.url = url;
}
/**
* 获取广告位
*
* @return 广告位
*/
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(nullable = false)
public AdPosition getAdPosition() {
return adPosition;
}
/**
* 设置广告位
*
* @param adPosition
* 广告位
*/
public void setAdPosition(AdPosition adPosition) {
this.adPosition = adPosition;
}
/**
* 判断是否已开始
*
* @return 是否已开始
*/
@Transient
public boolean hasBegun() {
return getBeginDate() == null || new Date().after(getBeginDate());
}
/**
* 判断是否已结束
*
* @return 是否已结束
*/
@Transient
public boolean hasEnded() {
return getEndDate() != null && new Date().after(getEndDate());
}
}