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 implements HelpCenterService { @Resource private HelpCenterArticleDao helpCenterArticleDao; @Resource private HelpCenterNoticeDao helpCenterNoticeDao; @Override public Result getNewNoticeList(@Valid NewNoticePageDto newNoticePageDto) { List arrayList = new ArrayList<>(); Page page = new Page<>(newNoticePageDto.getPageNum(), newNoticePageDto.getPageSize()); //获取【帮助中心公告】 HelpCenterNoticeEntity helpCenterNoticeEntity = new HelpCenterNoticeEntity(); IPage HelpCenterNoticeEntitys = helpCenterNoticeDao.getNewNoticeList(page, helpCenterNoticeEntity); List 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 arrayList = new ArrayList<>(); Page page = new Page<>(importantNoticePageDto.getPageNum(), importantNoticePageDto.getPageSize()); //获取【帮助中心公告】 HelpCenterNoticeEntity helpCenterNoticeEntity = new HelpCenterNoticeEntity(); IPage HelpCenterNoticeEntitys = helpCenterNoticeDao.getImportantNoticeList(page, helpCenterNoticeEntity); List 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); } }