xiaoyong931011
2020-08-12 ec7480312a1d80354e695eab72eaa8b8fbc46dc4
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
package com.xcong.excoin.modules.helpCenter.service.impl;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
import javax.annotation.Resource;
import javax.validation.Valid;
 
import org.springframework.stereotype.Service;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xcong.excoin.common.response.Result;
import com.xcong.excoin.modules.helpCenter.dao.HelpCenterArticleDao;
import com.xcong.excoin.modules.helpCenter.dao.HelpCenterNoticeDao;
import com.xcong.excoin.modules.helpCenter.dto.ImportantNoticePageDto;
import com.xcong.excoin.modules.helpCenter.dto.NewNoticePageDto;
import com.xcong.excoin.modules.helpCenter.entity.HelpCenterArticleEntity;
import com.xcong.excoin.modules.helpCenter.entity.HelpCenterNoticeEntity;
import com.xcong.excoin.modules.helpCenter.service.HelpCenterService;
import com.xcong.excoin.modules.helpCenter.vo.ImportantNoticeVo;
import com.xcong.excoin.modules.helpCenter.vo.NewNoticeInfoVo;
import com.xcong.excoin.modules.helpCenter.vo.NoticeInfoVo;
 
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
 
@Slf4j
@Service
public class HelpCenterServiceImpl extends ServiceImpl<HelpCenterNoticeDao, HelpCenterNoticeEntity> implements HelpCenterService {
    
    @Resource
    private HelpCenterArticleDao helpCenterArticleDao;
    @Resource
    private HelpCenterNoticeDao helpCenterNoticeDao;
    
    @Override
    public Result getNewNoticeList(@Valid NewNoticePageDto newNoticePageDto) {
        
        List<NewNoticeInfoVo> arrayList = new ArrayList<>();
        Page<HelpCenterNoticeEntity> page = new Page<>(newNoticePageDto.getPageNum(), newNoticePageDto.getPageSize());
        //获取【帮助中心公告】
        HelpCenterNoticeEntity helpCenterNoticeEntity = new HelpCenterNoticeEntity();
        IPage<HelpCenterNoticeEntity> HelpCenterNoticeEntitys = helpCenterNoticeDao.getNewNoticeList(page, helpCenterNoticeEntity);
        List<HelpCenterNoticeEntity> records = HelpCenterNoticeEntitys.getRecords();
        if(CollUtil.isNotEmpty(records)) {
            for(HelpCenterNoticeEntity helpCenterNotice : records) {
                NewNoticeInfoVo newNoticeInfoVo = new NewNoticeInfoVo();
                Long id = helpCenterNotice.getId();
                newNoticeInfoVo.setId(id);
                String createBy = helpCenterNotice.getCreateBy();
                newNoticeInfoVo.setCreateBy(createBy);
                Date createTime = helpCenterNotice.getCreateTime();
                newNoticeInfoVo.setCreateTime(createTime);
                int articleNotice = helpCenterNotice.getArticleNotice();
                newNoticeInfoVo.setArticleNotice(articleNotice);
                
                int type = newNoticePageDto.getType();
                if(type == 2) {
                    Long articleIdUs = helpCenterNotice.getArticleIdUs();
                    newNoticeInfoVo.setArticleId(articleIdUs);
                    String articleTitleUs = helpCenterNotice.getArticleTitleUs();
                    newNoticeInfoVo.setArticleTitle(articleTitleUs);
                }else {
                    Long articleId = helpCenterNotice.getArticleId();
                    newNoticeInfoVo.setArticleId(articleId);
                    String articleTitle = helpCenterNotice.getArticleTitle();
                    newNoticeInfoVo.setArticleTitle(articleTitle);
                }
                arrayList.add(newNoticeInfoVo);
            }
        }
        return Result.ok(arrayList);
    }
 
    @Override
    public Result getImportantNoticeList(@Valid ImportantNoticePageDto importantNoticePageDto) {
        
        List<ImportantNoticeVo> arrayList = new ArrayList<>();
        Page<HelpCenterNoticeEntity> page = new Page<>(importantNoticePageDto.getPageNum(), importantNoticePageDto.getPageSize());
        //获取【帮助中心公告】
        HelpCenterNoticeEntity helpCenterNoticeEntity = new HelpCenterNoticeEntity();
        IPage<HelpCenterNoticeEntity> HelpCenterNoticeEntitys = helpCenterNoticeDao.getImportantNoticeList(page, helpCenterNoticeEntity);
        List<HelpCenterNoticeEntity> records = HelpCenterNoticeEntitys.getRecords();
        if(CollUtil.isNotEmpty(records)) {
            for(HelpCenterNoticeEntity helpCenterNotice : records) {
                ImportantNoticeVo noticeInfoVo = new ImportantNoticeVo();
                Long id = helpCenterNotice.getId();
                noticeInfoVo.setId(id);
                String createBy = helpCenterNotice.getCreateBy();
                noticeInfoVo.setCreateBy(createBy);
                Date createTime = helpCenterNotice.getCreateTime();
                noticeInfoVo.setCreateTime(createTime);
                int articleNotice = helpCenterNotice.getArticleNotice();
                noticeInfoVo.setArticleNotice(articleNotice);
                
                int type = importantNoticePageDto.getType();
                if(type == 2) {
                    Long articleIdUs = helpCenterNotice.getArticleIdUs();
                    noticeInfoVo.setArticleId(articleIdUs);
                    String articleTitleUs = helpCenterNotice.getArticleTitleUs();
                    noticeInfoVo.setArticleTitle(articleTitleUs);
                }else {
                    Long articleId = helpCenterNotice.getArticleId();
                    noticeInfoVo.setArticleId(articleId);
                    String articleTitle = helpCenterNotice.getArticleTitle();
                    noticeInfoVo.setArticleTitle(articleTitle);
                }
                arrayList.add(noticeInfoVo);
            }
        }
        return Result.ok(arrayList);
    }
 
    @Override
    public Result getNoticeInfo(long id) {
        
        HelpCenterArticleEntity helpCenterArticleEntity = helpCenterArticleDao.selectById(id);
        NoticeInfoVo noticeInfoVo = new NoticeInfoVo();
        if(ObjectUtil.isNotEmpty(helpCenterArticleEntity)) {
            String content = helpCenterArticleEntity.getContent();
            noticeInfoVo.setContent(content);
            String createBy = helpCenterArticleEntity.getCreateBy();
            noticeInfoVo.setCreateBy(createBy);
            Date createTime = helpCenterArticleEntity.getCreateTime();
            noticeInfoVo.setCreateTime(createTime);
            String title = helpCenterArticleEntity.getTitle();
            noticeInfoVo.setTitle(title);
            int typeLanguage = helpCenterArticleEntity.getTypeLanguage();
            noticeInfoVo.setTypeLanguage(typeLanguage);
            noticeInfoVo.setId(id);
        }
        return Result.ok(noticeInfoVo);
    }
 
 
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
 
}