From 3a03018efa6374619e6e90dcfb5ed4d3995963aa Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期一, 18 八月 2025 11:21:39 +0800
Subject: [PATCH] 会员协议
---
cloud-server-other/src/main/java/com/dsh/other/controller/HonorController.java | 148 +++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 130 insertions(+), 18 deletions(-)
diff --git a/cloud-server-other/src/main/java/com/dsh/other/controller/HonorController.java b/cloud-server-other/src/main/java/com/dsh/other/controller/HonorController.java
index f7b218a..38daf8b 100644
--- a/cloud-server-other/src/main/java/com/dsh/other/controller/HonorController.java
+++ b/cloud-server-other/src/main/java/com/dsh/other/controller/HonorController.java
@@ -1,18 +1,18 @@
package com.dsh.other.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dsh.other.entity.HonorRules;
import com.dsh.other.feignclient.model.StuMedalVo;
+import com.dsh.other.model.vo.honorVo.EditHonorVO;
import com.dsh.other.service.HonorRulesService;
+import com.dsh.other.util.ResultUtil;
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 org.springframework.web.bind.annotation.*;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
+import java.util.stream.Collectors;
@RestController
@RequestMapping("")
@@ -21,17 +21,122 @@
@Autowired
private HonorRulesService hrService;
+ /**
+ * 获取 荣誉规则列表
+ */
+ @RequestMapping(value = "/base/honor/list")
+ public Map<Integer, List<HonorRules>> getList() {
+ List<HonorRules> list = hrService.getList();
+ return list.stream().collect(Collectors.groupingBy(HonorRules::getType));
+ }
- @PostMapping("/honor/stuHonors")
- public List<StuMedalVo> getStuHonors(@RequestBody List<Integer> honorIds){
+ /**
+ * 修改荣誉规则 并返回新的荣誉规则列表
+ */
+ @RequestMapping(value = "/base/honor/edit")
+ @ResponseBody
+ public Object edit(@RequestBody EditHonorVO vo) {
+ Integer type1 = vo.getType1().getType();
+ List<String> condition1 = vo.getType1().getCondition();
+ QueryWrapper<HonorRules> wrapper1 = new QueryWrapper<>();
+ wrapper1.eq("type", type1);
+ List<HonorRules> list1 = hrService.list(wrapper1);
+ for (int i = 0; i < list1.size(); i++) {
+ list1.get(i).setCondition(Integer.valueOf(condition1.get(i)));
+ }
+ hrService.updateBatchById(list1);
+
+ Integer type2 = vo.getType2().getType();
+ List<String> condition2 = vo.getType2().getCondition();
+ QueryWrapper<HonorRules> wrapper2 = new QueryWrapper<>();
+ wrapper2.eq("type", type2);
+ List<HonorRules> list2 = hrService.list(wrapper2);
+ for (int i = 0; i < list2.size(); i++) {
+ list2.get(i).setCondition(Integer.valueOf(condition2.get(i)));
+ }
+ hrService.updateBatchById(list2);
+
+ Integer type3 = vo.getType3().getType();
+ List<String> condition3 = vo.getType3().getCondition();
+ QueryWrapper<HonorRules> wrapper3 = new QueryWrapper<>();
+ wrapper3.eq("type", type3);
+ List<HonorRules> list3 = hrService.list(wrapper3);
+ for (int i = 0; i < list3.size(); i++) {
+ list3.get(i).setCondition(Integer.valueOf(condition3.get(i)));
+ }
+ hrService.updateBatchById(list3);
+
+ Integer type4 = vo.getType4().getType();
+ List<String> condition4 = vo.getType4().getCondition();
+ QueryWrapper<HonorRules> wrapper4 = new QueryWrapper<>();
+ wrapper4.eq("type", type4);
+ List<HonorRules> list4 = hrService.list(wrapper4);
+ for (int i = 0; i < list4.size(); i++) {
+ list4.get(i).setCondition(Integer.valueOf(condition4.get(i)));
+ }
+ hrService.updateBatchById(list4);
+
+ Integer type5 = vo.getType5().getType();
+ List<String> condition5 = vo.getType5().getCondition();
+ QueryWrapper<HonorRules> wrapper5 = new QueryWrapper<>();
+ wrapper5.eq("type", type5);
+ List<HonorRules> list5 = hrService.list(wrapper5);
+ for (int i = 0; i < list5.size(); i++) {
+ list5.get(i).setCondition(Integer.valueOf(condition5.get(i)));
+ }
+ hrService.updateBatchById(list5);
+
+ Integer type6 = vo.getType6().getType();
+ List<String> condition6 = vo.getType6().getCondition();
+ QueryWrapper<HonorRules> wrapper6 = new QueryWrapper<>();
+ wrapper6.eq("type", type6);
+ List<HonorRules> list6 = hrService.list(wrapper6);
+ for (int i = 0; i < list6.size(); i++) {
+ list6.get(i).setCondition(Integer.valueOf(condition6.get(i)));
+ }
+ hrService.updateBatchById(list6);
+
+ return ResultUtil.success();
+ }
+
+ @Autowired
+ private HonorRulesService honorRulesService;
+
+ @PostMapping("/base/honor/getHonor")
+ public HonorRules getHonor(@RequestBody List<Integer> integers) {
+ HonorRules one = honorRulesService.getOne(new QueryWrapper<HonorRules>()
+ .eq("type", integers.get(0))
+ .le("`condition`", integers.get(1)).orderByDesc("`condition`")
+ .last("LIMIT 1"));
+
+ if (one == null) {
+ HonorRules one1 = honorRulesService.getOne(new QueryWrapper<HonorRules>()
+ .eq("type", integers.get(0))
+ .eq("level", 1)
+ .last("LIMIT 1"));
+ return one1;
+ }
+
+ if (one.getLevel() == 10) {
+ return one;
+ }
+ HonorRules one2 = honorRulesService.getOne(new QueryWrapper<HonorRules>().eq("type", integers.get(0))
+ .eq("level", Integer.valueOf(one.getLevel()) + 1));
+ return one2;
+ }
+
+ @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){
+ List<HonorRules> honorRules = hrService.querylistOfIds(honorIds);
+
+
+ if (honorRules.size() > 0) {
honorRules.forEach(hrs -> {
StuMedalVo stuMedalVo = new StuMedalVo();
- stuMedalVo.setLevelNum(Integer.getInteger(hrs.getLevel()));
- switch (hrs.getType()){
+ stuMedalVo.setLevelNum(Integer.getInteger(String.valueOf(hrs.getLevel())));
+ stuMedalVo.setMedalType(hrs.getType());
+ switch (hrs.getType()) {
case 1:
stuMedalVo.setMedalName("俱乐部之星");
break;
@@ -44,14 +149,21 @@
case 4:
stuMedalVo.setMedalName("深度玩家");
break;
+ case 5:
+ stuMedalVo.setMedalName("常胜将军");
+ break;
+ case 6:
+ stuMedalVo.setMedalName("越战越勇");
+ break;
default:
break;
}
- if (!Objects.equals(hrs.getLevel(), "10")){
- stuMedalVo.setNextLevel(Integer.parseInt(hrs.getLevel())+1);
- stuMedalVo.setUpgradeConditions(hrs.getCondition());
+ if (!Objects.equals(hrs.getLevel(), "10")) {
+ stuMedalVo.setLevelNum(Integer.parseInt(String.valueOf(hrs.getLevel())));
+ stuMedalVo.setNextLevel(Integer.parseInt(String.valueOf(hrs.getLevel())) + 1);
+ stuMedalVo.setUpgradeConditions(String.valueOf(hrs.getCondition()));
stuMedalVo.setIsTopLevel(2);
- }else {
+ } else {
stuMedalVo.setIsTopLevel(1);
}
stuMedalVos.add(stuMedalVo);
--
Gitblit v1.7.1