From 7b487d4c819bc67021cf224c5042066bf73df1e3 Mon Sep 17 00:00:00 2001
From: nickchange <126672920+nickchange@users.noreply.github.com>
Date: 星期六, 28 十月 2023 17:01:00 +0800
Subject: [PATCH] 10.28。2
---
cloud-server-other/src/main/java/com/dsh/other/controller/HonorController.java | 71 ++++++++++++++++++++++++++++++++---
1 files changed, 64 insertions(+), 7 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 6a1dedd..39a8f85 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,6 +21,63 @@
@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));
+ }
+
+ /**
+ * 修改荣誉规则 并返回新的荣誉规则列表
+ */
+ @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(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 < list1.size(); i++) {
+ list2.get(i).setCondition(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 < list1.size(); i++) {
+ list3.get(i).setCondition(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 < list1.size(); i++) {
+ list4.get(i).setCondition(condition4.get(i));
+ }
+ hrService.updateBatchById(list4);
+
+ return ResultUtil.success();
+ }
@PostMapping("/base/honor/stuHonors")
public List<StuMedalVo> getStuHonors(@RequestBody List<Integer> honorIds){
--
Gitblit v1.7.1