cb3c219ae5b3df507729bcd13aa2ea12bbe5acae.svn-base
1.86 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
/**
* Copyright © 2015-2018 ODM All rights reserved.
*/
package com.thinkgem.jeesite.modules.cms.service;
import org.apache.commons.lang3.StringEscapeUtils;
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.SiteDao;
import com.thinkgem.jeesite.modules.cms.entity.Site;
import com.thinkgem.jeesite.modules.cms.utils.CmsUtils;
/**
* 站点Service
* @author ThinkGem
* @version 2013-01-15
*/
@Service
@Transactional(readOnly = true)
public class SiteService extends CrudService<SiteDao, Site> {
public Page<Site> findPage(Page<Site> page, Site site) {
// DetachedCriteria dc = siteDao.createDetachedCriteria();
// if (StringUtils.isNotEmpty(site.getName())){
// dc.add(Restrictions.like("name", "%"+site.getName()+"%"));
// }
// dc.add(Restrictions.eq(Site.FIELD_DEL_FLAG, site.getDelFlag()));
// //dc.addOrder(Order.asc("id"));
// return siteDao.find(page, dc);
site.getSqlMap().put("site", dataScopeFilter(site.getCurrentUser(), "o", "u"));
return super.findPage(page, site);
}
@Transactional(readOnly = false)
public void save(Site site) {
if (site.getCopyright()!=null){
site.setCopyright(StringEscapeUtils.unescapeHtml4(site.getCopyright()));
}
super.save(site);
CmsUtils.removeCache("site_"+site.getId());
CmsUtils.removeCache("siteList");
}
@Transactional(readOnly = false)
public void delete(Site site, Boolean isRe) {
//siteDao.updateDelFlag(id, isRe!=null&&isRe?Site.DEL_FLAG_NORMAL:Site.DEL_FLAG_DELETE);
site.setDelFlag(isRe!=null&&isRe?Site.DEL_FLAG_NORMAL:Site.DEL_FLAG_DELETE);
super.delete(site);
//siteDao.delete(id);
CmsUtils.removeCache("site_"+site.getId());
CmsUtils.removeCache("siteList");
}
}