package com.xcong.excoin.modules.helpCenter.service.impl; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; 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.dao.HelpCenterTypeDao; import com.xcong.excoin.modules.helpCenter.dto.ImportantNoticePageDto; import com.xcong.excoin.modules.helpCenter.dto.NewNoticePageDto; import com.xcong.excoin.modules.helpCenter.dto.NewNoticeTypePageDto; import com.xcong.excoin.modules.helpCenter.dto.NoticePageDto; import com.xcong.excoin.modules.helpCenter.entity.HelpCenterArticleEntity; import com.xcong.excoin.modules.helpCenter.entity.HelpCenterNoticeEntity; import com.xcong.excoin.modules.helpCenter.entity.HelpCenterTypeEntity; 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.NewNoticeTypeInfoVo; 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; @Resource private HelpCenterTypeDao helpCenterTypeDao; @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); } @Override public Result getNewNoticeTypeList(@Valid NewNoticeTypePageDto newNoticeTypePageDto) { List arrayList = new ArrayList<>(); Page page = new Page<>(newNoticeTypePageDto.getPageNum(), newNoticeTypePageDto.getPageSize()); //获取【类别】 HelpCenterTypeEntity helpCenterTypeEntity = new HelpCenterTypeEntity(); IPage helpCenterTypeEntitys = helpCenterTypeDao.getNoticeTypeList(page, helpCenterTypeEntity); List records = helpCenterTypeEntitys.getRecords(); if(CollUtil.isNotEmpty(records)) { for(HelpCenterTypeEntity helpCenterType : records) { NewNoticeTypeInfoVo noticeInfoVo = new NewNoticeTypeInfoVo(); Long id = helpCenterType.getId(); noticeInfoVo.setId(id); int type = newNoticeTypePageDto.getType(); if(type == 2) { String contentUs = helpCenterType.getContentUs(); noticeInfoVo.setContent(contentUs); }else { String content = helpCenterType.getContent(); noticeInfoVo.setContent(content); } arrayList.add(noticeInfoVo); } } return Result.ok(arrayList); } @Override public Result getNoticeList(@Valid NoticePageDto noticePageDto) { List arrayList = new ArrayList<>(); int noticeType = noticePageDto.getType(); //获取【类别】数据 Long id = noticePageDto.getId(); HelpCenterTypeEntity helpCenterTypeEntity = helpCenterTypeDao.selectById(id); if(ObjectUtil.isNotEmpty(helpCenterTypeEntity)) { int type = helpCenterTypeEntity.getType(); //获取对应的【帮助中心公告】 Map columnMap = new HashMap(); columnMap.put("article_notice", type); List helpCenterNoticeEntitys = helpCenterNoticeDao.selectByMap(columnMap); if(CollUtil.isNotEmpty(helpCenterNoticeEntitys)) { for(HelpCenterNoticeEntity helpCenterNoticeEntity : helpCenterNoticeEntitys) { NewNoticeInfoVo newNoticeInfoVo = new NewNoticeInfoVo(); Long noticeId = helpCenterNoticeEntity.getId(); newNoticeInfoVo.setId(noticeId); String createBy = helpCenterNoticeEntity.getCreateBy(); newNoticeInfoVo.setCreateBy(createBy); Date createTime = helpCenterNoticeEntity.getCreateTime(); newNoticeInfoVo.setCreateTime(createTime); if(noticeType == 2) { Long articleIdUs = helpCenterNoticeEntity.getArticleIdUs(); newNoticeInfoVo.setArticleId(articleIdUs); String articleTitle = helpCenterNoticeEntity.getArticleTitleUs(); newNoticeInfoVo.setArticleTitle(articleTitle); }else { Long articleId = helpCenterNoticeEntity.getArticleId(); newNoticeInfoVo.setArticleId(articleId); String articleTitle = helpCenterNoticeEntity.getArticleTitle(); helpCenterNoticeEntity.getArticleTitle(); newNoticeInfoVo.setArticleTitle(articleTitle); } arrayList.add(newNoticeInfoVo); } } } return Result.ok(arrayList); } @Override public Result getAboutUs() { NoticeInfoVo noticeInfoVo = new NoticeInfoVo(); HelpCenterArticleEntity selectById = helpCenterArticleDao.selectById(27); if(ObjectUtil.isNotEmpty(selectById)) { String createBy = selectById.getCreateBy(); noticeInfoVo.setCreateBy(createBy); String content = selectById.getContent(); noticeInfoVo.setContent(content); Date createTime = selectById.getCreateTime(); noticeInfoVo.setCreateTime(createTime); String title = selectById.getTitle(); noticeInfoVo.setTitle(title); int typeLanguage = selectById.getTypeLanguage(); noticeInfoVo.setTypeLanguage(typeLanguage); Long id = selectById.getId(); noticeInfoVo.setId(id); } return Result.ok(noticeInfoVo); } @Override public Result getUserAgreement() { NoticeInfoVo noticeInfoVo = new NoticeInfoVo(); HelpCenterArticleEntity selectById = helpCenterArticleDao.selectById(29); if(ObjectUtil.isNotEmpty(selectById)) { String createBy = selectById.getCreateBy(); noticeInfoVo.setCreateBy(createBy); String content = selectById.getContent(); noticeInfoVo.setContent(content); Date createTime = selectById.getCreateTime(); noticeInfoVo.setCreateTime(createTime); String title = selectById.getTitle(); noticeInfoVo.setTitle(title); int typeLanguage = selectById.getTypeLanguage(); noticeInfoVo.setTypeLanguage(typeLanguage); Long id = selectById.getId(); noticeInfoVo.setId(id); } return Result.ok(noticeInfoVo); } @Override public Result getFristNewNoticeList(@Valid NewNoticePageDto newNoticePageDto) { List arrayList = new ArrayList<>(); Page page = new Page<>(1, 5); //获取【帮助中心公告】 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); } }