From cae6e79d748d47fc80a6087915db14d229b3af9a Mon Sep 17 00:00:00 2001
From: DESKTOP-71BH0QO\L、ming <172680469@qq.com>
Date: 星期五, 09 四月 2021 12:31:49 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActQuestnaireServiceImpl.java |   55 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActQuestnaireServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActQuestnaireServiceImpl.java
index 492f210..46e90ac 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActQuestnaireServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActQuestnaireServiceImpl.java
@@ -1,5 +1,7 @@
 package com.panzhihua.service_community.service.impl;
 
+import java.util.Date;
+
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -20,7 +22,14 @@
 import com.panzhihua.service_community.model.dos.ComActQuestnaireSubDO;
 import com.panzhihua.service_community.model.dos.ComActQuestnaireSubSelectionDO;
 import com.panzhihua.service_community.service.ComActQuestnaireService;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
+import com.panzhihua.common.model.vos.community.ComActQuestnaireAnswerContentVO;
+import com.panzhihua.common.model.vos.community.ComActQuestnaireSubSelectionVO;
+import com.panzhihua.common.model.vos.community.ComActQuestnaireSubVO;
+import com.panzhihua.common.model.vos.community.ComActQuestnaireVO;
+import com.panzhihua.common.model.vos.community.questnaire.UsersAnswerVO;
+import com.panzhihua.common.model.vos.community.questnaire.UsersSubAnswerVO;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
@@ -150,10 +159,50 @@
     public R answerInfoQuestnaire(Long userId, Long questId) {
 
         ComActQuestnaireDO comActQuestnaireDO = questnaireDAO.selectById(questId);
+        if(comActQuestnaireDO==null){
+            return  R.fail("问卷不存在!");
+        }
 
-        List<ComActQuestnaireAnswerContentDO> questnaireAnswerContentDOList =
-                questnaireAnswerContentDAO.selectList(new QueryWrapper<ComActQuestnaireAnswerContentDO>().lambda().eq(ComActQuestnaireAnswerContentDO::getUserId, userId).eq(ComActQuestnaireAnswerContentDO::getSubId, questId));
+        UsersAnswerVO usersAnswerVO = new UsersAnswerVO();
+        ComActQuestnaireVO comActQuestnaireVO = new ComActQuestnaireVO();
+        BeanUtils.copyProperties(comActQuestnaireDO, comActQuestnaireVO);
+        usersAnswerVO.setQuestnaire(comActQuestnaireVO);
 
-        return null;
+        List<ComActQuestnaireSubDO> list = questnaireSubDAO.selectList(new QueryWrapper<ComActQuestnaireSubDO>().lambda().eq(ComActQuestnaireSubDO::getQueId, questId));
+        List<UsersSubAnswerVO> usersSubAnswerVOList = new ArrayList<>();
+
+        list.forEach(comActQuestnaireSubDO ->{
+            UsersSubAnswerVO usersSubAnswerVO = new UsersSubAnswerVO();
+            Long subId = comActQuestnaireSubDO.getId();
+            List<ComActQuestnaireSubSelectionDO> comActQuestnaireSubSelectionDOs =
+                    questnaireSubSelectionDAO.selectList(new QueryWrapper<ComActQuestnaireSubSelectionDO>().lambda().eq(ComActQuestnaireSubSelectionDO::getQueSubId, subId));
+
+
+            List<ComActQuestnaireSubSelectionVO> comActQuestnaireSubSelectionVOs = new ArrayList<>();
+            comActQuestnaireSubSelectionDOs.forEach(comActQuestnaireSubSelectionDO -> {
+                ComActQuestnaireSubSelectionVO comActQuestnaireSubSelectionVO = new ComActQuestnaireSubSelectionVO();
+                BeanUtils.copyProperties(comActQuestnaireSubSelectionDO, comActQuestnaireSubSelectionVO);
+                comActQuestnaireSubSelectionVOs.add(comActQuestnaireSubSelectionVO);
+            });
+            usersSubAnswerVO.setQuestSelectionList(comActQuestnaireSubSelectionVOs);
+            //用户回答
+            List<ComActQuestnaireAnswerContentDO> questnaireAnswerContentDOList =
+                    questnaireAnswerContentDAO.selectList(new QueryWrapper<ComActQuestnaireAnswerContentDO>().lambda().eq(ComActQuestnaireAnswerContentDO::getUserId, userId)
+                            .eq(ComActQuestnaireAnswerContentDO::getSubId, subId));
+
+            List<ComActQuestnaireAnswerContentVO> questnaireAnswerContentVOList = new ArrayList<>();
+            questnaireAnswerContentDOList.forEach(questnaireAnswerContentDO->{
+                ComActQuestnaireAnswerContentVO comActQuestnaireSubSelectionVO = new ComActQuestnaireAnswerContentVO();
+                BeanUtils.copyProperties(questnaireAnswerContentDO, comActQuestnaireSubSelectionVO);
+                questnaireAnswerContentVOList.add(comActQuestnaireSubSelectionVO);
+            });
+
+            usersSubAnswerVO.setUsersAnswer(questnaireAnswerContentVOList);
+            usersSubAnswerVOList.add(usersSubAnswerVO);
+            }
+        );
+        usersAnswerVO.setUsersSubAnswer(usersSubAnswerVOList);
+
+        return R.ok(usersAnswerVO);
     }
 }

--
Gitblit v1.7.1