8d2fadf4bad4ab5fe907aef84a67ccd1fad2da7a.svn-base
7.15 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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
/**
* Copyright © 2015-2018 ODM All rights reserved.
*/
package com.thinkgem.jeesite.modules.cms.entity;
import java.util.Date;
import java.util.List;
import org.hibernate.validator.constraints.Length;
import com.google.common.collect.Lists;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.persistence.TreeEntity;
import com.thinkgem.jeesite.modules.cms.utils.CmsUtils;
import com.thinkgem.jeesite.modules.sys.entity.Office;
/**
* 栏目Entity
* @author ThinkGem
* @version 2013-05-15
*/
public class Category extends TreeEntity<Category> {
public static final String DEFAULT_TEMPLATE = "frontList";
private static final long serialVersionUID = 1L;
private Site site; // 归属站点
private Office office; // 归属部门
// private Category parent;// 父级菜单
// private String parentIds;// 所有父级编号
private String module; // 栏目模型(article:文章;picture:图片;download:下载;link:链接;special:专题)
// private String name; // 栏目名称
private String image; // 栏目图片
private String href; // 链接
private String target; // 目标( _blank、_self、_parent、_top)
private String description; // 描述,填写有助于搜索引擎优化
private String keywords; // 关键字,填写有助于搜索引擎优化
// private Integer sort; // 排序(升序)
private String inMenu; // 是否在导航中显示(1:显示;0:不显示)
private String inList; // 是否在分类页中显示列表(1:显示;0:不显示)
private String showModes; // 展现方式(0:有子栏目显示栏目列表,无子栏目显示内容列表;1:首栏目内容列表;2:栏目第一条内容)
private String allowComment;// 是否允许评论
private String isAudit; // 是否需要审核
private String customListView; // 自定义列表视图
private String customContentView; // 自定义内容视图
private String viewConfig; // 视图参数
private Date beginDate; // 开始时间
private Date endDate; // 结束时间
private String cnt;//信息量
private String hits;//点击量
private List<Category> childList = Lists.newArrayList(); // 拥有子分类列表
public Category(){
super();
this.module = "";
this.sort = 30;
this.inMenu = Global.HIDE;
this.inList = Global.SHOW;
this.showModes = "0";
this.allowComment = Global.NO;
this.delFlag = DEL_FLAG_NORMAL;
this.isAudit = Global.NO;
}
public Category(String id){
this();
this.id = id;
}
public Category(String id, Site site){
this();
this.id = id;
this.setSite(site);
}
public Site getSite() {
return site;
}
public String getHits() {
return hits;
}
public void setHits(String hits) {
this.hits = hits;
}
public void setSite(Site site) {
this.site = site;
}
public Office getOffice() {
return office;
}
public void setOffice(Office office) {
this.office = office;
}
// @JsonBackReference
// @NotNull
public Category getParent() {
return parent;
}
public void setParent(Category parent) {
this.parent = parent;
}
// @Length(min=1, max=255)
// public String getParentIds() {
// return parentIds;
// }
//
// public void setParentIds(String parentIds) {
// this.parentIds = parentIds;
// }
@Length(min=0, max=20)
public String getModule() {
return module;
}
public void setModule(String module) {
this.module = module;
}
// @Length(min=0, max=100)
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
@Length(min=0, max=255)
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
@Length(min=0, max=255)
public String getHref() {
return href;
}
public void setHref(String href) {
this.href = href;
}
@Length(min=0, max=20)
public String getTarget() {
return target;
}
public Date getBeginDate() {
return beginDate;
}
public void setBeginDate(Date beginDate) {
this.beginDate = beginDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
public void setTarget(String target) {
this.target = target;
}
@Length(min=0, max=255)
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Length(min=0, max=255)
public String getKeywords() {
return keywords;
}
public void setKeywords(String keywords) {
this.keywords = keywords;
}
// @NotNull
// public Integer getSort() {
// return sort;
// }
//
// public void setSort(Integer sort) {
// this.sort = sort;
// }
@Length(min=1, max=1)
public String getInMenu() {
return inMenu;
}
public void setInMenu(String inMenu) {
this.inMenu = inMenu;
}
@Length(min=1, max=1)
public String getInList() {
return inList;
}
public void setInList(String inList) {
this.inList = inList;
}
@Length(min=1, max=1)
public String getShowModes() {
return showModes;
}
public void setShowModes(String showModes) {
this.showModes = showModes;
}
@Length(min=1, max=1)
public String getAllowComment() {
return allowComment;
}
public void setAllowComment(String allowComment) {
this.allowComment = allowComment;
}
@Length(min=1, max=1)
public String getIsAudit() {
return isAudit;
}
public void setIsAudit(String isAudit) {
this.isAudit = isAudit;
}
public String getCustomListView() {
return customListView;
}
public void setCustomListView(String customListView) {
this.customListView = customListView;
}
public String getCustomContentView() {
return customContentView;
}
public void setCustomContentView(String customContentView) {
this.customContentView = customContentView;
}
public String getViewConfig() {
return viewConfig;
}
public void setViewConfig(String viewConfig) {
this.viewConfig = viewConfig;
}
public List<Category> getChildList() {
return childList;
}
public void setChildList(List<Category> childList) {
this.childList = childList;
}
public String getCnt() {
return cnt;
}
public void setCnt(String cnt) {
this.cnt = cnt;
}
public static void sortList(List<Category> list, List<Category> sourcelist, String parentId){
for (int i=0; i<sourcelist.size(); i++){
Category e = sourcelist.get(i);
if (e.getParent()!=null && e.getParent().getId()!=null
&& e.getParent().getId().equals(parentId)){
list.add(e);
// 判断是否还有子节点, 有则继续获取子节点
for (int j=0; j<sourcelist.size(); j++){
Category child = sourcelist.get(j);
if (child.getParent()!=null && child.getParent().getId()!=null
&& child.getParent().getId().equals(e.getId())){
sortList(list, sourcelist, e.getId());
break;
}
}
}
}
}
public String getIds() {
return (this.getParentIds() !=null ? this.getParentIds().replaceAll(",", " ") : "")
+ (this.getId() != null ? this.getId() : "");
}
public boolean isRoot(){
return isRoot(this.id);
}
public static boolean isRoot(String id){
return id != null && id.equals("1");
}
public String getUrl() {
return CmsUtils.getUrlDynamic(this);
}
}