forked from github/dataease
perf: 优化主题设置后台接口
This commit is contained in:
parent
6d3ab3a8b4
commit
98c36ab957
@ -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) {
|
||||
@ -59,6 +58,39 @@ public class ThemeServer {
|
||||
|
||||
}
|
||||
|
||||
@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")
|
||||
@PostMapping("/delete/{themeId}")
|
||||
public void delete(@PathVariable("themeId") int themeId) {
|
||||
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,3 +3,10 @@ INSERT INTO `sys_menu` VALUES (710, 700, 0, 1, '外观配置', 'sys-appearance',
|
||||
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';
|
||||
|
||||
|
||||
|
||||
ALTER TABLE `sys_theme`
|
||||
DROP COLUMN `img`,
|
||||
DROP COLUMN `img_id`,
|
||||
ADD COLUMN `senior` TINYINT(1) NULL DEFAULT NULL AFTER `status`;
|
||||
|
Loading…
Reference in New Issue
Block a user