无关风月
2025-01-21 8f2abbbda6c87c59d0c2c5da9979e78ea38e74db
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
package com.dsh.account.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dsh.account.entity.StudentHonor;
import com.dsh.account.feignclient.other.HonorRulesClient;
import com.dsh.account.feignclient.other.model.HonorRules;
import com.dsh.account.service.StudentHonorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.util.Date;
 
 
/**
 * 勋章
 */
@RestController
@RequestMapping("/studentHonor")
public class StudentHonorController {
 
    @Autowired
    private StudentHonorService studentHonorService;
 
    @Resource
    private HonorRulesClient honorRulesClient;
 
 
 
 
 
    /**
     * 保存用户勋章
     * @param studentHonor
     */
    @ResponseBody
    @PostMapping("/saveStudentHonor")
    public void saveStudentHonor(@RequestBody StudentHonor studentHonor){
        StudentHonor one = studentHonorService.getOne(new QueryWrapper<StudentHonor>()
                .eq("appUserId", studentHonor.getAppUserId()).eq("honorType", studentHonor.getHonorType()));
        if(null == one){
            one = new StudentHonor();
        }
        //获取荣耀规则
        HonorRules honorRules = new HonorRules();
        honorRules.setType(studentHonor.getHonorType());
        honorRules.setCondition(studentHonor.getNumber());
        HonorRules honorRules1 = honorRulesClient.getHonorRules(honorRules);
        if(null != honorRules1){
            one.setAppUserId(studentHonor.getAppUserId());
            one.setHonorType(studentHonor.getHonorType());
            one.setNumber(studentHonor.getNumber());
            one.setHonorRuleId(honorRules1.getId());
            one.setHonorLevel(honorRules1.getLevel());
            one.setInsertTime(new Date());
            studentHonorService.saveOrUpdate(one);
        }
    }
}