963ee11f6e64fd4fe4d28841b06bcd0aaa9be6a2.svn-base
3.34 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
/**
* Copyright © 2015-2018 ODM All rights reserved.
*/
package com.thinkgem.jeesite.modules.cms.service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.modules.cms.dao.GuestbookDao;
import com.thinkgem.jeesite.modules.cms.entity.Guestbook;
/**
* 留言Service
* @author ThinkGem
* @version 2013-01-15
*/
@Service
@Transactional(readOnly = true)
public class GuestbookService extends CrudService<GuestbookDao, Guestbook> {
public Guestbook get(String id) {
return dao.get(id);
}
public Page<Guestbook> findPage(Page<Guestbook> page, Guestbook guestbook) {
// DetachedCriteria dc = dao.createDetachedCriteria();
// if (StringUtils.isNotEmpty(guestbook.getType())){
// dc.add(Restrictions.eq("type", guestbook.getType()));
// }
// if (StringUtils.isNotEmpty(guestbook.getContent())){
// dc.add(Restrictions.like("content", "%"+guestbook.getContent()+"%"));
// }
// dc.add(Restrictions.eq(Guestbook.FIELD_DEL_FLAG, guestbook.getDelFlag()));
// dc.addOrder(Order.desc("createDate"));
// return dao.find(page, dc);
guestbook.getSqlMap().put("dsf", dataScopeFilter(guestbook.getCurrentUser(), "o", "u"));
guestbook.setPage(page);
page.setList(dao.findList(guestbook));
return page;
}
@Transactional(readOnly = false)
public void delete(Guestbook guestbook, Boolean isRe) {
//dao.updateDelFlag(id, isRe!=null&&isRe?Guestbook.DEL_FLAG_AUDIT:Guestbook.DEL_FLAG_DELETE);
dao.delete(guestbook);
}
/**
* 更新索引
*/
public void createIndex(){
//dao.createIndex();
}
/**
* 全文检索
*/
//FIXME 暂不提供
public Page<Guestbook> search(Page<Guestbook> page, String q, String beginDate, String endDate){
// 设置查询条件
// BooleanQuery query = dao.getFullTextQuery(q, "name","content","reContent");
//
// // 设置过滤条件
// List<BooleanClause> bcList = Lists.newArrayList();
//
// bcList.add(new BooleanClause(new TermQuery(new Term(Guestbook.FIELD_DEL_FLAG, Guestbook.DEL_FLAG_NORMAL)), Occur.MUST));
//
// if (StringUtils.isNotBlank(beginDate) && StringUtils.isNotBlank(endDate)) {
// bcList.add(new BooleanClause(new TermRangeQuery("createDate", beginDate.replaceAll("-", ""),
// endDate.replaceAll("-", ""), true, true), Occur.MUST));
// }
//
// bcList.add(new BooleanClause(new TermQuery(new Term("type", "1")), Occur.SHOULD));
// bcList.add(new BooleanClause(new TermQuery(new Term("type", "2")), Occur.SHOULD));
// bcList.add(new BooleanClause(new TermQuery(new Term("type", "3")), Occur.SHOULD));
// bcList.add(new BooleanClause(new TermQuery(new Term("type", "4")), Occur.SHOULD));
//
// BooleanQuery queryFilter = dao.getFullTextQuery((BooleanClause[])bcList.toArray(new BooleanClause[bcList.size()]));
//
// System.out.println(queryFilter);
//
// // 设置排序(默认相识度排序)
// Sort sort = null;//new Sort(new SortField("updateDate", SortField.DOC, true));
// // 全文检索
// dao.search(page, query, queryFilter, sort);
// // 关键字高亮
// dao.keywordsHighlight(query, page.getList(), 30, "name");
// dao.keywordsHighlight(query, page.getList(), 1300, "content");
// dao.keywordsHighlight(query, page.getList(), 1300, "reContent");
return page;
}
}