diff --git a/dao/src/main/java/cn/bunny/dao/constant/RedisUserConstant.java b/dao/src/main/java/cn/bunny/dao/constant/RedisUserConstant.java index a0f8e4d..845194f 100644 --- a/dao/src/main/java/cn/bunny/dao/constant/RedisUserConstant.java +++ b/dao/src/main/java/cn/bunny/dao/constant/RedisUserConstant.java @@ -10,12 +10,14 @@ public class RedisUserConstant { // 过期时间 public static final Long REDIS_EXPIRATION_TIME = 7L;// 7 天/分钟 Redis过期 public static final Integer Cookie_EXPIRATION_TIME = 5 * 60 * 60;// cookies 过期时间 5 分钟 + public static final String WEB_CONFIG_KEY = "webConfig::platformConfig";// web配置 private static final String ADMIN_LOGIN_INFO_PREFIX = "admin::login_info::"; private static final String ADMIN_EMAIL_CODE_PREFIX = "admin::email_code::"; private static final String USER_LOGIN_INFO_PREFIX = "user::login_info::"; private static final String USER_EMAIL_CODE_PREFIX = "user::email_code::"; + public static String getAdminLoginInfoPrefix(String adminUser) { return ADMIN_LOGIN_INFO_PREFIX + adminUser; } diff --git a/dao/src/main/java/cn/bunny/dao/dto/financial/category/admin/CategoryAddDto.java b/dao/src/main/java/cn/bunny/dao/dto/financial/category/admin/CategoryAddDto.java index 261531e..00eaef9 100644 --- a/dao/src/main/java/cn/bunny/dao/dto/financial/category/admin/CategoryAddDto.java +++ b/dao/src/main/java/cn/bunny/dao/dto/financial/category/admin/CategoryAddDto.java @@ -16,7 +16,6 @@ import lombok.NoArgsConstructor; public class CategoryAddDto { @Schema(name = "userId", title = "绑定的用户id") - @NotNull(message = "用户不能为空") private Long userId; @Schema(name = "categoryName", title = "分类名称") diff --git a/dao/src/main/java/cn/bunny/dao/vo/configuration/WebConfigurationVo.java b/dao/src/main/java/cn/bunny/dao/vo/configuration/WebConfigurationVo.java deleted file mode 100644 index 287c131..0000000 --- a/dao/src/main/java/cn/bunny/dao/vo/configuration/WebConfigurationVo.java +++ /dev/null @@ -1,121 +0,0 @@ -package cn.bunny.dao.vo.configuration; - -import com.alibaba.fastjson2.annotation.JSONField; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@AllArgsConstructor -@NoArgsConstructor -@Builder -@Schema(name = "WebConfigurationVo对象", title = "前端配置获取返回结果", description = "前端配置获取返回结果") -public class WebConfigurationVo { - - @Schema(name = "Version", description = "应用程序的版本") - @JSONField(name = "Version") - private String version; - - @Schema(name = "Title", description = "应用程序的标题") - @JSONField(name = "Title") - private String title; - - @Schema(name = "Copyright", description = "版权信息") - @JSONField(name = "Copyright") - private String copyright; - - @Schema(name = "FixedHeader", description = "头部是否固定") - @JSONField(name = "FixedHeader") - private boolean fixedHeader; - - @Schema(name = "HiddenSideBar", description = "侧边栏是否隐藏") - @JSONField(name = "HiddenSideBar") - private boolean hiddenSideBar; - - @Schema(name = "MultiTagsCache", description = "是否缓存多个标签") - @JSONField(name = "MultiTagsCache") - private boolean multiTagsCache; - - @Schema(name = "KeepAlive", description = "是否持久化") - @JSONField(name = "KeepAlive") - private boolean keepAlive; - - @Schema(name = "Locale", description = "语言类型") - @JSONField(name = "Locale") - private String locale; - - @Schema(name = "Layout", description = "应用程序的布局") - @JSONField(name = "Layout") - private String layout; - - @Schema(name = "Theme", description = "应用程序的主题") - @JSONField(name = "Theme") - private String theme; - - @Schema(name = "DarkMode", description = "是否启用深色模式") - @JSONField(name = "DarkMode") - private boolean darkMode; - - @Schema(name = "OverallStyle", description = "应用程序的整体样式") - @JSONField(name = "OverallStyle") - private String overallStyle; - - @Schema(name = "Grey", description = "是否启用灰色模式") - @JSONField(name = "Grey") - private boolean grey; - - @Schema(name = "Weak", description = "色弱模式") - @JSONField(name = "Weak") - private boolean weak; - - @Schema(name = "HideTabs", description = "是否隐藏选项卡") - @JSONField(name = "HideTabs") - private boolean hideTabs; - - @Schema(name = "HideFooter", description = "是否隐藏页脚") - @JSONField(name = "HideFooter") - private boolean hideFooter; - - @Schema(name = "Stretch", description = "是否拉伸显示") - @JSONField(name = "Stretch") - private boolean stretch; - - @Schema(name = "SidebarStatus", description = "侧边栏的状态") - @JSONField(name = "SidebarStatus") - private boolean sidebarStatus; - - @Schema(name = "EpThemeColor", description = "主题颜色") - @JSONField(name = "EpThemeColor") - private String epThemeColor; - - @Schema(name = "ShowLogo", description = "是否显示logo") - @JSONField(name = "ShowLogo") - private boolean showLogo; - - @Schema(name = "ShowModel", description = "要显示的模型") - @JSONField(name = "ShowModel") - private String showModel; - - @Schema(name = "MenuArrowIconNoTransition", description = "菜单箭头图标是否没有过渡效果") - @JSONField(name = "MenuArrowIconNoTransition") - private boolean menuArrowIconNoTransition; - - @Schema(name = "CachingAsyncRoutes", description = "是否缓存异步路由") - @JSONField(name = "CachingAsyncRoutes") - private boolean cachingAsyncRoutes; - - @Schema(name = "TooltipEffect", description = "工具提示的效果") - @JSONField(name = "TooltipEffect") - private String tooltipEffect; - - @Schema(name = "ResponsiveStorageNameSpace", description = "响应式存储的命名空间") - @JSONField(name = "ResponsiveStorageNameSpace") - private String responsiveStorageNameSpace; - - @Schema(name = "MenuSearchHistory", description = "菜单搜索历史") - @JSONField(name = "MenuSearchHistory") - private int menuSearchHistory; - -} \ No newline at end of file diff --git a/service/pom.xml b/service/pom.xml index 2e3bc49..dac8a25 100644 --- a/service/pom.xml +++ b/service/pom.xml @@ -32,6 +32,12 @@ org.springframework.security spring-security-test + + org.springframework.boot + spring-boot-devtools + runtime + true + org.springframework.boot diff --git a/service/src/main/java/cn/bunny/services/controller/configuration/ConfigurationController.java b/service/src/main/java/cn/bunny/services/controller/configuration/ConfigurationController.java index 0ac68bd..c29c702 100644 --- a/service/src/main/java/cn/bunny/services/controller/configuration/ConfigurationController.java +++ b/service/src/main/java/cn/bunny/services/controller/configuration/ConfigurationController.java @@ -2,7 +2,6 @@ package cn.bunny.services.controller.configuration; import cn.bunny.dao.dto.system.configuration.WebConfigurationDto; import cn.bunny.dao.model.configuration.WebConfiguration; -import cn.bunny.dao.vo.configuration.WebConfigurationVo; import cn.bunny.dao.vo.result.Result; import cn.bunny.dao.vo.result.ResultCodeEnum; import cn.bunny.services.aop.annotation.ExcludeRequestLog; @@ -32,9 +31,9 @@ public class ConfigurationController { @ExcludeRequestLog @Operation(summary = "获取修改web配置文件", description = "获取修改web配置文件") @GetMapping("getWebConfig") - public Mono> getWebConfig() { - WebConfigurationVo webConfiguration = configurationService.getWebConfig(); - return Mono.just(Result.success(webConfiguration)); + public Result getWebConfig() { + WebConfiguration webConfiguration = configurationService.webConfig(); + return Result.success(webConfiguration); } @Operation(summary = "更新web配置文件", description = "更新web配置文件") diff --git a/service/src/main/java/cn/bunny/services/factory/BillFactory.java b/service/src/main/java/cn/bunny/services/factory/BillFactory.java index 8c0a3c2..9c08be4 100644 --- a/service/src/main/java/cn/bunny/services/factory/BillFactory.java +++ b/service/src/main/java/cn/bunny/services/factory/BillFactory.java @@ -51,7 +51,6 @@ public class BillFactory { @Autowired private EmailFactory emailFactory; - public void exportBill(BillExportDto dto, HttpServletResponse response) { LocalDate startDate = dto.getStartDate(); LocalDate endDate = dto.getEndDate(); diff --git a/service/src/main/java/cn/bunny/services/service/configuration/ConfigurationService.java b/service/src/main/java/cn/bunny/services/service/configuration/ConfigurationService.java index f94b1c4..3380dfc 100644 --- a/service/src/main/java/cn/bunny/services/service/configuration/ConfigurationService.java +++ b/service/src/main/java/cn/bunny/services/service/configuration/ConfigurationService.java @@ -2,7 +2,6 @@ package cn.bunny.services.service.configuration; import cn.bunny.dao.dto.system.configuration.WebConfigurationDto; import cn.bunny.dao.model.configuration.WebConfiguration; -import cn.bunny.dao.vo.configuration.WebConfigurationVo; public interface ConfigurationService { @@ -20,10 +19,4 @@ public interface ConfigurationService { */ WebConfiguration webConfig(); - /** - * 获取修改web配置文件 - * - * @return 要修改前端配置文件 - */ - WebConfigurationVo getWebConfig(); } \ No newline at end of file diff --git a/service/src/main/java/cn/bunny/services/service/configuration/impl/ConfigurationServiceImpl.java b/service/src/main/java/cn/bunny/services/service/configuration/impl/ConfigurationServiceImpl.java index 6ef327e..1d7473e 100644 --- a/service/src/main/java/cn/bunny/services/service/configuration/impl/ConfigurationServiceImpl.java +++ b/service/src/main/java/cn/bunny/services/service/configuration/impl/ConfigurationServiceImpl.java @@ -1,41 +1,27 @@ package cn.bunny.services.service.configuration.impl; import cn.bunny.common.service.exception.AuthCustomerException; +import cn.bunny.dao.constant.RedisUserConstant; import cn.bunny.dao.dto.system.configuration.WebConfigurationDto; import cn.bunny.dao.model.configuration.WebConfiguration; -import cn.bunny.dao.vo.configuration.WebConfigurationVo; import cn.bunny.dao.vo.result.ResultCodeEnum; import cn.bunny.services.service.configuration.ConfigurationService; import com.alibaba.fastjson2.JSON; -import org.jetbrains.annotations.NotNull; import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.io.IOException; import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Path; @Service +@Transactional public class ConfigurationServiceImpl implements ConfigurationService { - @Value("${bunny.bashPath}") - private String bashPath; - - private static @NotNull String getWebConfigString(InputStream inputStream, Path templatePath) throws IOException { - if (inputStream == null) throw new AuthCustomerException(ResultCodeEnum.MISSING_TEMPLATE_FILES); - - // 判断web模板文件是否存在,不存在进行复制 - boolean exists = Files.exists(templatePath); - if (!exists) Files.copy(inputStream, templatePath); - - // 将读取文件返回 - byte[] bytes = Files.readAllBytes(templatePath); - return new String(bytes); - } + @Autowired + private RedisTemplate redisTemplate; /** * * 更新web配置 @@ -43,26 +29,14 @@ public class ConfigurationServiceImpl implements ConfigurationService { * @param dto 前端配置选项 */ @Override - @CacheEvict(cacheNames = "webConfig", key = "'platformConfig'", beforeInvocation = true, cacheManager = "cacheManagerWithMouth") public void updateWebConfiguration(WebConfigurationDto dto) { - try { - // 系统模板文件位置 - Path templatePath = Path.of(bashPath + "/platform-config.json"); + redisTemplate.delete(RedisUserConstant.WEB_CONFIG_KEY); - // 提交表单转换 - WebConfiguration webConfiguration = new WebConfiguration(); - BeanUtils.copyProperties(dto, webConfiguration); + // 提交表单转换 + WebConfiguration webConfiguration = new WebConfiguration(); + BeanUtils.copyProperties(dto, webConfiguration); - // 将表单转成存储的类型 - WebConfigurationVo webConfigurationVo = new WebConfigurationVo(); - BeanUtils.copyProperties(webConfiguration, webConfigurationVo); - - // 将文件写入 - String jsonString = JSON.toJSONString(webConfigurationVo); - Files.writeString(templatePath, jsonString); - } catch (IOException e) { - throw new RuntimeException(e); - } + redisTemplate.opsForValue().set(RedisUserConstant.WEB_CONFIG_KEY, webConfiguration); } /** @@ -71,32 +45,24 @@ public class ConfigurationServiceImpl implements ConfigurationService { * @return 前端配置文件 */ @Override - @Cacheable(cacheNames = "webConfig", key = "'platformConfig'", cacheManager = "cacheManagerWithMouth") public WebConfiguration webConfig() { - // 系统模板文件位置 - Path templatePath = Path.of(bashPath + "/platform-config.json"); - - try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("static/platform-config.json")) { - String string = getWebConfigString(inputStream, templatePath); - return JSON.parseObject(string, WebConfiguration.class); - } catch (IOException exception) { - throw new AuthCustomerException(exception.getMessage()); + // 判断Redis中是否存在 + Object object = redisTemplate.opsForValue().get(RedisUserConstant.WEB_CONFIG_KEY); + if (object != null) { + String jsonString = JSON.toJSONString(object); + return JSON.parseObject(jsonString, WebConfiguration.class); } - } - - /** - * 获取修改web配置文件 - * - * @return 要修改前端配置文件 - */ - @Override - public WebConfigurationVo getWebConfig() { - // 系统模板文件位置 - Path templatePath = Path.of(bashPath + "/platform-config.json"); + // 不存在从文件中获取 try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("static/platform-config.json")) { - String string = getWebConfigString(inputStream, templatePath); - return JSON.parseObject(string, WebConfigurationVo.class); + if (inputStream == null) throw new AuthCustomerException(ResultCodeEnum.MISSING_TEMPLATE_FILES); + + // 读取文件返回并存入Redis + byte[] bytes = inputStream.readAllBytes(); + WebConfiguration webConfiguration = JSON.parseObject(new String(bytes), WebConfiguration.class); + redisTemplate.opsForValue().set(RedisUserConstant.WEB_CONFIG_KEY, webConfiguration); + + return webConfiguration; } catch (IOException exception) { throw new AuthCustomerException(exception.getMessage()); } diff --git a/service/src/main/resources/banner.txt b/service/src/main/resources/banner.txt index 17f911a..b905910 100644 --- a/service/src/main/resources/banner.txt +++ b/service/src/main/resources/banner.txt @@ -4,4 +4,7 @@ | |_) | |_| | | | | | | | |_| | | | (_| |\ V | (_| | |_.__/ \__,_|_| |_|_| |_|\__, | _/ |\__,_| \_/ \__,_| |___/ |__/ + +${spring-boot.formatted-version} +${application.title} SpringBoot Version: ${spring-boot.version}${spring-boot.formatted-version}