From 40dcac7c694867a4b66a9c8567cd2fe6959a25df Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期三, 06 五月 2026 08:51:05 +0800
Subject: [PATCH] #请求入库任务提示优化

---
 src/main/java/com/zy/system/controller/ConfigController.java |  111 +++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 79 insertions(+), 32 deletions(-)

diff --git a/src/main/java/com/zy/system/controller/ConfigController.java b/src/main/java/com/zy/system/controller/ConfigController.java
index 6243d13..58acb70 100644
--- a/src/main/java/com/zy/system/controller/ConfigController.java
+++ b/src/main/java/com/zy/system/controller/ConfigController.java
@@ -2,8 +2,8 @@
 
 import com.alibaba.fastjson.JSON;
 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;
@@ -17,7 +17,9 @@
 import com.zy.core.enums.RedisKeyType;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
+import java.io.IOException;
 import java.util.*;
 
 @RestController
@@ -31,19 +33,14 @@
     @RequestMapping(value = "/config/refreshCache")
     @ManagerAuth
     public R refreshCache(){
-        HashMap<String, String> systemConfigMap = new HashMap<>();
-        List<Config> configList = configService.selectList(new EntityWrapper<>());
-        for (Config config : configList) {
-            systemConfigMap.put(config.getCode(), config.getValue());
-        }
-        redisUtil.set(RedisKeyType.SYSTEM_CONFIG_MAP.key, systemConfigMap);
+        refreshCacheData();
         return R.ok();
     }
 
     @RequestMapping(value = "/config/{id}/auth")
     @ManagerAuth
     public R get(@PathVariable("id") Long id) {
-        return R.ok(configService.selectById(String.valueOf(id)));
+        return R.ok(configService.getById(String.valueOf(id)));
     }
 
     @RequestMapping(value = "/config/list/auth")
@@ -54,28 +51,30 @@
                   @RequestParam(required = false)String orderByType,
                   @RequestParam Map<String, Object> param){
         excludeTrash(param);
-        EntityWrapper<Config> wrapper = new EntityWrapper<>();
+        QueryWrapper<Config> wrapper = new QueryWrapper<>();
         convert(param, wrapper);
-        wrapper.orderBy("id", false);
-        return R.ok(configService.selectPage(new Page<>(curr, limit), wrapper));
+        wrapper.orderBy(true, false, "id");
+        return R.ok(configService.page(new Page<>(curr, limit), wrapper));
     }
 
     @RequestMapping(value = "/config/listAll/auth")
     @ManagerAuth
     public R listAll(){
-        EntityWrapper<Config> wrapper = new EntityWrapper<>();
-        wrapper.orderBy("id", false);
-        return R.ok(configService.selectList(wrapper));
+        QueryWrapper<Config> wrapper = new QueryWrapper<>();
+        wrapper.orderBy(true, false, "id");
+        return R.ok(configService.list(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.like(entry.getKey(), String.valueOf(entry.getValue()));
+                wrapper.like(column, val);
             }
         }
     }
@@ -83,16 +82,28 @@
     @RequestMapping(value = "/config/updateBatch")
     @ManagerAuth
     public R updateBatch(@RequestBody List<ConfigUpdateBatchParam> params){
+        boolean updated = false;
         for (ConfigUpdateBatchParam param : params) {
             String code = param.getCode();
             String value = param.getValue();
-            Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", code));
+            Config config = configService.getOne(new QueryWrapper<Config>().eq("code", code));
             if (config == null) {
+                continue;
+            }
+            if (Short.valueOf((short) 2).equals(config.getType()) && !checkJson(value)) {
+                return R.error(config.getCode() + " json瑙f瀽澶辫触");
+            }
+            if (Objects.equals(config.getValue(), value)) {
                 continue;
             }
 
             config.setValue(value);
             configService.updateById(config);
+            updated = true;
+        }
+        if (updated) {
+            Parameter.reset();
+            refreshCacheData();
         }
         return R.ok();
     }
@@ -109,7 +120,7 @@
             }
         }
         if (null == config.getId()){
-            configService.insert(config);
+            configService.save(config);
         } else {
             configService.updateById(config);
             Parameter.reset();
@@ -125,7 +136,7 @@
                 return R.error("json瑙f瀽澶辫触");
             }
         }
-        configService.insert(config);
+        configService.save(config);
         return R.ok();
     }
 
@@ -151,7 +162,7 @@
         if (Cools.isEmpty(ids)){
             return R.error();
         }
-        configService.deleteBatchIds(Arrays.asList(ids));
+        configService.removeByIds(Arrays.asList(ids));
         return R.ok();
     }
 
@@ -159,19 +170,19 @@
     @ManagerAuth
     public R export(@RequestBody JSONObject param){
         List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class);
-        EntityWrapper<Config> wrapper = new EntityWrapper<>();
+        QueryWrapper<Config> wrapper = new QueryWrapper<>();
         Map<String, Object> map = excludeTrash(param.getJSONObject("config"));
         convert(map, wrapper);
-        List<Config> list = configService.selectList(wrapper);
+        List<Config> list = configService.list(wrapper);
         return R.ok(exportSupport(list, fields));
     }
 
     @RequestMapping(value = "/configQuery/auth")
     @ManagerAuth
     public R query(String condition) {
-        EntityWrapper<Config> wrapper = new EntityWrapper<>();
+        QueryWrapper<Config> wrapper = new QueryWrapper<>();
         wrapper.like("id", condition);
-        Page<Config> page = configService.selectPage(new Page<>(0, 10), wrapper);
+        Page<Config> page = configService.page(new Page<>(0, 10), wrapper);
         List<Map<String, Object>> result = new ArrayList<>();
         for (Config config : page.getRecords()){
             Map<String, Object> map = new HashMap<>();
@@ -204,10 +215,10 @@
     @RequestMapping(value = "/config/getSelectTypes")
     @ManagerAuth
     public R getSelectTypes() {
-        EntityWrapper<Config> wrapper = new EntityWrapper<>();
-        wrapper.setSqlSelect("DISTINCT select_type as selectType");
+        QueryWrapper<Config> wrapper = new QueryWrapper<>();
+        wrapper.select("DISTINCT select_type as selectType");
         wrapper.isNotNull("select_type");
-        List<Map<String, Object>> maps = configService.selectMaps(wrapper);
+        List<Map<String, Object>> maps = configService.listMaps(wrapper);
         List<String> types = new ArrayList<>();
         for (Map<String, Object> map : maps) {
             if (map != null && map.get("selectType") != null) {
@@ -215,6 +226,38 @@
             }
         }
         return R.ok(types);
+    }
+
+    @PostMapping("/config/uploadLogo/auth")
+    @ManagerAuth
+    public R uploadLogo(@RequestParam("file") MultipartFile file) {
+        if (file == null || file.isEmpty()) {
+            return R.error("璇烽�夋嫨鏂囦欢");
+        }
+        String originalName = file.getOriginalFilename();
+        if (originalName == null) {
+            return R.error("鏂囦欢鍚嶄负绌�");
+        }
+        String ext = originalName.contains(".") ? originalName.substring(originalName.lastIndexOf(".") + 1).toLowerCase() : "";
+        String mimeType;
+        switch (ext) {
+            case "png": mimeType = "image/png"; break;
+            case "jpg":
+            case "jpeg": mimeType = "image/jpeg"; break;
+            case "svg": mimeType = "image/svg+xml"; break;
+            case "ico": mimeType = "image/x-icon"; break;
+            default: return R.error("浠呮敮鎸� png/jpg/jpeg/svg/ico 鏍煎紡");
+        }
+        try {
+            String base64 = Base64.getEncoder().encodeToString(file.getBytes());
+            String dataUri = "data:" + mimeType + ";base64," + base64;
+            configService.saveConfigValue("system.logo", dataUri);
+            Parameter.reset();
+            configService.refreshSystemConfigCache();
+            return R.ok().add(dataUri);
+        } catch (IOException e) {
+            return R.error("涓婁紶澶辫触锛�" + e.getMessage());
+        }
     }
 
 
@@ -227,4 +270,8 @@
         return parse != null;
     }
 
+    private void refreshCacheData() {
+        configService.refreshSystemConfigCache();
+    }
+
 }

--
Gitblit v1.9.1