puzhibing
2023-07-17 f195cf48cf57635c8848b2bc32afd4541c4090ed
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
package com.dsh.other.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dsh.other.entity.HonorRules;
import com.dsh.other.feignclient.model.StuMedalVo;
import com.dsh.other.service.HonorRulesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
 
@RestController
@RequestMapping("")
public class HonorController {
 
    @Autowired
    private HonorRulesService hrService;
 
 
    @PostMapping("/base/honor/stuHonors")
    public List<StuMedalVo> getStuHonors(@RequestBody List<Integer> honorIds){
        List<StuMedalVo> stuMedalVos = new ArrayList<>();
        List<HonorRules> honorRules = hrService.list(new QueryWrapper<HonorRules>()
                .in("id", honorIds));
        if (honorRules.size() > 0){
            honorRules.forEach(hrs -> {
                StuMedalVo stuMedalVo = new StuMedalVo();
                stuMedalVo.setLevelNum(Integer.getInteger(hrs.getLevel()));
                switch (hrs.getType()){
                    case 1:
                        stuMedalVo.setMedalName("俱乐部之星");
                        break;
                    case 2:
                        stuMedalVo.setMedalName("运动达人");
                        break;
                    case 3:
                        stuMedalVo.setMedalName("社区之王");
                        break;
                    case 4:
                        stuMedalVo.setMedalName("深度玩家");
                        break;
                    default:
                        break;
                }
                if (!Objects.equals(hrs.getLevel(), "10")){
                    stuMedalVo.setNextLevel(Integer.parseInt(hrs.getLevel())+1);
                    stuMedalVo.setUpgradeConditions(hrs.getCondition());
                    stuMedalVo.setIsTopLevel(2);
                }else {
                    stuMedalVo.setIsTopLevel(1);
                }
                stuMedalVos.add(stuMedalVo);
            });
        }
 
        return stuMedalVos;
    }
 
 
}