admin
2021-01-04 aa6ef62aef83e277d4171df1d9f0803f91738216
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
package com.newvideo.service.imp;
 
import java.util.List;
 
import javax.annotation.Resource;
 
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
 
import com.newvideo.dao.ShareContentDao;
import com.newvideo.domain.ShareContent;
import com.newvideo.util.Constant;
 
@Service
public class ShareService {
    @Resource
    private ShareContentDao shareContentDao;
 
    public ShareContentDao getShareContentDao() {
        return shareContentDao;
    }
 
    public void setShareContentDao(ShareContentDao shareContentDao) {
        this.shareContentDao = shareContentDao;
    }
 
    /**
     * 添加分享内容
     * 
     * @param sc
     */
    public void addShareContent(ShareContent sc) {
        shareContentDao.create(sc);
    }
 
    public void updateShareContent(ShareContent sc) {
        shareContentDao.update(sc);
    }
 
    /**
     * 获取分享内容
     * 
     * @param id
     * @return
     */
    public ShareContent getShareContentById(String id) {
        return shareContentDao.find(ShareContent.class, id);
    }
 
    public List<ShareContent> getShareContentList(String key, int page) {
        return shareContentDao.list("from ShareContent sc where sc.detailSystem.appName like ?",
                (page - 1) * Constant.pageCount, Constant.pageCount, new String[] { "%" + key + "%" });
    }
 
    public long getShareContentListCount(String key) {
        return shareContentDao.getCount("select count(*)  from ShareContent sc where sc.detailSystem.appName like ?",
                new String[] { "%" + key + "%" });
    }
 
    public void deleteShareContent(ShareContent sc) {
        shareContentDao.delete(sc);
    }
 
    @Cacheable(value="userCache",key="'getShareContent'+'-'+#detailSystem")
    public ShareContent getShareContent(String detailSystem) {
        List<ShareContent> list = shareContentDao.list("from ShareContent sc where sc.detailSystem.id=" + detailSystem);
        if (list != null && list.size() > 0) {
            return list.get(0);
        }
        return null;
    }
 
}