puzhibing
2023-07-12 aa43a92c7ec9053dbaef92fe5ccb3011b670442c
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
package com.dsh.account.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsh.account.entity.StudentHonor;
import com.dsh.account.feignclient.other.HonorDeClient;
import com.dsh.account.mapper.StudentHonorMapper;
import com.dsh.account.model.vo.medalDetail.GongVo;
import com.dsh.account.model.vo.medalDetail.StuMedalVo;
import com.dsh.account.service.StudentHonorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 学员-荣耀中间表 服务实现类
 * </p>
 *
 * @author jqs
 * @since 2023-07-04
 */
@Service
public class StudentHonorServiceImpl extends ServiceImpl<StudentHonorMapper, StudentHonor> implements StudentHonorService {
 
 
    @Autowired
    private HonorDeClient honorDeClient;
 
    @Override
    public List<GongVo> queryStuOfMedalData(Integer stuId) {
        List<GongVo> voList = new ArrayList<>();
        List<StudentHonor> studentHonors = this.baseMapper.selectList(new QueryWrapper<StudentHonor>()
                .eq("stuId", stuId));
        if (studentHonors.size() > 0){
            studentHonors.forEach( stuoHo -> {
                GongVo vo = new GongVo();
                vo.setMedalType(stuoHo.getHonorType());
                switch (stuoHo.getHonorType()){
                    case 1:
                        vo.setMedalName("俱乐部之星");
                        break;
                    case 2:
                        vo.setMedalName("运动达人");
                        break;
                    case 3:
                        vo.setMedalName("社区之王");
                        break;
                    case 4:
                        vo.setMedalName("深度玩家");
                        break;
                    default:
                        break;
                }
                voList.add(vo);
            });
        }
        return voList;
    }
 
    @Override
    public List<StuMedalVo> queryHonorDetails(Integer stuId) {
        List<StudentHonor> studentHonors = this.baseMapper.selectList(new QueryWrapper<StudentHonor>()
                .in("stuId",stuId));
        List<Integer> collect = studentHonors.stream().map(StudentHonor::getStuId).collect(Collectors.toList());
        return honorDeClient.getStuHonors(collect);
    }
}