huanghongfa
2021-08-26 3adb33652e097365ced4bdb58c31fce476b244fb
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
package com.panzhihua.service_community.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panzhihua.common.model.dtos.community.QuestnaireAnswersDTO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.ComActQuestnaireAnswerContentVO;
import com.panzhihua.common.model.vos.community.ComActQuestnaireSubVO;
import com.panzhihua.service_community.dao.ComActReserveAnswerContentMapper;
import com.panzhihua.service_community.dao.ComActReserveSubMapper;
import com.panzhihua.service_community.model.dos.ComActQuestnaireAnswerContentDO;
import com.panzhihua.service_community.model.dos.ComActQuestnaireSubDO;
import com.panzhihua.service_community.model.dos.ComActReserveAnswerContentDO;
import com.panzhihua.service_community.model.dos.ComActReserveSubDO;
import com.panzhihua.service_community.service.ComActReserveAnswerContentService;
import com.panzhihua.service_community.service.ComActReserveSubService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
 
/**
 * @auther lyq
 * @create 2021-08-23 10:33:32
 * @describe 预约登记回答记录内容 服务实现类
 */
@Slf4j
@Service
public class ComActReserveAnswerContentServiceImpl extends ServiceImpl<ComActReserveAnswerContentMapper, ComActReserveAnswerContentDO> implements ComActReserveAnswerContentService {
 
    @Resource
    private ComActReserveSubMapper comActReserveSubMapper;
 
    @Override
    public R exportRegisterAdmin(Long reserveId){
        QuestnaireAnswersDTO result = new QuestnaireAnswersDTO();
 
        //查询题目
        List<ComActReserveSubDO> list = comActReserveSubMapper.selectList(new QueryWrapper<ComActReserveSubDO>().lambda().eq(ComActReserveSubDO::getReserveId, reserveId));
        List<ComActQuestnaireSubVO> listSubVo = new ArrayList<>();
        list.forEach(subDo -> {
            ComActQuestnaireSubVO comActQuestnaireSubVO = new ComActQuestnaireSubVO();
            BeanUtils.copyProperties(subDo, comActQuestnaireSubVO);
            listSubVo.add(comActQuestnaireSubVO);
        });
        result.setSubs(listSubVo);
 
        //查询用户回答
        List<ComActReserveAnswerContentDO> questnaireAnswerContentDOList = this.baseMapper.selectListByReserve(reserveId);
        List<ComActQuestnaireAnswerContentVO> vos = new ArrayList<>();
        questnaireAnswerContentDOList.forEach(dos -> {
            ComActQuestnaireAnswerContentVO vo = new ComActQuestnaireAnswerContentVO();
            BeanUtils.copyProperties(dos, vo);
            vos.add(vo);
        });
        result.setAnswers(vos);
        return R.ok(result);
    }
}