xiaoyong931011
2020-08-14 c3392f5f16d3258f38170640a02fb3449ab09e2b
src/main/java/com/xcong/excoin/modules/helpCenter/service/impl/HelpCenterServiceImpl.java
@@ -2,7 +2,9 @@
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;
@@ -15,13 +17,18 @@
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;
@@ -36,6 +43,8 @@
    private HelpCenterArticleDao helpCenterArticleDao;
   @Resource
    private HelpCenterNoticeDao helpCenterNoticeDao;
   @Resource
   private HelpCenterTypeDao helpCenterTypeDao;
   
   @Override
   public Result getNewNoticeList(@Valid NewNoticePageDto newNoticePageDto) {
@@ -136,6 +145,76 @@
      return Result.ok(noticeInfoVo);
   }
   @Override
   public Result getNewNoticeTypeList(@Valid NewNoticeTypePageDto newNoticeTypePageDto) {
      List<NewNoticeTypeInfoVo> arrayList = new ArrayList<>();
        Page<HelpCenterTypeEntity> page = new Page<>(newNoticeTypePageDto.getPageNum(), newNoticeTypePageDto.getPageSize());
        //获取【类别】
        HelpCenterTypeEntity helpCenterTypeEntity = new HelpCenterTypeEntity();
        IPage<HelpCenterTypeEntity> helpCenterTypeEntitys = helpCenterTypeDao.getNoticeTypeList(page, helpCenterTypeEntity);
        List<HelpCenterTypeEntity> 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<NewNoticeInfoVo> 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<String, Object> columnMap = new HashMap<String, Object>();
         columnMap.put("article_notice", type);
         List<HelpCenterNoticeEntity> 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);
               }
            }
         }
      }
      return Result.ok(arrayList);
   }