b9411514
陈杰
first
|
1
2
3
4
5
6
|
package com.sincere.student.service.impl;
import com.github.pagehelper.PageHelper;
import com.sincere.student.dto.ArticleSearchDto;
import com.sincere.student.mapper.ArticleMapper;
import com.sincere.student.model.Article;
|
123dbb81
徐泉
研学代码提交
|
7
|
import com.sincere.student.service.ArticleService;
|
b9411514
陈杰
first
|
8
9
10
11
12
|
import com.sincere.student.utils.Page;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
|
123dbb81
徐泉
研学代码提交
|
13
|
import java.util.ArrayList;
|
b9411514
陈杰
first
|
14
|
import java.util.Arrays;
|
a79c5a75
陈杰
bug 修复
|
15
16
|
import java.util.LinkedList;
import java.util.List;
|
fafdccdc
陈杰
bug 修复
|
17
|
|
b9411514
陈杰
first
|
18
19
20
21
22
23
24
25
26
27
|
@Service
public class ArticleServiceImpl implements ArticleService {
@Autowired
ArticleMapper articleMapper;
@Override
public Page<Article> getList(ArticleSearchDto articleSearchDto) {
Page<Article> result = new Page<>(articleSearchDto.getPage(),articleSearchDto.getPageSize());
if(StringUtils.isNotBlank(articleSearchDto.getTitle())){
|
123dbb81
徐泉
研学代码提交
|
28
29
30
|
articleSearchDto.setTitle("%"+articleSearchDto.getTitle()+"%");
}
PageHelper.startPage(articleSearchDto.getPage(),articleSearchDto.getPageSize());
|
b9411514
陈杰
first
|
31
|
List<Article> list = articleMapper.getList(articleSearchDto) ;
|
123dbb81
徐泉
研学代码提交
|
32
33
34
|
for(Article article : list){
String[] urlList = article.getImageUrl().split(",");
article.setImageUrlList(Arrays.asList(urlList));
|
a79c5a75
陈杰
bug 修复
|
35
36
37
38
|
article.setImageCount(urlList.length);
}
List<Article> addAdvertList = new ArrayList<>();
for(int i = 0 ; i < list.size() ;i++){
|
fafdccdc
陈杰
bug 修复
|
39
|
addAdvertList.add(list.get(i));
|
123dbb81
徐泉
研学代码提交
|
40
|
if(i % 6 ==5){
|
fafdccdc
陈杰
bug 修复
|
41
|
try{
|
123dbb81
徐泉
研学代码提交
|
42
43
44
|
Article advert =articleMapper.getAdvert();
String[] urlList = advert.getImageUrl().split(",");
advert.setImageUrlList(Arrays.asList(urlList));
|
d7dac5d8
504987307@qq.com
1
|
45
46
47
48
|
advert.setImageCount(urlList.length);
addAdvertList.add(advert);
}catch (Exception e){
|
123dbb81
徐泉
研学代码提交
|
49
|
}
|
d7dac5d8
504987307@qq.com
1
|
50
51
|
}
}
|
fafdccdc
陈杰
bug 修复
|
52
53
54
|
result.setList(addAdvertList);
result.setCount(articleMapper.getListCount(articleSearchDto));
return result;
|
b9411514
陈杰
first
|
55
|
}
|
473605c5
陈杰
bug 修复
|
56
57
58
59
60
|
@Override
public Page<Article> getAdminList(ArticleSearchDto articleSearchDto) {
Page<Article> result = new Page<>(articleSearchDto.getPage(),articleSearchDto.getPageSize());
if(StringUtils.isNotBlank(articleSearchDto.getTitle())){
|
123dbb81
徐泉
研学代码提交
|
61
62
63
|
articleSearchDto.setTitle("%"+articleSearchDto.getTitle()+"%");
}
PageHelper.startPage(articleSearchDto.getPage(),articleSearchDto.getPageSize());
|
473605c5
陈杰
bug 修复
|
64
|
List<Article> list = articleMapper.getList(articleSearchDto) ;
|
123dbb81
徐泉
研学代码提交
|
65
66
67
|
for(Article article : list){
String[] urlList = article.getImageUrl().split(",");
article.setImageUrlList(Arrays.asList(urlList));
|
473605c5
陈杰
bug 修复
|
68
69
70
71
72
73
|
article.setImageCount(urlList.length);
}
result.setList(list);
result.setCount(articleMapper.getListCount(articleSearchDto));
return result;
}
|
b9411514
陈杰
first
|
74
75
76
77
78
79
80
81
82
83
|
@Override
public List<Article> getRelationList(int universityId) {
return articleMapper.getRelationList(universityId);
}
@Override
public Article selectById(int id) {
Article article = articleMapper.selectById(id);
String[] urlList = article.getImageUrl().split(",");
|
a79c5a75
陈杰
bug 修复
|
84
85
86
87
|
article.setImageUrlList(Arrays.asList(urlList));
article.setImageCount(urlList.length);
return article ;
}
|
123dbb81
徐泉
研学代码提交
|
88
|
|
b9411514
陈杰
first
|
89
90
91
92
|
@Override
public int create(Article article) {
if(article.getType() == 1){
article.setColumnType(0);
|
123dbb81
徐泉
研学代码提交
|
93
|
}
|
b9411514
陈杰
first
|
94
95
|
articleMapper.create(article);
return article.getId() ;
|
123dbb81
徐泉
研学代码提交
|
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
}
@Override
public int delete(int id) {
return articleMapper.delete(id);
}
@Override
public int update(Article article) {
if(article.getType() == 1){
article.setColumnType(0);
}
return articleMapper.update(article);
}
}
|
fafdccdc
陈杰
bug 修复
|
|
|
123dbb81
徐泉
研学代码提交
|
|
|
b9411514
陈杰
first
|
|
|
123dbb81
徐泉
研学代码提交
|
|
|
b9411514
陈杰
first
|
|
|
123dbb81
徐泉
研学代码提交
|
|
|
b9411514
陈杰
first
|
|
|