linzhijie
2021-04-12 c632636e2f5b4188b430f5efc9d9f68c8dbe3d6d
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package com.ots.project.exam.restcontroller;
import com.ots.project.exam.domain.EntDemographyInfo;
import com.ots.project.exam.domain.EntDemographyParam;
import com.ots.project.exam.domain.EntTestMember;
import com.ots.project.exam.dto.DictItemDto;
import com.ots.project.exam.dto.ParamDefine;
import com.ots.project.exam.dto.ParamsInfo;
import com.ots.project.exam.dto.RestResponse;
import com.ots.project.exam.service.IEntDemographyParamService;
import com.ots.project.exam.service.IEntTestMemberService;
import com.ots.project.exam.service.ITReportTemplateService;
import com.ots.project.exam.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
@RestController
public class MemberControllerImpl implements MemberController {
    @Autowired
    private MemberService memberService;
    @Autowired
    private IEntTestMemberService entTestMemberService;
    @Autowired
    IEntDemographyParamService entDemographyParamService;
    @Autowired
    private ITReportTemplateService itReportTemplateService;
    @Override
    public RestResponse getdemographyParam(String token, String lang) {
        try {
            List<ParamDefine> collect = memberService.getParamDefines(token, lang);
            
            getMemberNameValue(collect);
            return RestResponse.ok(collect);
        } catch (Exception ex) {
            return RestResponse.fail(ex);
        }
    }
    private void getMemberNameValue(List<ParamDefine> collect) {
        EntTestMember entTestMember = entTestMemberService.selectEntTestMemberById(collect.get(0).getMemberId());
        String  paramIds = collect.stream().map(it -> {
            return it.getParamId().toString();
        }).collect(Collectors.joining(","));
        List<EntDemographyParam> entDemographyParams = entDemographyParamService.selectEntDemographyParamListByParamIn(paramIds);
        Map<Long, String> entDemographyParamsMap = entDemographyParams.stream().collect(
                Collectors.toMap(EntDemographyParam::getParamId, EntDemographyParam::getParamCode));
        for (ParamDefine paramDefine : collect) {
            System.out.println(entDemographyParamsMap.get(paramDefine.getParamId()));
            if (Objects.equals(entDemographyParamsMap.get(paramDefine.getParamId()), "name")) {
                paramDefine.setParamValue(entTestMember.getMemberName());
            }
        }
    }
    @Override
    public RestResponse queryDemographyParamInfo(String token) {
        try {
            List<EntDemographyInfo> resluts = memberService.queryDemographyParamInfo(token);
            return RestResponse.ok(resluts);
        } catch (Exception ex) {
            return RestResponse.fail(ex);
        }
    }
    @Override
    public RestResponse saveDemographyParamInfo(@Valid List<ParamsInfo> infos, String token, String langType) {
        try {
            memberService.saveDemographyParamInfo(token, infos, langType);
            return RestResponse.ok();
        } catch (Exception ex) {
            return RestResponse.fail(ex);
        }
    }
    @Override
    public RestResponse memberAuth(String token) {
        try {
            return RestResponse.ok();
        } catch (Exception ex) {
            return RestResponse.fail(ex);
        }
    }
    @Override
    public RestResponse queryLangList(String token, String reportTemplateId) {
        try {
            List<DictItemDto> resluts = memberService.queryLang(token);
            
 
 
 
 
 
 
 
 
 
 
 
 
 
            return RestResponse.ok(resluts);
        } catch (Exception ex) {
            return RestResponse.fail(ex);
        }
    }
}