LinkService.java
2.1 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
/**
* Copyright © 2015-2018 ODM All rights reserved.
*/
package com.thinkgem.jeesite.modules.cms.service;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.google.common.collect.Lists;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.common.utils.CacheUtils;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.cms.dao.LinkDao;
import com.thinkgem.jeesite.modules.cms.entity.Link;
/**
* 链接Service
* @author ThinkGem
* @version 2013-01-15
*/
@Service
@Transactional(readOnly = true)
public class LinkService extends CrudService<LinkDao, Link> {
@Transactional(readOnly = false)
public Page<Link> findPage(Page<Link> page, Link link, boolean isDataScopeFilter) {
// 更新过期的权重,间隔为“6”个小时
Date updateExpiredWeightDate = (Date)CacheUtils.get("updateExpiredWeightDateByLink");
if (updateExpiredWeightDate == null || (updateExpiredWeightDate != null
&& updateExpiredWeightDate.getTime() < new Date().getTime())){
dao.updateExpiredWeight(link);
CacheUtils.put("updateExpiredWeightDateByLink", DateUtils.addHours(new Date(), 6));
}
link.getSqlMap().put("dsf", dataScopeFilter(link.getCurrentUser(), "o", "u"));
return super.findPage(page, link);
}
@Transactional(readOnly = false)
public void delete(Link link, Boolean isRe) {
//dao.updateDelFlag(id, isRe!=null&&isRe?Link.DEL_FLAG_NORMAL:Link.DEL_FLAG_DELETE);
link.setDelFlag(isRe!=null&&isRe?Link.DEL_FLAG_NORMAL:Link.DEL_FLAG_DELETE);
dao.delete(link);
}
/**
* 通过编号获取内容标题
*/
public List<Object[]> findByIds(String ids) {
List<Object[]> list = Lists.newArrayList();
String[] idss = StringUtils.split(ids,",");
if (idss.length>0){
List<Link> l = dao.findByIdIn(idss);
for (Link e : l){
list.add(new Object[]{e.getId(),StringUtils.abbr(e.getTitle(),50)});
}
}
return list;
}
}