From 98c36ab957f0da0170dbc9c22b6d9281faee1e14 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Wed, 10 Aug 2022 22:44:25 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=90=8E=E5=8F=B0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataease/plugins/server/ThemeServer.java | 50 ++++++++++++++++--- .../main/resources/db/migration/V39__1.14.sql | 9 +++- 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/backend/src/main/java/io/dataease/plugins/server/ThemeServer.java b/backend/src/main/java/io/dataease/plugins/server/ThemeServer.java index b8c25834f7..497f6d79e1 100644 --- a/backend/src/main/java/io/dataease/plugins/server/ThemeServer.java +++ b/backend/src/main/java/io/dataease/plugins/server/ThemeServer.java @@ -6,17 +6,17 @@ import org.apache.commons.lang3.ObjectUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.web.bind.annotation.PathVariable; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - import io.dataease.commons.exception.DEException; import io.dataease.commons.utils.LogUtil; import io.dataease.i18n.Translator; import io.dataease.plugins.config.SpringContextUtil; +import io.dataease.plugins.xpack.theme.dto.ThemeCreateRequest; import io.dataease.plugins.xpack.theme.dto.ThemeDto; import io.dataease.plugins.xpack.theme.dto.ThemeItem; +import io.dataease.plugins.xpack.theme.dto.ThemeRenameRequest; import io.dataease.plugins.xpack.theme.dto.ThemeRequest; import io.dataease.plugins.xpack.theme.service.ThemeXpackService; import springfox.documentation.annotations.ApiIgnore; @@ -41,11 +41,10 @@ public class ThemeServer { @RequiresPermissions("sysparam:read") @PostMapping("/save") - public void save(@RequestPart("request") ThemeRequest request, - @RequestPart(value = "file", required = false) MultipartFile bodyFile) { + public void save(@RequestBody ThemeCreateRequest request) { ThemeXpackService themeXpackService = SpringContextUtil.getBean(ThemeXpackService.class); try { - themeXpackService.save(request, bodyFile); + themeXpackService.addTheme(request); } catch (Exception e) { LogUtil.error(e.getMessage(), e); if (ObjectUtils.isNotEmpty(e.getMessage()) && e.getMessage().indexOf("theme_name_repeat") != -1) { @@ -56,7 +55,40 @@ public class ThemeServer { DEException.throwException(e); } } + + } + + @PostMapping("/rename") + public void renameTheme(@RequestBody ThemeRenameRequest request) { + if (request.getId() < 3) { + throw new RuntimeException("default theme can not execute rename"); + } + try { + ThemeXpackService themeXpackService = SpringContextUtil.getBean(ThemeXpackService.class); + themeXpackService.renameTheme(request); + } catch (Exception e) { + LogUtil.error(e.getMessage(), e); + if (ObjectUtils.isNotEmpty(e.getMessage()) && e.getMessage().indexOf("theme_name_repeat") != -1) { + DEException.throwException(Translator.get("theme_name_repeat")); + } else if (ObjectUtils.isNotEmpty(e.getMessage()) && e.getMessage().indexOf("theme_name_empty") != -1) { + DEException.throwException(Translator.get("theme_name_empty")); + } else { + DEException.throwException(e); + } + } + + } + @PostMapping("/enableSenior/{themeId}") + public void enableSenior(@PathVariable("themeId") Integer themeId) { + ThemeXpackService themeXpackService = SpringContextUtil.getBean(ThemeXpackService.class); + themeXpackService.switchSenior(themeId); + } + + @PostMapping("/activeTheme/{themeId}") + public void activeTheme(@PathVariable("themeId") Integer themeId) { + ThemeXpackService themeXpackService = SpringContextUtil.getBean(ThemeXpackService.class); + themeXpackService.switchStatus(themeId); } @RequiresPermissions("sysparam:read") @@ -66,4 +98,10 @@ public class ThemeServer { themeXpackService.deleteTheme(themeId); } + @PostMapping("/saveThemeItems") + public void saveThemeItems(@RequestBody ThemeRequest request) { + ThemeXpackService themeXpackService = SpringContextUtil.getBean(ThemeXpackService.class); + themeXpackService.saveThemeItems(request); + } + } diff --git a/backend/src/main/resources/db/migration/V39__1.14.sql b/backend/src/main/resources/db/migration/V39__1.14.sql index 56a5bf26e8..1046f11bf4 100644 --- a/backend/src/main/resources/db/migration/V39__1.14.sql +++ b/backend/src/main/resources/db/migration/V39__1.14.sql @@ -2,4 +2,11 @@ INSERT INTO `sys_menu` VALUES (700, 1, 2, 1, '系统配置', 'sys-settings', 'sy INSERT INTO `sys_menu` VALUES (710, 700, 0, 1, '外观配置', 'sys-appearance', 'system/settings/AppearanceSetting', 2, 'sys-tools', 'appearance', b'0', b'0', b'0', 'appearance:read', NULL, NULL, NULL, NULL); INSERT INTO `sys_menu` VALUES (730, 1, 0, 1, '数据同步表单', 'sys-task-ds-form', 'system/task/form', 11, NULL, '/task-ds-form', b'1', b'0', b'1', NULL, NULL, NULL, NULL, NULL); -UPDATE `sys_menu` set pid = 700, menu_sort = 1 where menu_id = 6 and `name` = 'system-param'; \ No newline at end of file +UPDATE `sys_menu` set pid = 700, menu_sort = 1 where menu_id = 6 and `name` = 'system-param'; + + + +ALTER TABLE `sys_theme` +DROP COLUMN `img`, +DROP COLUMN `img_id`, +ADD COLUMN `senior` TINYINT(1) NULL DEFAULT NULL AFTER `status`;