派生自 projectDept/qhighschool

dengqingliu
2022-12-02 e271aeca561a4f7f45ad9f6780030d436bb95c1f
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
package com.qxueyou.scc.portal.homepage.serivce.imp;
 
//import com.qxueyou.appraisal.web.homepage.dao.AppraisalBatchDao;
 
//import com.qxueyou.appraisal.web.homepage.dao.ArticleDao;
//import com.qxueyou.appraisal.web.homepage.dao.ContestsBatchDao;
//import com.qxueyou.appraisal.web.homepage.dao.OccupationDao;
//import com.qxueyou.appraisal.web.homepage.serivce.IHomepageService;
//import com.qxueyou.entity.article.ArticleDO;
//import com.qxueyou.util.CollectionUtils;
import com.qxueyou.scc.base.util.CollectionUtils;
import com.qxueyou.scc.portal.homepage.dao.ArticleDao;
import com.qxueyou.scc.portal.homepage.serivce.IHomepageService;
import com.qxueyou.scc.portal.information.model.Information;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * @author ZERO 2021-03-03 09:16
 */
@Service
public class HomepageService implements IHomepageService {
 
    @Autowired
    private ArticleDao articleDao;
 
//    @Autowired
//    private AppraisalBatchDao batchDao;
 
//    @Autowired
//    private ContestsBatchDao batchDao;
 
//    @Autowired
//    private OccupationDao occupationDao;
 
    /**
     * 获取首页数据
     */
//    @Override
//    public Map<String, Object> getIndexDetail() {
////        System.err.println("================>获取首页数据");
//        return CollectionUtils.newObjectMap(
//                "appraisalBatchInfo", batchDao.findBatches(1, 24, null).get("data"), // createTime  browseCount dateTime
//                "occupationInfo", articleDao.findPage(CollectionUtils.newObjectMap("type", "qualifiedSet", "status", ArticleDO.UP_STATUS), 1, 8, "dateTime", Sort.Direction.DESC).get("data"),
//                "news", articleDao.findPage(CollectionUtils.newObjectMap("type", "policiesRegulations", "status", ArticleDO.UP_STATUS), 1, 8, "dateTime", Sort.Direction.DESC).get("data"));
//    }
 
 
    /**
     * 获取首页标签
     */
    @Override
    public List<Map<String, Object>> getTabs() {
 
        boolean exist;
        List<Map<String, Object>> tabs = new ArrayList<>();
 
        List<Map<String,String>> sub=new ArrayList<>();
 
 
        exist = articleDao.exist("examBriefing");
        if (exist) tabs.add(CollectionUtils.newObjectMap("name", "媒体聚焦", "type", "examBriefing","list",sub));
 
        exist = articleDao.exist("qualifiedSet");
        if (exist) tabs.add(CollectionUtils.newObjectMap("name", "华教新鲜事", "type", "qualifiedSet"));
 
        exist = articleDao.exist("policiesRegulations");
        if (exist) tabs.add(CollectionUtils.newObjectMap("name", "新闻中心", "type", "policiesRegulations"));
 
        exist = articleDao.exist("examinationGuide");
        if (exist) tabs.add(CollectionUtils.newObjectMap("name", "专家风采", "type", "examinationGuide"));
 
        exist = articleDao.exist("popularInformation");
        if (exist) tabs.add(CollectionUtils.newObjectMap("name", "联系我们", "type", "popularInformation"));
 
        exist =articleDao.existsubColumn("examBriefing","introduce");
        if(exist) sub.add(CollectionUtils.newStringMap("name", "海外资讯", "subColumn", "introduce") );
 
        exist =articleDao.existsubColumn("examBriefing","contestFile");
        if(exist) sub.add(CollectionUtils.newStringMap("name", "海外资讯", "subColumn", "contestFile"));
 
        exist =articleDao.existsubColumn("examBriefing","previousContest");
        if(exist) sub.add(CollectionUtils.newStringMap("name", "往届大赛", "subColumn", "previousContest"));
 
        return tabs;
    }
 
    /**
     * 获取文章列表
     */
    @Override
    public Map<String, Object> getArticle(String type,String subColumn,String numbers,int page, int size, String keyword) {
        return articleDao.moreOccupation(type,subColumn,numbers,page, size, keyword);
    }
 
 
    /**
     * @param id
     * @return
     */
 
    @Override
    public Map<String, Object> getArticleDetail(String id) {
 
        //inc浏览数
        articleDao.incBrowseCount(id);
 
        Information article = articleDao.read(Information.class,id);
 
        Map<String, Object> data = CollectionUtils.newObjectMap(
                "title", article.getTitle(),
                "dateTime", article.getDateTime(),
                "browseCount", article.getBrowseCount(),
                "content", article.getContent(),
                "attachment", article.getAttachment());
 
        Map<String, Object> preAndBehindArticle = articleDao.getPreAndBehindArticle(id, article.getType());
 
 
        data.putAll(preAndBehindArticle);
 
        return data;
    }
 
    public Information getArticlesType(String type,String subColumn) {
        Information articleDO=articleDao.getArticle(type,subColumn);
        return articleDO;
    }
 
    @Override
    public Map<String, Object> getVideo(String type, String subColumn, int page, int size) {
        return articleDao.getVideoList(type,subColumn,page, size);
    }
}