IndexServiceImpl.java
3.41 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
package com.server.web.common.service.Impl;
import com.server.web.common.mapper.TBaseBannerMapper;
import com.server.web.common.mapper.TBaseFirstClassMapper;
import com.server.web.common.mapping.CourseMapper;
import com.server.web.common.mapping.InformationMapper;
import com.server.web.common.model.TBaseBanner;
import com.server.web.common.model.TBaseBannerExample;
import com.server.web.common.model.TBaseFirstClass;
import com.server.web.common.model.TBaseFirstClassExample;
import com.server.web.common.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.*;
import static com.server.utils.ResultMapUtil.returnMap;
/**
* Created by weiwenfu@163.com on 2018/12/12 下午 3:05.
*/
@Service
public class IndexServiceImpl implements IndexService {
@Autowired
private TBaseBannerMapper tBaseBannerMapper;
@Autowired
private TBaseFirstClassMapper tBaseFirstClassMapper;
@Autowired
private InformationMapper informationMapper;
@Autowired
private CourseMapper courseMapper;
@Override
public Map<String, Object> banner() {
TBaseBannerExample tBaseBannerExample = new TBaseBannerExample();
tBaseBannerExample.createCriteria().andIsUpEqualTo(1).andIsDeleteEqualTo(0);
tBaseBannerExample.setOrderByClause(" weight desc ");
List<TBaseBanner> list = tBaseBannerMapper.selectByExample(tBaseBannerExample);
return returnMap("1", "", list);
}
/**
* 首页分类
*
* @return
*/
@Override
public Map<String, Object> categoryList() {
TBaseFirstClassExample tBaseFirstClassExample = new TBaseFirstClassExample();
tBaseFirstClassExample.setOrderByClause(" weight desc");
tBaseFirstClassExample.createCriteria().andStatusEqualTo(1);
List<TBaseFirstClass> list = tBaseFirstClassMapper.selectByExample(tBaseFirstClassExample);
return returnMap("1", "", list);
}
/**
* 首页分类+两条资讯
*
* @return
*/
@Override
public Map<String, Object> categoryDetail() {
TBaseFirstClassExample tBaseFirstClassExample = new TBaseFirstClassExample();
tBaseFirstClassExample.setOrderByClause(" weight desc");
tBaseFirstClassExample.createCriteria().andStatusEqualTo(1);
List<TBaseFirstClass> list = tBaseFirstClassMapper.selectByExample(tBaseFirstClassExample);
List<Map<String, Object>> resultList = new ArrayList<>();
Map<String, Object> flagMap = null;
for (TBaseFirstClass tBaseFirstClass : list) {
flagMap = new HashMap<String, Object>();
flagMap.put("className", tBaseFirstClass.getClassName());
flagMap.put("id", tBaseFirstClass.getId());
List<Map<String, Object>> list2 = informationMapper.categoryDetail(tBaseFirstClass.getId());
flagMap.put("informationList", list2);
resultList.add(flagMap);
}
return returnMap("1", "", resultList);
}
@Override
public Map<String, Object> livingCourseToday() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Map<String, Object> param = new HashMap<>();
param.put("today", simpleDateFormat.format(new Date()));
List<Map<String, Object>> list = courseMapper.livingCourseToday(param);
return returnMap("1", "", list);
}
}