From caf3bdd9bbb629c8bc6f1a19b3ccdf441bf7650c Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期日, 15 三月 2026 17:46:47 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/system/controller/ResourceController.java |   48 +++++++++++++++++++++++++-----------------------
 1 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/src/main/java/com/zy/system/controller/ResourceController.java b/src/main/java/com/zy/system/controller/ResourceController.java
index 9eac7ac..f5a36c6 100644
--- a/src/main/java/com/zy/system/controller/ResourceController.java
+++ b/src/main/java/com/zy/system/controller/ResourceController.java
@@ -1,8 +1,8 @@
 package com.zy.system.controller;
 
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.mapper.EntityWrapper;
-import com.baomidou.mybatisplus.plugins.Page;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.core.annotations.ManagerAuth;
 import com.core.common.Cools;
 import com.core.common.DateUtils;
@@ -27,7 +27,7 @@
     @RequestMapping(value = "/resource/{id}/auth")
     @ManagerAuth
     public R get(@PathVariable("id") Long id) {
-        return R.ok(resourceService.selectById(String.valueOf(id)));
+        return R.ok(resourceService.getById(String.valueOf(id)));
     }
 
     @RequestMapping(value = "/resource/list/auth")
@@ -38,20 +38,22 @@
                   @RequestParam(required = false)String orderByType,
                   @RequestParam Map<String, Object> param){
         excludeTrash(param);
-        EntityWrapper<Resource> wrapper = new EntityWrapper<>();
+        QueryWrapper<Resource> wrapper = new QueryWrapper<>();
         convert(param, wrapper);
-        wrapper.orderBy("id", false);
-        return R.ok(resourceService.selectPage(new Page<>(curr, limit), wrapper));
+        wrapper.orderBy(true, false, "id");
+        return R.ok(resourceService.page(new Page<>(curr, limit), wrapper));
     }
 
-    private void convert(Map<String, Object> map, EntityWrapper wrapper){
+    private void convert(Map<String, Object> map, QueryWrapper wrapper){
         for (Map.Entry<String, Object> entry : map.entrySet()){
-            if (entry.getKey().endsWith(">")) {
-                wrapper.ge(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue())));
-            } else if (entry.getKey().endsWith("<")) {
-                wrapper.le(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue())));
+            String val = String.valueOf(entry.getValue());
+            String column = humpToLine(entry.getKey());
+            if (val.contains(" - ")) {
+                String[] dates = val.split(" - ");
+                wrapper.ge(column, DateUtils.convert(dates[0]));
+                wrapper.le(column, DateUtils.convert(dates[1]));
             } else {
-                wrapper.eq(entry.getKey(), String.valueOf(entry.getValue()));
+                wrapper.eq(column, val);
             }
         }
     }
@@ -66,7 +68,7 @@
             if (resource.getSort() == null){
                 resource.setSort(999);
             }
-            resourceService.insert(resource);
+            resourceService.save(resource);
         } else {
             resourceService.updateById(resource);
         }
@@ -76,7 +78,7 @@
     @RequestMapping(value = "/resource/add/auth")
     @ManagerAuth(memo = "鑿滃崟娣诲姞")
     public R add(Resource resource) {
-        resourceService.insert(resource);
+        resourceService.save(resource);
         return R.ok();
     }
 
@@ -94,7 +96,7 @@
     @ManagerAuth(memo = "鑿滃崟鍒犻櫎")
     public R delete(@RequestParam(value="ids[]") Long[] ids){
         for (Long id : ids){
-            resourceService.deleteById(id);
+            resourceService.removeById(id);
         }
         return R.ok();
     }
@@ -103,19 +105,19 @@
     @ManagerAuth(memo = "鑿滃崟瀵煎嚭")
     public R export(@RequestBody JSONObject param){
         List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class);
-        EntityWrapper<Resource> wrapper = new EntityWrapper<>();
+        QueryWrapper<Resource> wrapper = new QueryWrapper<>();
         Map<String, Object> map = excludeTrash(param.getJSONObject("resource"));
         convert(map, wrapper);
-        List<Resource> list = resourceService.selectList(wrapper);
+        List<Resource> list = resourceService.list(wrapper);
         return R.ok(exportSupport(list, fields));
     }
 
     @RequestMapping(value = "/resourceQuery/auth")
     @ManagerAuth
     public R query(String condition) {
-        EntityWrapper<Resource> wrapper = new EntityWrapper<>();
+        QueryWrapper<Resource> wrapper = new QueryWrapper<>();
         wrapper.like("name", condition);
-        Page<Resource> page = resourceService.selectPage(new Page<>(0, 10), wrapper);
+        Page<Resource> page = resourceService.page(new Page<>(0, 10), wrapper);
         List<Map<String, Object>> result = new ArrayList<>();
         for (Resource resource : page.getRecords()){
             Map<String, Object> map = new HashMap<>();
@@ -138,14 +140,14 @@
                   @RequestParam(required = false)String orderByField,
                   @RequestParam(required = false)String orderByType,
                   @RequestParam Map<String, Object> param){
-        EntityWrapper<Resource> wrapper = new EntityWrapper<>();
+        QueryWrapper<Resource> wrapper = new QueryWrapper<>();
         excludeTrash(param);
         convert(param, wrapper);
-        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
+        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(true, "asc".equals(orderByType), humpToLine(orderByField));}
         else {
-            wrapper.orderBy("sort");
+            wrapper.orderBy(true, true, "sort");
         }
-        List<Resource> resources = resourceService.selectList(wrapper);
+        List<Resource> resources = resourceService.list(wrapper);
         for (Resource resource : resources) {
             resource.setName(i18nMessageService.resolveResourceText(resource.getName(), resource.getCode(), resource.getId()));
         }

--
Gitblit v1.9.1