From 6be20b44b2f3fc1f09fe2f0d595744131dffd2bf Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 19 十二月 2023 16:56:56 +0800
Subject: [PATCH] #

---
 zy-asrs-common/src/main/java/com/zy/asrs/common/sys/controller/RoleController.java |   62 ++++++++++--------------------
 1 files changed, 21 insertions(+), 41 deletions(-)

diff --git a/zy-asrs-common/src/main/java/com/zy/asrs/common/sys/controller/RoleController.java b/zy-asrs-common/src/main/java/com/zy/asrs/common/sys/controller/RoleController.java
index 737c7ca..4172008 100644
--- a/zy-asrs-common/src/main/java/com/zy/asrs/common/sys/controller/RoleController.java
+++ b/zy-asrs-common/src/main/java/com/zy/asrs/common/sys/controller/RoleController.java
@@ -1,6 +1,7 @@
 package com.zy.asrs.common.sys.controller;
 
-import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.zy.asrs.common.sys.entity.Role;
 import com.zy.asrs.common.sys.service.RoleService;
 import com.zy.asrs.common.web.BaseController;
@@ -8,7 +9,10 @@
 import com.zy.asrs.framework.common.Cools;
 import com.zy.asrs.framework.common.R;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 
 import java.util.*;
 
@@ -31,45 +35,31 @@
                   @RequestParam(required = false)String orderByField,
                   @RequestParam(required = false)String orderByType,
                   @RequestParam Map<String, Object> param){
-        excludeTrash(param);
-        EntityWrapper<Role> wrapper = new EntityWrapper<>();
-        convert(param, wrapper);
-        wrapper.orderBy("id", false);
+        LambdaQueryWrapper<Role> wrapper = new LambdaQueryWrapper<>();
+        wrapper.orderByDesc(Role::getId);
 
         if (9527 == getUserId()) {
-            return R.ok(roleService.selectPage(new Page<>(curr, limit), wrapper));
+            return R.ok(roleService.page(new Page<>(curr, limit), wrapper));
         }
         Long roleId = getUser().getRoleId();
-        Role role = roleService.selectById(roleId);
+        Role role = roleService.getById(roleId);
         Long leaderId = role.getLeader();
         if (null != leaderId) {
             List<Long> leaderIds = new ArrayList<>();
             leaderIds.add(roleId);
             while (leaderId != null) {
-                Role leader = roleService.selectById(leaderId);
+                Role leader = roleService.getById(leaderId);
                 leaderIds.add(leader.getId());
                 leaderId = leader.getLeader();
             }
-            wrapper.notIn("id", leaderIds);
+            wrapper.notIn(Role::getId, leaderIds);
         }
 //        if (null != role.getLevel()) {
 //            wrapper.gt("level", role.getLevel());
 //        }
-        return R.ok(roleService.selectPage(new Page<>(curr, limit), wrapper));
+        return R.ok(roleService.page(new Page<>(curr, limit), wrapper));
     }
 
-    private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){
-        for (Map.Entry<String, Object> entry : map.entrySet()){
-            String val = String.valueOf(entry.getValue());
-            if (val.contains(RANGE_TIME_LINK)){
-                String[] dates = val.split(RANGE_TIME_LINK);
-                wrapper.ge(entry.getKey(), DateUtils.convert(dates[0]));
-                wrapper.le(entry.getKey(), DateUtils.convert(dates[1]));
-            } else {
-                wrapper.like(entry.getKey(), val);
-            }
-        }
-    }
 
     @RequestMapping(value = "/role/edit/auth")
     @ManagerAuth(memo = "瑙掕壊缂栬緫")
@@ -88,7 +78,7 @@
     @RequestMapping(value = "/role/add/auth")
     @ManagerAuth(memo = "瑙掕壊娣诲姞")
     public R add(Role role) {
-        roleService.insert(role);
+        roleService.save(role);
         return R.ok();
     }
 
@@ -108,46 +98,36 @@
         if (Cools.isEmpty(ids)){
             return R.error();
         }
-        roleService.deleteBatchIds(Arrays.asList(ids));
+        roleService.removeByIds(Arrays.asList(ids));
         return R.ok();
     }
 
-    @RequestMapping(value = "/role/export/auth")
-    @ManagerAuth(memo = "瑙掕壊瀵煎嚭")
-    public R export(@RequestBody JSONObject param){
-        List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class);
-        EntityWrapper<Role> wrapper = new EntityWrapper<>();
-        Map<String, Object> map = excludeTrash(param.getJSONObject("role"));
-        convert(map, wrapper);
-        List<Role> list = roleService.selectList(wrapper);
-        return R.ok(exportSupport(list, fields));
-    }
 
     @RequestMapping(value = "/roleQuery/auth")
     @ManagerAuth
     public R query(String condition) {
-        EntityWrapper<Role> wrapper = new EntityWrapper<>();
-        wrapper.like("name", condition);
+        LambdaQueryWrapper<Role> wrapper = new LambdaQueryWrapper<>();
+        wrapper.like(Role::getName, condition);
         // 涓婁笅绾х鐞�
         if (9527 != getUserId()) {
             Long roleId = getUser().getRoleId();
-            Role role = roleService.selectById(roleId);
+            Role role = roleService.getById(roleId);
             Long leaderId = role.getLeader();
             if (null != leaderId) {
                 List<Long> leaderIds = new ArrayList<>();
                 while (leaderId != null) {
-                    Role leader = roleService.selectById(leaderId);
+                    Role leader = roleService.getById(leaderId);
                     leaderIds.add(leader.getId());
                     leaderId = leader.getLeader();
                 }
-                wrapper.notIn("id", leaderIds);
+                wrapper.notIn(Role::getId, leaderIds);
             }
 //            if (null != role.getLevel()) {
 //                wrapper.ge("level", role.getLevel());
 //            }
         }
 
-        Page<Role> page = roleService.selectPage(new Page<>(0, 10), wrapper);
+        Page<Role> page = roleService.page(new Page<>(0, 10), wrapper);
         List<Map<String, Object>> result = new ArrayList<>();
         for (Role role : page.getRecords()){
             Map<String, Object> map = new HashMap<>();

--
Gitblit v1.9.1