From 96d498fbbfdfc95c0b8d12b76c1100e25ebb9072 Mon Sep 17 00:00:00 2001 From: zhuoda Date: Wed, 8 Jan 2025 20:14:53 +0800 Subject: [PATCH] =?UTF-8?q?v3.12=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E9=A1=B5Chome=E6=A8=A1=E5=BC=8F;=E3=80=90?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E3=80=91=E4=BC=98=E5=8C=96=E5=BE=88=E5=A4=9A?= =?UTF-8?q?=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- smart-admin-api-java17-springboot3/.gitignore | 35 -- .../support/AdminSmartJobController.java | 16 + .../sa/base/config/DataSourceConfig.java | 8 +- .../lab1024/sa/base/config/JsonConfig.java | 2 +- .../lab1024/sa/base/config/RedisConfig.java | 5 +- .../lab1024/sa/base/config/TokenConfig.java | 33 ++ .../net/lab1024/sa/base/config/UrlConfig.java | 6 +- .../support/captcha/CaptchaService.java | 4 +- .../backend/domain/EntityVariableService.java | 2 +- .../support/dict/service/DictService.java | 78 ++-- .../support/job/api/SmartJobService.java | 103 ++++-- .../job/api/domain/SmartJobAddForm.java | 58 +++ .../job/api/domain/SmartJobQueryForm.java | 3 + .../job/api/domain/SmartJobUpdateForm.java | 40 +- .../support/job/constant/SmartJobUtil.java | 24 +- .../support/job/core/SmartJobLauncher.java | 5 + .../support/job/repository/SmartJobDao.java | 16 + .../job/repository/domain/SmartJobEntity.java | 5 + .../base/module/support/mail/MailService.java | 4 +- .../core/AbstractSmartReloadCommand.java | 34 +- .../reload/core/SmartReloadManager.java | 77 ++-- .../core/thread/SmartReloadRunnable.java | 20 +- .../service/Level3ProtectConfigService.java | 2 +- .../service/SecurityFileService.java | 2 + .../java/controller/Controller.java.vm | 2 +- .../java/dao/Dao.java.vm | 1 - .../src/main/resources/dev/sa-base.yaml | 2 +- .../mapper/support/SmartJobMapper.xml | 15 + .../src/main/resources/prod/sa-base.yaml | 25 +- .../support/AdminSmartJobController.java | 16 + .../lab1024/sa/base/config/TokenConfig.java | 34 ++ .../net/lab1024/sa/base/config/UrlConfig.java | 8 +- .../support/dict/service/DictService.java | 80 ++-- .../support/job/api/SmartJobService.java | 104 ++++-- .../job/api/domain/SmartJobAddForm.java | 59 +++ .../job/api/domain/SmartJobQueryForm.java | 3 + .../job/api/domain/SmartJobUpdateForm.java | 45 +-- .../support/job/constant/SmartJobUtil.java | 24 +- .../support/job/core/SmartJobLauncher.java | 5 + .../support/job/repository/SmartJobDao.java | 16 + .../job/repository/domain/SmartJobEntity.java | 5 + .../service/Level3ProtectConfigService.java | 2 +- .../mapper/support/SmartJobMapper.xml | 15 + .../src/api/support/job-api.js | 8 + .../src/assets/images/nav/active_bg2.svg | 3 + .../assets/images/nav/active_bg2_default.svg | 3 + .../src/config/app-config.js | 2 +- .../src/constants/layout-const.js | 4 + .../header-user-space/header-setting.vue | 3 +- .../page-tag/components/chrome-tab.vue | 342 ++++++++++++++++++ .../src/layout/components/page-tag/index.vue | 2 + .../side-expand-menu/recursion-menu.vue | 41 ++- .../src/layout/help-doc-layout.vue | 1 + .../src/store/modules/system/user.js | 1 + .../views/business/oa/notice/notice-list.vue | 2 +- ...code-generator-table-config-form-basic.vue | 16 +- .../job/components/deleted-job-list.vue | 283 +++++++++++++++ .../support/job/components/job-form-modal.vue | 280 +++++++------- .../src/views/support/job/job-list.vue | 284 +++++++++------ .../menu/components/menu-operate-modal.vue | 6 +- .../src/api/support/job-api.ts | 8 + .../src/assets/images/nav/active_bg2.svg | 3 + .../assets/images/nav/active_bg2_default.svg | 3 + .../src/constants/layout-const.ts | 4 + .../header-user-space/header-setting.vue | 3 +- .../page-tag/components/chrome-tab.vue | 342 ++++++++++++++++++ .../src/layout/components/page-tag/index.vue | 2 + .../side-expand-menu/recursion-menu.vue | 41 ++- .../src/layout/help-doc-layout.vue | 1 + .../src/layout/side-layout.vue | 9 +- .../src/types/config.d.ts | 2 +- .../job/components/deleted-job-list.vue | 283 +++++++++++++++ .../support/job/components/job-form-modal.vue | 280 +++++++------- .../src/views/support/job/job-list.vue | 284 +++++++++------ .../menu/components/menu-operate-modal.vue | 6 +- smart-app/src/store/modules/system/user.js | 10 +- smart_admin_v3.sql | 18 +- 77 files changed, 2713 insertions(+), 910 deletions(-) delete mode 100644 smart-admin-api-java17-springboot3/.gitignore create mode 100644 smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/config/TokenConfig.java create mode 100644 smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobAddForm.java create mode 100644 smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/config/TokenConfig.java create mode 100644 smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobAddForm.java create mode 100644 smart-admin-web-javascript/src/assets/images/nav/active_bg2.svg create mode 100644 smart-admin-web-javascript/src/assets/images/nav/active_bg2_default.svg create mode 100644 smart-admin-web-javascript/src/layout/components/page-tag/components/chrome-tab.vue create mode 100644 smart-admin-web-javascript/src/views/support/job/components/deleted-job-list.vue create mode 100644 smart-admin-web-typescript/src/assets/images/nav/active_bg2.svg create mode 100644 smart-admin-web-typescript/src/assets/images/nav/active_bg2_default.svg create mode 100644 smart-admin-web-typescript/src/layout/components/page-tag/components/chrome-tab.vue create mode 100644 smart-admin-web-typescript/src/views/support/job/components/deleted-job-list.vue diff --git a/smart-admin-api-java17-springboot3/.gitignore b/smart-admin-api-java17-springboot3/.gitignore deleted file mode 100644 index ab428af8b..000000000 --- a/smart-admin-api-java17-springboot3/.gitignore +++ /dev/null @@ -1,35 +0,0 @@ -HELP.md -target/ - -velocity.log - -!.mvn/wrapper/maven-wrapper.jar - - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -.DS_Store - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ - -### VS Code ### -.vscode/ diff --git a/smart-admin-api-java17-springboot3/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/support/AdminSmartJobController.java b/smart-admin-api-java17-springboot3/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/support/AdminSmartJobController.java index 71d80a84c..02e5ceaed 100644 --- a/smart-admin-api-java17-springboot3/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/support/AdminSmartJobController.java +++ b/smart-admin-api-java17-springboot3/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/support/AdminSmartJobController.java @@ -52,6 +52,15 @@ public ResponseDTO> queryJob(@RequestBody @Valid SmartJob return jobService.queryJob(queryForm); } + @Operation(summary = "定时任务-添加任务 @huke") + @PostMapping("/job/add") + @RepeatSubmit + public ResponseDTO addJob(@RequestBody @Valid SmartJobAddForm addForm) { + RequestUser requestUser = SmartRequestUtil.getRequestUser(); + addForm.setUpdateName(requestUser.getUserName()); + return jobService.addJob(addForm); + } + @Operation(summary = "定时任务-更新-任务信息 @huke") @PostMapping("/job/update") @RepeatSubmit @@ -70,6 +79,13 @@ public ResponseDTO updateJobEnabled(@RequestBody @Valid SmartJobEnabledU return jobService.updateJobEnabled(updateForm); } + @Operation(summary = "定时任务-删除 @zhuoda") + @GetMapping("/job/delete") + @RepeatSubmit + public ResponseDTO deleteJob(@RequestParam Integer jobId) { + return jobService.deleteJob(jobId, SmartRequestUtil.getRequestUser()); + } + @Operation(summary = "定时任务-执行记录-分页查询 @huke") @PostMapping("/job/log/query") public ResponseDTO> queryJobLog(@RequestBody @Valid SmartJobLogQueryForm queryForm) { diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/config/DataSourceConfig.java b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/config/DataSourceConfig.java index 54dcd2f66..91f440198 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/config/DataSourceConfig.java +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/config/DataSourceConfig.java @@ -10,7 +10,6 @@ import com.baomidou.mybatisplus.core.config.GlobalConfig; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean; -import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import net.lab1024.sa.base.common.domain.DataScopePlugin; import net.lab1024.sa.base.handler.MybatisPlusFillHandler; @@ -25,6 +24,7 @@ import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; +import org.springframework.core.io.Resource; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import javax.sql.DataSource; @@ -92,10 +92,10 @@ public class DataSourceConfig { @Value("${spring.datasource.druid.method.pointcut}") String methodPointcut; - @Resource + @jakarta.annotation.Resource private MybatisPlusInterceptor paginationInterceptor; - @Resource + @jakarta.annotation.Resource private DataScopePlugin dataScopePlugin; @Bean @@ -136,7 +136,7 @@ public SqlSessionFactory sqlSessionFactory() throws Exception { MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean(); factoryBean.setDataSource(druidDataSource()); PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); - org.springframework.core.io.Resource[] resources = resolver.getResources("classpath*:/mapper/**/*.xml"); + Resource[] resources = resolver.getResources("classpath*:/mapper/**/*.xml"); factoryBean.setMapperLocations(resources); // 设置 MyBatis-Plus 分页插件 注意此处myBatisPlugin一定要放在后面 diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/config/JsonConfig.java b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/config/JsonConfig.java index b9605c3c7..9164b35c5 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/config/JsonConfig.java +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/config/JsonConfig.java @@ -18,7 +18,7 @@ import java.time.format.DateTimeParseException; /** - * Json 序列化配置 + * json 序列化配置 * * @Author 1024创新实验室-主任: 卓大 * @Date 2017-11-28 15:21:10 diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/config/RedisConfig.java b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/config/RedisConfig.java index 98dcce8a0..5d1357c39 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/config/RedisConfig.java +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/config/RedisConfig.java @@ -33,7 +33,7 @@ public class RedisConfig { @Bean public RedisTemplate redisTemplate() { - + Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); ObjectMapper om = new ObjectMapper(); om.registerModule(new JavaTimeModule()) .configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false) @@ -41,10 +41,11 @@ public RedisTemplate redisTemplate() { .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false) .setSerializationInclusion(JsonInclude.Include.NON_NULL); - Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(om, Object.class); + om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); // enableDefaultTyping 官方已弃用 所以改为 activateDefaultTyping om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL); + jackson2JsonRedisSerializer.setObjectMapper(om); RedisTemplate template = new RedisTemplate<>(); template.setConnectionFactory(factory); template.setKeySerializer(new StringRedisSerializer()); diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/config/TokenConfig.java b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/config/TokenConfig.java new file mode 100644 index 000000000..8e3d36c48 --- /dev/null +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/config/TokenConfig.java @@ -0,0 +1,33 @@ +package net.lab1024.sa.base.config; + +import cn.dev33.satoken.config.SaTokenConfig; +import jakarta.annotation.Resource; +import net.lab1024.sa.base.module.support.securityprotect.service.Level3ProtectConfigService; +import org.springframework.context.annotation.Configuration; + +/** + * + * 三级等保配置初始化后最低活跃频率全局配置 + * + * @Author 1024创新实验室-创始人兼主任:卓大 + * @Date 2024/11/24 + * @Wechat zhuoda1024 + * @Email lab1024@163.com + * @Copyright 1024创新实验室 ,Since 2012 + */ + +@Configuration +public class TokenConfig { + + @Resource + private Level3ProtectConfigService level3ProtectConfigService; + + // 此配置会覆盖 sa-base.yaml 中的配置 + @Resource + public void configSaToken(SaTokenConfig config) { + + config.setActiveTimeout(level3ProtectConfigService.getLoginActiveTimeoutSeconds()); + } + + +} diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/config/UrlConfig.java b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/config/UrlConfig.java index 4937a9ffe..b1af7ae6a 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/config/UrlConfig.java +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/config/UrlConfig.java @@ -13,6 +13,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.method.HandlerMethod; +import org.springframework.web.servlet.mvc.condition.PathPatternsRequestCondition; import org.springframework.web.servlet.mvc.method.RequestMappingInfo; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; @@ -47,11 +48,12 @@ public Map> methodUrlMap() { Map map = requestMappingHandlerMapping.getHandlerMethods(); for (Map.Entry entry : map.entrySet()) { RequestMappingInfo requestMappingInfo = entry.getKey(); - if(requestMappingInfo.getPatternsCondition() == null){ + PathPatternsRequestCondition pathPatternsCondition = requestMappingInfo.getPathPatternsCondition(); + if(pathPatternsCondition == null){ continue; } - Set urls = requestMappingInfo.getPatternsCondition().getPatterns(); + Set urls = pathPatternsCondition.getPatternValues(); if (CollectionUtils.isEmpty(urls)) { continue; } diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/captcha/CaptchaService.java b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/captcha/CaptchaService.java index d63f87c7b..c7913f19d 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/captcha/CaptchaService.java +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/captcha/CaptchaService.java @@ -42,8 +42,10 @@ public class CaptchaService { @Resource private DefaultKaptcha defaultKaptcha; - @Autowired + + @Resource private SystemEnvironment systemEnvironment; + @Resource private RedisService redisService; diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/codegenerator/service/variable/backend/domain/EntityVariableService.java b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/codegenerator/service/variable/backend/domain/EntityVariableService.java index 8dd9e4097..391bffa4a 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/codegenerator/service/variable/backend/domain/EntityVariableService.java +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/codegenerator/service/variable/backend/domain/EntityVariableService.java @@ -14,7 +14,7 @@ * @Date 2022/9/29 17:20:41 * @Wechat zhuoda1024 * @Email lab1024@163.com - * @Copyright 1024创新实验室 + * @Copyright 1024创新实验室 */ public class EntityVariableService extends CodeGenerateBaseVariableService { diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/dict/service/DictService.java b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/dict/service/DictService.java index 9fba4d060..e84280ed9 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/dict/service/DictService.java +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/dict/service/DictService.java @@ -28,7 +28,7 @@ * @Date 2022/5/26 19:40:55 * @Wechat zhuoda1024 * @Email lab1024@163.com - * @Copyright 1024创新实验室 + * @Copyright 1024创新实验室 */ @Service public class DictService { @@ -39,10 +39,6 @@ public class DictService { private DictValueDao dictValueDao; @Resource private DictCacheService dictCacheService; - /** - * CODE锁 - */ - private static final Interner CODE_POOL = Interners.newWeakInterner(); /** @@ -51,15 +47,15 @@ public class DictService { * @param keyAddForm * @return */ - public ResponseDTO keyAdd(DictKeyAddForm keyAddForm) { - synchronized (CODE_POOL.intern(keyAddForm.getKeyCode())) { - DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyAddForm.getKeyCode(), false); - if (dictKeyEntity != null) { - return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); - } - dictKeyEntity = SmartBeanUtil.copy(keyAddForm, DictKeyEntity.class); - dictKeyDao.insert(dictKeyEntity); + public synchronized ResponseDTO keyAdd(DictKeyAddForm keyAddForm) { + DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyAddForm.getKeyCode(), false); + if (dictKeyEntity != null) { + return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); } + dictKeyEntity = SmartBeanUtil.copy(keyAddForm, DictKeyEntity.class); + dictKeyDao.insert(dictKeyEntity); + //刷新缓存 + dictCacheService.cacheRefresh(); return ResponseDTO.ok(); } @@ -69,15 +65,15 @@ public ResponseDTO keyAdd(DictKeyAddForm keyAddForm) { * @param valueAddForm * @return */ - public ResponseDTO valueAdd(DictValueAddForm valueAddForm) { - synchronized (CODE_POOL.intern(valueAddForm.getValueCode())) { - DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueAddForm.getValueCode(), false); - if (dictValueEntity != null) { - return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); - } - dictValueEntity = SmartBeanUtil.copy(valueAddForm, DictValueEntity.class); - dictValueDao.insert(dictValueEntity); + public synchronized ResponseDTO valueAdd(DictValueAddForm valueAddForm) { + DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueAddForm.getValueCode(), false); + if (dictValueEntity != null) { + return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); } + dictValueEntity = SmartBeanUtil.copy(valueAddForm, DictValueEntity.class); + dictValueDao.insert(dictValueEntity); + //刷新缓存 + dictCacheService.cacheRefresh(); return ResponseDTO.ok(); } @@ -87,15 +83,15 @@ public ResponseDTO valueAdd(DictValueAddForm valueAddForm) { * @param keyUpdateForm * @return */ - public ResponseDTO keyEdit(DictKeyUpdateForm keyUpdateForm) { - synchronized (CODE_POOL.intern(keyUpdateForm.getKeyCode())) { - DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyUpdateForm.getKeyCode(), false); - if (dictKeyEntity != null && !dictKeyEntity.getDictKeyId().equals(keyUpdateForm.getDictKeyId())) { - return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); - } - DictKeyEntity dictKeyUpdateEntity = SmartBeanUtil.copy(keyUpdateForm, DictKeyEntity.class); - dictKeyDao.updateById(dictKeyUpdateEntity); + public synchronized ResponseDTO keyEdit(DictKeyUpdateForm keyUpdateForm) { + DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyUpdateForm.getKeyCode(), false); + if (dictKeyEntity != null && !dictKeyEntity.getDictKeyId().equals(keyUpdateForm.getDictKeyId())) { + return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); } + DictKeyEntity dictKeyUpdateEntity = SmartBeanUtil.copy(keyUpdateForm, DictKeyEntity.class); + dictKeyDao.updateById(dictKeyUpdateEntity); + //刷新缓存 + dictCacheService.cacheRefresh(); return ResponseDTO.ok(); } @@ -105,19 +101,19 @@ public ResponseDTO keyEdit(DictKeyUpdateForm keyUpdateForm) { * @param valueUpdateForm * @return */ - public ResponseDTO valueEdit(DictValueUpdateForm valueUpdateForm) { + public synchronized ResponseDTO valueEdit(DictValueUpdateForm valueUpdateForm) { DictKeyEntity dictKeyEntity = dictKeyDao.selectById(valueUpdateForm.getDictKeyId()); if (dictKeyEntity == null || dictKeyEntity.getDeletedFlag()) { return ResponseDTO.userErrorParam("key不能存在"); } - synchronized (CODE_POOL.intern(valueUpdateForm.getValueCode())) { - DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueUpdateForm.getValueCode(), false); - if (dictValueEntity != null && !dictValueEntity.getDictValueId().equals(valueUpdateForm.getDictValueId())) { - return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); - } - DictValueEntity dictValueUpdateEntity = SmartBeanUtil.copy(valueUpdateForm, DictValueEntity.class); - dictValueDao.updateById(dictValueUpdateEntity); + DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueUpdateForm.getValueCode(), false); + if (dictValueEntity != null && !dictValueEntity.getDictValueId().equals(valueUpdateForm.getDictValueId())) { + return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); } + DictValueEntity dictValueUpdateEntity = SmartBeanUtil.copy(valueUpdateForm, DictValueEntity.class); + dictValueDao.updateById(dictValueUpdateEntity); + //刷新缓存 + dictCacheService.cacheRefresh(); return ResponseDTO.ok(); } @@ -127,11 +123,13 @@ public ResponseDTO valueEdit(DictValueUpdateForm valueUpdateForm) { * @param keyIdList * @return */ - public ResponseDTO keyDelete(List keyIdList) { + public synchronized ResponseDTO keyDelete(List keyIdList) { if (CollectionUtils.isEmpty(keyIdList)) { return ResponseDTO.ok(); } dictKeyDao.updateDeletedFlagByIdList(keyIdList, true); + //刷新缓存 + dictCacheService.cacheRefresh(); return ResponseDTO.ok(); } @@ -141,11 +139,13 @@ public ResponseDTO keyDelete(List keyIdList) { * @param valueIdList * @return */ - public ResponseDTO valueDelete(List valueIdList) { + public synchronized ResponseDTO valueDelete(List valueIdList) { if (CollectionUtils.isEmpty(valueIdList)) { return ResponseDTO.ok(); } dictValueDao.updateDeletedFlagByIdList(valueIdList, true); + //刷新缓存 + dictCacheService.cacheRefresh(); return ResponseDTO.ok(); } diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/SmartJobService.java b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/SmartJobService.java index b3ef1b9f8..836f42fa6 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/SmartJobService.java +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/SmartJobService.java @@ -5,6 +5,7 @@ import jakarta.annotation.Resource; import net.lab1024.sa.base.common.code.UserErrorCode; import net.lab1024.sa.base.common.domain.PageResult; +import net.lab1024.sa.base.common.domain.RequestUser; import net.lab1024.sa.base.common.domain.ResponseDTO; import net.lab1024.sa.base.common.util.SmartBeanUtil; import net.lab1024.sa.base.common.util.SmartPageUtil; @@ -125,27 +126,61 @@ public ResponseDTO> queryJobLog(SmartJobLogQueryForm q return ResponseDTO.ok(pageResult); } + /** + * 添加定时任务 + * + * @param addForm + * @return + */ + public synchronized ResponseDTO addJob(SmartJobAddForm addForm) { + // 校验参数 + ResponseDTO checkRes = this.checkParam(addForm); + if (!checkRes.getOk()) { + return checkRes; + } + + // 校验重复的执行类 + SmartJobEntity existJobClass = jobDao.selectByJobClass(addForm.getJobClass()); + if (null != existJobClass && !existJobClass.getDeletedFlag()) { + return ResponseDTO.userErrorParam("已经存在相同的执行类"); + } + + // 添加数据 + SmartJobEntity jobEntity = SmartBeanUtil.copy(addForm, SmartJobEntity.class); + jobDao.insert(jobEntity); + + // 更新执行端 + SmartJobMsg jobMsg = new SmartJobMsg(); + jobMsg.setJobId(jobEntity.getJobId()); + jobMsg.setMsgType(SmartJobMsg.MsgTypeEnum.UPDATE_JOB); + jobMsg.setUpdateName(addForm.getUpdateName()); + jobClientManager.publishToClient(jobMsg); + return ResponseDTO.ok(); + } + /** * 更新定时任务 * * @param updateForm * @return */ - public ResponseDTO updateJob(SmartJobUpdateForm updateForm) { + public synchronized ResponseDTO updateJob(SmartJobUpdateForm updateForm) { // 校验参数 Integer jobId = updateForm.getJobId(); SmartJobEntity jobEntity = jobDao.selectById(jobId); if (null == jobEntity) { return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST); } - // 校验触发时间配置 - String triggerType = updateForm.getTriggerType(); - String triggerValue = updateForm.getTriggerValue(); - if (SmartJobTriggerTypeEnum.CRON.equalsValue(triggerType) && !SmartJobUtil.checkCron(triggerValue)) { - return ResponseDTO.userErrorParam("cron表达式错误"); + + ResponseDTO checkRes = this.checkParam(updateForm); + if (!checkRes.getOk()) { + return checkRes; } - if (SmartJobTriggerTypeEnum.FIXED_DELAY.equalsValue(triggerType) && !SmartJobUtil.checkFixedDelay(triggerValue)) { - return ResponseDTO.userErrorParam("固定间隔错误:整数且大于0"); + + // 校验重复的执行类 + SmartJobEntity existJobClass = jobDao.selectByJobClass(updateForm.getJobClass()); + if (null != existJobClass && !existJobClass.getDeletedFlag() && !existJobClass.getJobId().equals(jobId)) { + return ResponseDTO.userErrorParam("已经存在相同的执行类"); } // 更新数据 @@ -161,6 +196,27 @@ public ResponseDTO updateJob(SmartJobUpdateForm updateForm) { return ResponseDTO.ok(); } + /** + * 校验参数 + * 如需其他校验,请自行添加校验逻辑 + * + * @param addForm + * @return + */ + private ResponseDTO checkParam(SmartJobAddForm addForm) { + // 校验触发时间配置 + String triggerType = addForm.getTriggerType(); + String triggerValue = addForm.getTriggerValue(); + if (SmartJobTriggerTypeEnum.CRON.equalsValue(triggerType) && !SmartJobUtil.checkCron(triggerValue)) { + return ResponseDTO.userErrorParam("cron表达式错误"); + } + if (SmartJobTriggerTypeEnum.FIXED_DELAY.equalsValue(triggerType) && !SmartJobUtil.checkFixedDelay(triggerValue)) { + return ResponseDTO.userErrorParam("固定间隔配置错误:必须是大于0的整数"); + } + // 校验job class + return SmartJobUtil.checkJobClass(addForm.getJobClass()); + } + /** * 更新定时任务-是否开启 * @@ -217,29 +273,24 @@ public ResponseDTO execute(SmartJobExecuteForm executeForm) { return ResponseDTO.ok(); } - /** - * 新增定时任务 - * ps:目前没有业务场景需要通过接口 添加任务 - * 因为新增定时任务无论如何都需要 手动编码 - * 需要时手动给数据库增加一条就行 - * - * @return - * @author huke - */ - public ResponseDTO addJob() { - return ResponseDTO.userErrorParam("暂未支持"); - } - /** * 移除定时任务 - * ps:目前没有业务场景需要通过接口移除,理由同 {@link SmartJobService#addJob}, - * 彻底移除始终都需要手动删除代码 - * 如果只是想暂停任务执行,可以调用 {@link SmartJobService#updateJobEnabled} + * 物理删除 * * @return * @author huke */ - public ResponseDTO delJob() { - return ResponseDTO.userErrorParam("暂未支持"); + public synchronized ResponseDTO deleteJob(Integer jobId, RequestUser requestUser) { + // 删除任务 + jobDao.updateDeletedFlag(jobId, Boolean.TRUE); + + // 更新执行端 + SmartJobMsg jobMsg = new SmartJobMsg(); + jobMsg.setJobId(jobId); + jobMsg.setMsgType(SmartJobMsg.MsgTypeEnum.UPDATE_JOB); + jobMsg.setUpdateName(requestUser.getUserName()); + jobClientManager.publishToClient(jobMsg); + return ResponseDTO.ok(); } + } diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobAddForm.java b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobAddForm.java new file mode 100644 index 000000000..0ca70f1a6 --- /dev/null +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobAddForm.java @@ -0,0 +1,58 @@ +package net.lab1024.sa.base.module.support.job.api.domain; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import net.lab1024.sa.base.common.swagger.SchemaEnum; +import net.lab1024.sa.base.common.validator.enumeration.CheckEnum; +import net.lab1024.sa.base.module.support.job.constant.SmartJobTriggerTypeEnum; +import org.hibernate.validator.constraints.Length; + +/** + * 定时任务 添加 + * + * @author huke + * @date 2024/12/19 19:30 + */ +@Data +public class SmartJobAddForm { + + @Schema(description = "任务名称") + @NotBlank(message = "任务名称不能为空") + @Length(max = 100, message = "任务名称最多100字符") + private String jobName; + + @Schema(description = "任务执行类") + @NotBlank(message = "任务执行类不能为空") + @Length(max = 200, message = "任务执行类最多200字符") + private String jobClass; + + @SchemaEnum(desc = "触发类型", value = SmartJobTriggerTypeEnum.class) + @CheckEnum(value = SmartJobTriggerTypeEnum.class, required = true, message = "触发类型错误") + private String triggerType; + + @Schema(description = "触发配置") + @NotBlank(message = "触发配置不能为空") + @Length(max = 100, message = "触发配置最多100字符") + private String triggerValue; + + @Schema(description = "定时任务参数|可选") + @Length(max = 1000, message = "定时任务参数最多1000字符") + private String param; + + @Schema(description = "是否开启") + @NotNull(message = "是否开启不能为空") + private Boolean enabledFlag; + + @Schema(description = "备注") + @Length(max = 250, message = "任务备注最多250字符") + private String remark; + + @NotNull(message = "排序不能为空") + @Schema(description = "排序") + private Integer sort; + + @Schema(hidden = true) + private String updateName; +} diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobQueryForm.java b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobQueryForm.java index a6091af7b..39a56c704 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobQueryForm.java +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobQueryForm.java @@ -27,4 +27,7 @@ public class SmartJobQueryForm extends PageParam { @Schema(description = "是否启用|可选") private Boolean enabledFlag; + + @Schema(description = "是否删除|可选") + private Boolean deletedFlag; } diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobUpdateForm.java b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobUpdateForm.java index 489f31587..860b4a92c 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobUpdateForm.java +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobUpdateForm.java @@ -16,47 +16,9 @@ * @date 2024/6/17 21:30 */ @Data -public class SmartJobUpdateForm { +public class SmartJobUpdateForm extends SmartJobAddForm { @Schema(description = "任务id") @NotNull(message = "任务id不能为空") private Integer jobId; - - @Schema(description = "任务名称") - @NotBlank(message = "任务名称不能为空") - @Length(max = 100, message = "任务名称最多100字符") - private String jobName; - - @Schema(description = "任务执行类") - @NotBlank(message = "任务执行类不能为空") - @Length(max = 200, message = "任务执行类最多200字符") - private String jobClass; - - @SchemaEnum(desc = "触发类型", value = SmartJobTriggerTypeEnum.class) - @CheckEnum(value = SmartJobTriggerTypeEnum.class, required = true, message = "触发类型错误") - private String triggerType; - - @Schema(description = "触发配置") - @NotBlank(message = "触发配置不能为空") - @Length(max = 100, message = "触发配置最多100字符") - private String triggerValue; - - @Schema(description = "定时任务参数|可选") - @Length(max = 1000, message = "定时任务参数最多1000字符") - private String param; - - @Schema(description = "是否开启") - @NotNull(message = "是否开启不能为空") - private Boolean enabledFlag; - - @Schema(description = "备注") - @Length(max = 250, message = "任务备注最多250字符") - private String remark; - - @NotNull(message = "排序不能为空") - @Schema(description = "排序") - private Integer sort; - - @Schema(hidden = true) - private String updateName; } diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/constant/SmartJobUtil.java b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/constant/SmartJobUtil.java index adb2497d6..ac21b3daf 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/constant/SmartJobUtil.java +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/constant/SmartJobUtil.java @@ -1,5 +1,7 @@ package net.lab1024.sa.base.module.support.job.constant; +import net.lab1024.sa.base.common.domain.ResponseDTO; +import net.lab1024.sa.base.module.support.job.core.SmartJob; import org.springframework.scheduling.support.CronExpression; import java.lang.management.ManagementFactory; @@ -98,7 +100,7 @@ public static List queryNextTimeFromNow(String triggerType, } else if (SmartJobTriggerTypeEnum.FIXED_DELAY.equalsValue(triggerType)) { Integer fixedDelay = getFixedDelayVal(triggerVal); LocalDateTime startTime = null == lastExecuteTime || lastExecuteTime.plusSeconds(fixedDelay).isBefore(nowTime) - ? nowTime : lastExecuteTime; + ? nowTime : lastExecuteTime; nextTimeList = SmartJobUtil.queryNextTime(fixedDelay, startTime, num); } return nextTimeList; @@ -174,6 +176,24 @@ public static String getProcessId() { return runtime.getName().split("@")[0]; } + + /** + * 根据className 判断job class + */ + public static ResponseDTO checkJobClass(String className) { + try { + Class aClass = Class.forName(className); + // 判断是否实现了 SmartJob + if (!SmartJob.class.isAssignableFrom(aClass)) { + return ResponseDTO.userErrorParam(className + " 执行类没有实现 SmartJob 接口"); + } + } catch (ClassNotFoundException e) { + return ResponseDTO.userErrorParam("没有在代码中发现执行类:" + className); + } + return ResponseDTO.ok(); + } + + public static void main(String[] args) { LocalDateTime startTime = LocalDateTime.now(); List timeList = SmartJobUtil.queryNextTime("5 * * * * *", startTime, 3); @@ -184,5 +204,7 @@ public static void main(String[] args) { System.out.println("project path ->" + getProgramPath()); System.out.println("project process id ->" + getProcessId()); + ResponseDTO res = checkJobClass("net.lab1024.sa.base.module.support.job.sample.SmartJobSample1"); + System.out.println(res.getMsg()); } } diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/core/SmartJobLauncher.java b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/core/SmartJobLauncher.java index 6183a5938..04dd72e59 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/core/SmartJobLauncher.java +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/core/SmartJobLauncher.java @@ -103,6 +103,10 @@ public void startOrRefreshJob(List smartJobList) { if (!jobEntity.getEnabledFlag()) { continue; } + // 任务删除 + if (jobEntity.getDeletedFlag()) { + continue; + } // 查找任务实现类 SmartJob jobImpl = jobImplMap.get(jobEntity.getJobClass()); if (null == jobImpl) { @@ -135,6 +139,7 @@ private List queryJob() { private static boolean isNeedUpdate(SmartJobEntity oldJob, SmartJobEntity newJob) { // cron为空时 fixedDelay 才有意义 return !Objects.equals(oldJob.getEnabledFlag(), newJob.getEnabledFlag()) + || !Objects.equals(oldJob.getDeletedFlag(), newJob.getDeletedFlag()) || !Objects.equals(oldJob.getTriggerType(), newJob.getTriggerType()) || !Objects.equals(oldJob.getTriggerValue(), newJob.getTriggerValue()) || !Objects.equals(oldJob.getJobClass(), newJob.getJobClass()); diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/repository/SmartJobDao.java b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/repository/SmartJobDao.java index 703a90de2..002e03fc2 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/repository/SmartJobDao.java +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/repository/SmartJobDao.java @@ -29,4 +29,20 @@ public interface SmartJobDao extends BaseMapper { * @return */ List query(Page page, @Param("query") SmartJobQueryForm queryForm); + + /** + * 假删除 + * + * @param jobId + * @return + */ + void updateDeletedFlag(@Param("jobId") Integer jobId, @Param("deletedFlag") Boolean deletedFlag); + + /** + * 根据 任务class 查找 + * + * @param jobClass + * @return + */ + SmartJobEntity selectByJobClass(@Param("jobClass") String jobClass); } diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/repository/domain/SmartJobEntity.java b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/repository/domain/SmartJobEntity.java index 7b4708798..890bc6369 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/repository/domain/SmartJobEntity.java +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/repository/domain/SmartJobEntity.java @@ -76,6 +76,11 @@ public class SmartJobEntity { */ private Integer sort; + /** + * 是否删除 + */ + private Boolean deletedFlag; + private String updateName; private LocalDateTime updateTime; diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/mail/MailService.java b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/mail/MailService.java index 2c2084dd1..ac5255d60 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/mail/MailService.java +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/mail/MailService.java @@ -6,6 +6,8 @@ import freemarker.template.Configuration; import freemarker.template.Template; import jakarta.annotation.Resource; +import jakarta.mail.MessagingException; +import jakarta.mail.internet.MimeMessage; import lombok.extern.slf4j.Slf4j; import net.lab1024.sa.base.common.domain.ResponseDTO; import net.lab1024.sa.base.common.domain.SystemEnvironment; @@ -23,8 +25,6 @@ import org.springframework.mail.javamail.MimeMessageHelper; import org.springframework.stereotype.Component; -import jakarta.mail.MessagingException; -import jakarta.mail.internet.MimeMessage; import java.io.File; import java.io.StringWriter; import java.io.Writer; diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/reload/core/AbstractSmartReloadCommand.java b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/reload/core/AbstractSmartReloadCommand.java index 9cd13c944..a19aa06b3 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/reload/core/AbstractSmartReloadCommand.java +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/reload/core/AbstractSmartReloadCommand.java @@ -2,9 +2,11 @@ import net.lab1024.sa.base.module.support.reload.core.domain.SmartReloadItem; +import net.lab1024.sa.base.module.support.reload.core.domain.SmartReloadObject; import net.lab1024.sa.base.module.support.reload.core.domain.SmartReloadResult; import java.util.List; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; /** @@ -14,21 +16,29 @@ * @Date 2015-03-02 19:11:52 * @Wechat zhuoda1024 * @Email lab1024@163.com - * @Copyright 1024创新实验室 + * @Copyright 1024创新实验室 */ public abstract class AbstractSmartReloadCommand { /** * 当前ReloadItem的存储器 */ - private static final ConcurrentHashMap TAG_IDENTIFIER_MAP = new ConcurrentHashMap<>(); + private ConcurrentHashMap tagIdentifierMap = new ConcurrentHashMap<>(); + private SmartReloadManager smartReloadManager; + + /** + * @return + */ + public void setReloadManager(SmartReloadManager smartReloadManager) { + this.smartReloadManager = smartReloadManager; + } public void init() { List smartReloadItems = this.readReloadItem(); if (smartReloadItems != null) { for (SmartReloadItem smartReloadItem : smartReloadItems) { - TAG_IDENTIFIER_MAP.put(smartReloadItem.getTag(), smartReloadItem.getIdentification()); + tagIdentifierMap.put(smartReloadItem.getTag(), smartReloadItem.getIdentification()); } } } @@ -57,7 +67,7 @@ public void init() { * @return */ public ConcurrentHashMap getTagIdentifierMap() { - return TAG_IDENTIFIER_MAP; + return tagIdentifierMap; } /** @@ -67,6 +77,20 @@ public ConcurrentHashMap getTagIdentifierMap() { * @param identification */ public void putIdentifierMap(String tag, String identification) { - TAG_IDENTIFIER_MAP.put(tag, identification); + tagIdentifierMap.put(tag, identification); + } + + + /** + * 获取重载对象 + * + * @return + */ + public SmartReloadObject reloadObject(String tag) { + if (this.smartReloadManager == null) { + return null; + } + Map reloadObjectMap = smartReloadManager.reloadObjectMap(); + return reloadObjectMap.get(tag); } } diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/reload/core/SmartReloadManager.java b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/reload/core/SmartReloadManager.java index f1428b242..98773e183 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/reload/core/SmartReloadManager.java +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/reload/core/SmartReloadManager.java @@ -1,19 +1,23 @@ package net.lab1024.sa.base.module.support.reload.core; +import jakarta.annotation.PostConstruct; import jakarta.annotation.PreDestroy; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import net.lab1024.sa.base.module.support.reload.core.annoation.SmartReload; import net.lab1024.sa.base.module.support.reload.core.domain.SmartReloadObject; import net.lab1024.sa.base.module.support.reload.core.thread.SmartReloadRunnable; +import org.springframework.beans.BeansException; import org.springframework.beans.factory.annotation.Value; +import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.stereotype.Service; import org.springframework.util.ReflectionUtils; +import java.lang.reflect.Method; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledThreadPoolExecutor; @@ -32,7 +36,10 @@ */ @Slf4j @Service -public class SmartReloadManager implements ApplicationListener { +public class SmartReloadManager implements BeanPostProcessor { + + private static final String THREAD_NAME_PREFIX = "smart-reload"; + private static final int THREAD_COUNT = 1; @Value("${reload.interval-seconds}") private Integer intervalSeconds; @@ -40,27 +47,13 @@ public class SmartReloadManager implements ApplicationListener RELOAD_OBJECT_MAP = new ConcurrentHashMap<>(); + private final Map reloadObjectMap = new ConcurrentHashMap<>(); private ScheduledThreadPoolExecutor threadPoolExecutor; - private static final String THREAD_NAME_PREFIX = "smart-reload"; - - private static final int THREAD_COUNT = 1; - - private ApplicationContext applicationContext; - - @Override - public void onApplicationEvent(ContextRefreshedEvent event) { - this.applicationContext = event.getApplicationContext(); - - // 初始化 - this.init(); - } + @PostConstruct public void init() { - this.registerReloadBean(); - if (threadPoolExecutor != null) { return; } @@ -73,8 +66,10 @@ public void init() { return t; }); this.threadPoolExecutor.scheduleWithFixedDelay(new SmartReloadRunnable(this.reloadCommand), 10, this.intervalSeconds, TimeUnit.SECONDS); + this.reloadCommand.setReloadManager(this); } + @PreDestroy public void shutdown() { if (this.threadPoolExecutor != null) { @@ -83,28 +78,24 @@ public void shutdown() { } } - /** - * 注册 reload bean - */ - public void registerReloadBean() { - // 遍历所有Bean - String[] beanNames = applicationContext.getBeanDefinitionNames(); - for (String beanName : beanNames) { - Object bean = applicationContext.getBean(beanName); - ReflectionUtils.doWithMethods(bean.getClass(), method -> { - SmartReload smartReload = method.getAnnotation(SmartReload.class); - if (smartReload == null) { - return; - } - int paramCount = method.getParameterCount(); - if (paramCount > 1) { - log.error("<> register tag reload : " + smartReload.value() + " , param count cannot greater than one !"); - return; - } - String reloadTag = smartReload.value(); - this.register(reloadTag, new SmartReloadObject(bean, method)); - }); + + @Override + public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { + Method[] methods = ReflectionUtils.getAllDeclaredMethods(bean.getClass()); + for (Method method : methods) { + SmartReload smartReload = method.getAnnotation(SmartReload.class); + if (smartReload == null) { + continue; + } + int paramCount = method.getParameterCount(); + if (paramCount > 1) { + log.error("<> register tag reload : " + smartReload.value() + " , param count cannot greater than one !"); + continue; + } + String reloadTag = smartReload.value(); + this.register(reloadTag, new SmartReloadObject(bean, method)); } + return bean; } /** @@ -114,10 +105,10 @@ public void registerReloadBean() { * @param smartReloadObject */ private void register(String tag, SmartReloadObject smartReloadObject) { - if (RELOAD_OBJECT_MAP.containsKey(tag)) { + if (reloadObjectMap.containsKey(tag)) { log.error("<> register duplicated tag reload : " + tag + " , and it will be cover!"); } - RELOAD_OBJECT_MAP.put(tag, smartReloadObject); + reloadObjectMap.put(tag, smartReloadObject); } /** @@ -125,7 +116,9 @@ private void register(String tag, SmartReloadObject smartReloadObject) { * * @return */ - public static SmartReloadObject getReloadObject(String tag) { - return RELOAD_OBJECT_MAP.get(tag); + public Map reloadObjectMap() { + return this.reloadObjectMap; } + + } diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/reload/core/thread/SmartReloadRunnable.java b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/reload/core/thread/SmartReloadRunnable.java index c1d787033..88cb1a404 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/reload/core/thread/SmartReloadRunnable.java +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/reload/core/thread/SmartReloadRunnable.java @@ -20,17 +20,17 @@ * @Date 2015-03-02 19:11:52 * @Wechat zhuoda1024 * @Email lab1024@163.com - * @Copyright 1024创新实验室 + * @Copyright 1024创新实验室 */ @Slf4j public class SmartReloadRunnable implements Runnable { - private final AbstractSmartReloadCommand reloadCommand; + private AbstractSmartReloadCommand abstractSmartReloadCommand; private boolean isInit = false; - public SmartReloadRunnable(AbstractSmartReloadCommand reloadCommand) { - this.reloadCommand = reloadCommand; + public SmartReloadRunnable(AbstractSmartReloadCommand abstractSmartReloadCommand) { + this.abstractSmartReloadCommand = abstractSmartReloadCommand; } @Override @@ -47,23 +47,23 @@ public void run() { */ private void doTask() { if (!isInit) { - this.reloadCommand.init(); + this.abstractSmartReloadCommand.init(); isInit = true; return; } - List smartReloadItemList = this.reloadCommand.readReloadItem(); - ConcurrentHashMap tagIdentifierMap = this.reloadCommand.getTagIdentifierMap(); + List smartReloadItemList = this.abstractSmartReloadCommand.readReloadItem(); + ConcurrentHashMap tagIdentifierMap = this.abstractSmartReloadCommand.getTagIdentifierMap(); for (SmartReloadItem smartReloadItem : smartReloadItemList) { String tag = smartReloadItem.getTag(); String tagIdentifier = smartReloadItem.getIdentification(); String preTagChangeIdentifier = tagIdentifierMap.get(tag); // 数据不一致 if (preTagChangeIdentifier == null || !preTagChangeIdentifier.equals(tagIdentifier)) { - this.reloadCommand.putIdentifierMap(tag, tagIdentifier); + this.abstractSmartReloadCommand.putIdentifierMap(tag, tagIdentifier); // 执行重新加载此项的动作 SmartReloadResult smartReloadResult = this.doReload(smartReloadItem); - this.reloadCommand.handleReloadResult(smartReloadResult); + this.abstractSmartReloadCommand.handleReloadResult(smartReloadResult); } } } @@ -76,7 +76,7 @@ private void doTask() { */ private SmartReloadResult doReload(SmartReloadItem smartReloadItem) { SmartReloadResult result = new SmartReloadResult(); - SmartReloadObject smartReloadObject = SmartReloadManager.getReloadObject(smartReloadItem.getTag()); + SmartReloadObject smartReloadObject = this.abstractSmartReloadCommand.reloadObject(smartReloadItem.getTag()); try { if (smartReloadObject == null) { result.setResult(false); diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/securityprotect/service/Level3ProtectConfigService.java b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/securityprotect/service/Level3ProtectConfigService.java index 2d9d45517..ad39fc4e0 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/securityprotect/service/Level3ProtectConfigService.java +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/securityprotect/service/Level3ProtectConfigService.java @@ -44,7 +44,7 @@ public class Level3ProtectConfigService { /** * 最低活跃时间(单位:秒),超过此时间没有操作系统就会被冻结,默认-1 代表不限制,永不冻结; 默认 30分钟 */ - private int loginActiveTimeoutSeconds = 1800; + private int loginActiveTimeoutSeconds = -1; /** * 密码复杂度 是否开启,默认:开启 diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/securityprotect/service/SecurityFileService.java b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/securityprotect/service/SecurityFileService.java index b35977a7e..6774a43c2 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/securityprotect/service/SecurityFileService.java +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/module/support/securityprotect/service/SecurityFileService.java @@ -5,6 +5,8 @@ import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; +import java.io.File; + /** * 三级等保 文件上传 相关 * diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/resources/code-generator-template/java/controller/Controller.java.vm b/smart-admin-api-java17-springboot3/sa-base/src/main/resources/code-generator-template/java/controller/Controller.java.vm index 026d5cc41..3d0657b8d 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/resources/code-generator-template/java/controller/Controller.java.vm +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/resources/code-generator-template/java/controller/Controller.java.vm @@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.Operation; - +import cn.dev33.satoken.annotation.SaCheckPermission; import jakarta.annotation.Resource; import jakarta.validation.Valid; diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/resources/code-generator-template/java/dao/Dao.java.vm b/smart-admin-api-java17-springboot3/sa-base/src/main/resources/code-generator-template/java/dao/Dao.java.vm index 3fb0f52e7..dd01bbc03 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/resources/code-generator-template/java/dao/Dao.java.vm +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/resources/code-generator-template/java/dao/Dao.java.vm @@ -49,5 +49,4 @@ public interface ${name.upperCamel}Dao extends BaseMapper<${name.upperCamel}Enti #end #end #end - } diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/resources/dev/sa-base.yaml b/smart-admin-api-java17-springboot3/sa-base/src/main/resources/dev/sa-base.yaml index 4b2c4094a..1600d3101 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/resources/dev/sa-base.yaml +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/resources/dev/sa-base.yaml @@ -40,7 +40,7 @@ spring: host: smtp.163.com port: 465 username: lab1024@163.com - password: ROIMSIQCEXHTQFTA + password: LAB1024LAB properties: mail: smtp: diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/resources/mapper/support/SmartJobMapper.xml b/smart-admin-api-java17-springboot3/sa-base/src/main/resources/mapper/support/SmartJobMapper.xml index 41863b6db..bd1ad5676 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/resources/mapper/support/SmartJobMapper.xml +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/resources/mapper/support/SmartJobMapper.xml @@ -2,6 +2,12 @@ + + update t_smart_job + set deleted_flag = #{deletedFlag} + where job_id = #{jobId} + + + + \ No newline at end of file diff --git a/smart-admin-api-java17-springboot3/sa-base/src/main/resources/prod/sa-base.yaml b/smart-admin-api-java17-springboot3/sa-base/src/main/resources/prod/sa-base.yaml index 1162a1ce9..adcac8c9a 100644 --- a/smart-admin-api-java17-springboot3/sa-base/src/main/resources/prod/sa-base.yaml +++ b/smart-admin-api-java17-springboot3/sa-base/src/main/resources/prod/sa-base.yaml @@ -21,18 +21,19 @@ spring: pointcut: net.lab1024.sa..*Service.* # redis 连接池配置信息 - redis: - database: 1 - host: 127.0.0.1 - port: 6379 - password: - timeout: 10000ms - lettuce: - pool: - max-active: 100 - min-idle: 10 - max-idle: 50 - max-wait: 30000ms + data: + redis: + database: 1 + host: 127.0.0.1 + port: 6379 + password: + timeout: 10000ms + lettuce: + pool: + max-active: 100 + min-idle: 10 + max-idle: 50 + max-wait: 30000ms # 邮件,置以SSL的方式发送, 这个需要使用这种方式并且端口是465 mail: host: smtp.163.com diff --git a/smart-admin-api-java8-springboot2/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/support/AdminSmartJobController.java b/smart-admin-api-java8-springboot2/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/support/AdminSmartJobController.java index d987ca394..b7dc11f43 100644 --- a/smart-admin-api-java8-springboot2/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/support/AdminSmartJobController.java +++ b/smart-admin-api-java8-springboot2/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/support/AdminSmartJobController.java @@ -53,6 +53,15 @@ public ResponseDTO> queryJob(@RequestBody @Valid SmartJob return jobService.queryJob(queryForm); } + @Operation(summary = "定时任务-添加任务 @huke") + @PostMapping("/job/add") + @RepeatSubmit + public ResponseDTO addJob(@RequestBody @Valid SmartJobAddForm addForm) { + RequestUser requestUser = SmartRequestUtil.getRequestUser(); + addForm.setUpdateName(requestUser.getUserName()); + return jobService.addJob(addForm); + } + @Operation(summary = "定时任务-更新-任务信息 @huke") @PostMapping("/job/update") @RepeatSubmit @@ -71,6 +80,13 @@ public ResponseDTO updateJobEnabled(@RequestBody @Valid SmartJobEnabledU return jobService.updateJobEnabled(updateForm); } + @Operation(summary = "定时任务-删除 @zhuoda") + @GetMapping("/job/delete") + @RepeatSubmit + public ResponseDTO deleteJob(@RequestParam Integer jobId) { + return jobService.deleteJob(jobId, SmartRequestUtil.getRequestUser()); + } + @Operation(summary = "定时任务-执行记录-分页查询 @huke") @PostMapping("/job/log/query") public ResponseDTO> queryJobLog(@RequestBody @Valid SmartJobLogQueryForm queryForm) { diff --git a/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/config/TokenConfig.java b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/config/TokenConfig.java new file mode 100644 index 000000000..0d7d076a9 --- /dev/null +++ b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/config/TokenConfig.java @@ -0,0 +1,34 @@ +package net.lab1024.sa.base.config; + +import cn.dev33.satoken.config.SaTokenConfig; +import net.lab1024.sa.base.module.support.securityprotect.service.Level3ProtectConfigService; +import org.springframework.context.annotation.Configuration; + +import javax.annotation.Resource; + +/** + * + * 三级等保配置初始化后最低活跃频率全局配置 + * + * @Author 1024创新实验室-创始人兼主任:卓大 + * @Date 2024/11/24 + * @Wechat zhuoda1024 + * @Email lab1024@163.com + * @Copyright 1024创新实验室 ,Since 2012 + */ + +@Configuration +public class TokenConfig { + + @Resource + private Level3ProtectConfigService level3ProtectConfigService; + + // 此配置会覆盖 sa-base.yaml 中的配置 + @Resource + public void configSaToken(SaTokenConfig config) { + + config.setActiveTimeout(level3ProtectConfigService.getLoginActiveTimeoutSeconds()); + } + + +} diff --git a/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/config/UrlConfig.java b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/config/UrlConfig.java index 7939a6061..0dda4915f 100644 --- a/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/config/UrlConfig.java +++ b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/config/UrlConfig.java @@ -9,10 +9,10 @@ import net.lab1024.sa.base.common.annoation.NoNeedLogin; import net.lab1024.sa.base.common.domain.RequestUrlVO; import org.apache.commons.collections4.CollectionUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.method.HandlerMethod; +import org.springframework.web.servlet.mvc.condition.PathPatternsRequestCondition; import org.springframework.web.servlet.mvc.method.RequestMappingInfo; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; @@ -21,7 +21,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.stream.Collectors; /** * url配置 @@ -49,11 +48,12 @@ public Map> methodUrlMap() { Map map = requestMappingHandlerMapping.getHandlerMethods(); for (Map.Entry entry : map.entrySet()) { RequestMappingInfo requestMappingInfo = entry.getKey(); - if(requestMappingInfo.getPatternsCondition() == null){ + PathPatternsRequestCondition pathPatternsCondition = requestMappingInfo.getPathPatternsCondition(); + if(pathPatternsCondition == null){ continue; } - Set urls = requestMappingInfo.getPatternsCondition().getPatterns(); + Set urls = pathPatternsCondition.getPatternValues(); if (CollectionUtils.isEmpty(urls)) { continue; } diff --git a/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/dict/service/DictService.java b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/dict/service/DictService.java index 78a5ca9ac..439f96f68 100644 --- a/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/dict/service/DictService.java +++ b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/dict/service/DictService.java @@ -1,8 +1,6 @@ package net.lab1024.sa.base.module.support.dict.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.google.common.collect.Interner; -import com.google.common.collect.Interners; import net.lab1024.sa.base.common.code.UserErrorCode; import net.lab1024.sa.base.common.domain.PageResult; import net.lab1024.sa.base.common.domain.ResponseDTO; @@ -28,7 +26,7 @@ * @Date 2022/5/26 19:40:55 * @Wechat zhuoda1024 * @Email lab1024@163.com - * @Copyright 1024创新实验室 + * @Copyright 1024创新实验室 */ @Service public class DictService { @@ -39,10 +37,6 @@ public class DictService { private DictValueDao dictValueDao; @Resource private DictCacheService dictCacheService; - /** - * CODE锁 - */ - private static final Interner CODE_POOL = Interners.newWeakInterner(); /** @@ -51,15 +45,15 @@ public class DictService { * @param keyAddForm * @return */ - public ResponseDTO keyAdd(DictKeyAddForm keyAddForm) { - synchronized (CODE_POOL.intern(keyAddForm.getKeyCode())) { - DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyAddForm.getKeyCode(), false); - if (dictKeyEntity != null) { - return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); - } - dictKeyEntity = SmartBeanUtil.copy(keyAddForm, DictKeyEntity.class); - dictKeyDao.insert(dictKeyEntity); + public synchronized ResponseDTO keyAdd(DictKeyAddForm keyAddForm) { + DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyAddForm.getKeyCode(), false); + if (dictKeyEntity != null) { + return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); } + dictKeyEntity = SmartBeanUtil.copy(keyAddForm, DictKeyEntity.class); + dictKeyDao.insert(dictKeyEntity); + //刷新缓存 + dictCacheService.cacheRefresh(); return ResponseDTO.ok(); } @@ -69,15 +63,15 @@ public ResponseDTO keyAdd(DictKeyAddForm keyAddForm) { * @param valueAddForm * @return */ - public ResponseDTO valueAdd(DictValueAddForm valueAddForm) { - synchronized (CODE_POOL.intern(valueAddForm.getValueCode())) { - DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueAddForm.getValueCode(), false); - if (dictValueEntity != null) { - return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); - } - dictValueEntity = SmartBeanUtil.copy(valueAddForm, DictValueEntity.class); - dictValueDao.insert(dictValueEntity); + public synchronized ResponseDTO valueAdd(DictValueAddForm valueAddForm) { + DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueAddForm.getValueCode(), false); + if (dictValueEntity != null) { + return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); } + dictValueEntity = SmartBeanUtil.copy(valueAddForm, DictValueEntity.class); + dictValueDao.insert(dictValueEntity); + //刷新缓存 + dictCacheService.cacheRefresh(); return ResponseDTO.ok(); } @@ -87,15 +81,15 @@ public ResponseDTO valueAdd(DictValueAddForm valueAddForm) { * @param keyUpdateForm * @return */ - public ResponseDTO keyEdit(DictKeyUpdateForm keyUpdateForm) { - synchronized (CODE_POOL.intern(keyUpdateForm.getKeyCode())) { - DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyUpdateForm.getKeyCode(), false); - if (dictKeyEntity != null && !dictKeyEntity.getDictKeyId().equals(keyUpdateForm.getDictKeyId())) { - return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); - } - DictKeyEntity dictKeyUpdateEntity = SmartBeanUtil.copy(keyUpdateForm, DictKeyEntity.class); - dictKeyDao.updateById(dictKeyUpdateEntity); + public synchronized ResponseDTO keyEdit(DictKeyUpdateForm keyUpdateForm) { + DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyUpdateForm.getKeyCode(), false); + if (dictKeyEntity != null && !dictKeyEntity.getDictKeyId().equals(keyUpdateForm.getDictKeyId())) { + return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); } + DictKeyEntity dictKeyUpdateEntity = SmartBeanUtil.copy(keyUpdateForm, DictKeyEntity.class); + dictKeyDao.updateById(dictKeyUpdateEntity); + //刷新缓存 + dictCacheService.cacheRefresh(); return ResponseDTO.ok(); } @@ -105,19 +99,19 @@ public ResponseDTO keyEdit(DictKeyUpdateForm keyUpdateForm) { * @param valueUpdateForm * @return */ - public ResponseDTO valueEdit(DictValueUpdateForm valueUpdateForm) { + public synchronized ResponseDTO valueEdit(DictValueUpdateForm valueUpdateForm) { DictKeyEntity dictKeyEntity = dictKeyDao.selectById(valueUpdateForm.getDictKeyId()); if (dictKeyEntity == null || dictKeyEntity.getDeletedFlag()) { return ResponseDTO.userErrorParam("key不能存在"); } - synchronized (CODE_POOL.intern(valueUpdateForm.getValueCode())) { - DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueUpdateForm.getValueCode(), false); - if (dictValueEntity != null && !dictValueEntity.getDictValueId().equals(valueUpdateForm.getDictValueId())) { - return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); - } - DictValueEntity dictValueUpdateEntity = SmartBeanUtil.copy(valueUpdateForm, DictValueEntity.class); - dictValueDao.updateById(dictValueUpdateEntity); + DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueUpdateForm.getValueCode(), false); + if (dictValueEntity != null && !dictValueEntity.getDictValueId().equals(valueUpdateForm.getDictValueId())) { + return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); } + DictValueEntity dictValueUpdateEntity = SmartBeanUtil.copy(valueUpdateForm, DictValueEntity.class); + dictValueDao.updateById(dictValueUpdateEntity); + //刷新缓存 + dictCacheService.cacheRefresh(); return ResponseDTO.ok(); } @@ -127,11 +121,13 @@ public ResponseDTO valueEdit(DictValueUpdateForm valueUpdateForm) { * @param keyIdList * @return */ - public ResponseDTO keyDelete(List keyIdList) { + public synchronized ResponseDTO keyDelete(List keyIdList) { if (CollectionUtils.isEmpty(keyIdList)) { return ResponseDTO.ok(); } dictKeyDao.updateDeletedFlagByIdList(keyIdList, true); + //刷新缓存 + dictCacheService.cacheRefresh(); return ResponseDTO.ok(); } @@ -141,11 +137,13 @@ public ResponseDTO keyDelete(List keyIdList) { * @param valueIdList * @return */ - public ResponseDTO valueDelete(List valueIdList) { + public synchronized ResponseDTO valueDelete(List valueIdList) { if (CollectionUtils.isEmpty(valueIdList)) { return ResponseDTO.ok(); } dictValueDao.updateDeletedFlagByIdList(valueIdList, true); + //刷新缓存 + dictCacheService.cacheRefresh(); return ResponseDTO.ok(); } diff --git a/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/SmartJobService.java b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/SmartJobService.java index 1600acbcd..e55816d47 100644 --- a/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/SmartJobService.java +++ b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/SmartJobService.java @@ -4,6 +4,7 @@ import com.google.common.collect.Lists; import net.lab1024.sa.base.common.code.UserErrorCode; import net.lab1024.sa.base.common.domain.PageResult; +import net.lab1024.sa.base.common.domain.RequestUser; import net.lab1024.sa.base.common.domain.ResponseDTO; import net.lab1024.sa.base.common.util.SmartBeanUtil; import net.lab1024.sa.base.common.util.SmartPageUtil; @@ -16,7 +17,6 @@ import net.lab1024.sa.base.module.support.job.repository.domain.SmartJobEntity; import net.lab1024.sa.base.module.support.job.repository.domain.SmartJobLogEntity; import org.apache.commons.collections4.CollectionUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.stereotype.Service; @@ -126,27 +126,61 @@ public ResponseDTO> queryJobLog(SmartJobLogQueryForm q return ResponseDTO.ok(pageResult); } + /** + * 添加定时任务 + * + * @param addForm + * @return + */ + public synchronized ResponseDTO addJob(SmartJobAddForm addForm) { + // 校验参数 + ResponseDTO checkRes = this.checkParam(addForm); + if (!checkRes.getOk()) { + return checkRes; + } + + // 校验重复的执行类 + SmartJobEntity existJobClass = jobDao.selectByJobClass(addForm.getJobClass()); + if (null != existJobClass && !existJobClass.getDeletedFlag()) { + return ResponseDTO.userErrorParam("已经存在相同的执行类"); + } + + // 添加数据 + SmartJobEntity jobEntity = SmartBeanUtil.copy(addForm, SmartJobEntity.class); + jobDao.insert(jobEntity); + + // 更新执行端 + SmartJobMsg jobMsg = new SmartJobMsg(); + jobMsg.setJobId(jobEntity.getJobId()); + jobMsg.setMsgType(SmartJobMsg.MsgTypeEnum.UPDATE_JOB); + jobMsg.setUpdateName(addForm.getUpdateName()); + jobClientManager.publishToClient(jobMsg); + return ResponseDTO.ok(); + } + /** * 更新定时任务 * * @param updateForm * @return */ - public ResponseDTO updateJob(SmartJobUpdateForm updateForm) { + public synchronized ResponseDTO updateJob(SmartJobUpdateForm updateForm) { // 校验参数 Integer jobId = updateForm.getJobId(); SmartJobEntity jobEntity = jobDao.selectById(jobId); if (null == jobEntity) { return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST); } - // 校验触发时间配置 - String triggerType = updateForm.getTriggerType(); - String triggerValue = updateForm.getTriggerValue(); - if (SmartJobTriggerTypeEnum.CRON.equalsValue(triggerType) && !SmartJobUtil.checkCron(triggerValue)) { - return ResponseDTO.userErrorParam("cron表达式错误"); + + ResponseDTO checkRes = this.checkParam(updateForm); + if (!checkRes.getOk()) { + return checkRes; } - if (SmartJobTriggerTypeEnum.FIXED_DELAY.equalsValue(triggerType) && !SmartJobUtil.checkFixedDelay(triggerValue)) { - return ResponseDTO.userErrorParam("固定间隔错误:整数且大于0"); + + // 校验重复的执行类 + SmartJobEntity existJobClass = jobDao.selectByJobClass(updateForm.getJobClass()); + if (null != existJobClass && !existJobClass.getDeletedFlag() && !existJobClass.getJobId().equals(jobId)) { + return ResponseDTO.userErrorParam("已经存在相同的执行类"); } // 更新数据 @@ -162,6 +196,27 @@ public ResponseDTO updateJob(SmartJobUpdateForm updateForm) { return ResponseDTO.ok(); } + /** + * 校验参数 + * 如需其他校验,请自行添加校验逻辑 + * + * @param addForm + * @return + */ + private ResponseDTO checkParam(SmartJobAddForm addForm) { + // 校验触发时间配置 + String triggerType = addForm.getTriggerType(); + String triggerValue = addForm.getTriggerValue(); + if (SmartJobTriggerTypeEnum.CRON.equalsValue(triggerType) && !SmartJobUtil.checkCron(triggerValue)) { + return ResponseDTO.userErrorParam("cron表达式错误"); + } + if (SmartJobTriggerTypeEnum.FIXED_DELAY.equalsValue(triggerType) && !SmartJobUtil.checkFixedDelay(triggerValue)) { + return ResponseDTO.userErrorParam("固定间隔配置错误:必须是大于0的整数"); + } + // 校验job class + return SmartJobUtil.checkJobClass(addForm.getJobClass()); + } + /** * 更新定时任务-是否开启 * @@ -218,29 +273,24 @@ public ResponseDTO execute(SmartJobExecuteForm executeForm) { return ResponseDTO.ok(); } - /** - * 新增定时任务 - * ps:目前没有业务场景需要通过接口 添加任务 - * 因为新增定时任务无论如何都需要 手动编码 - * 需要时手动给数据库增加一条就行 - * - * @return - * @author huke - */ - public ResponseDTO addJob() { - return ResponseDTO.userErrorParam("暂未支持"); - } - /** * 移除定时任务 - * ps:目前没有业务场景需要通过接口移除,理由同 {@link SmartJobService#addJob}, - * 彻底移除始终都需要手动删除代码 - * 如果只是想暂停任务执行,可以调用 {@link SmartJobService#updateJobEnabled} + * 物理删除 * * @return * @author huke */ - public ResponseDTO delJob() { - return ResponseDTO.userErrorParam("暂未支持"); + public synchronized ResponseDTO deleteJob(Integer jobId, RequestUser requestUser) { + // 删除任务 + jobDao.updateDeletedFlag(jobId, Boolean.TRUE); + + // 更新执行端 + SmartJobMsg jobMsg = new SmartJobMsg(); + jobMsg.setJobId(jobId); + jobMsg.setMsgType(SmartJobMsg.MsgTypeEnum.UPDATE_JOB); + jobMsg.setUpdateName(requestUser.getUserName()); + jobClientManager.publishToClient(jobMsg); + return ResponseDTO.ok(); } + } diff --git a/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobAddForm.java b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobAddForm.java new file mode 100644 index 000000000..4dcea397f --- /dev/null +++ b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobAddForm.java @@ -0,0 +1,59 @@ +package net.lab1024.sa.base.module.support.job.api.domain; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import net.lab1024.sa.base.common.swagger.SchemaEnum; +import net.lab1024.sa.base.common.validator.enumeration.CheckEnum; +import net.lab1024.sa.base.module.support.job.constant.SmartJobTriggerTypeEnum; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * 定时任务 添加 + * + * @author huke + * @date 2024/12/19 19:30 + */ +@Data +public class SmartJobAddForm { + + @Schema(description = "任务名称") + @NotBlank(message = "任务名称不能为空") + @Length(max = 100, message = "任务名称最多100字符") + private String jobName; + + @Schema(description = "任务执行类") + @NotBlank(message = "任务执行类不能为空") + @Length(max = 200, message = "任务执行类最多200字符") + private String jobClass; + + @SchemaEnum(desc = "触发类型", value = SmartJobTriggerTypeEnum.class) + @CheckEnum(value = SmartJobTriggerTypeEnum.class, required = true, message = "触发类型错误") + private String triggerType; + + @Schema(description = "触发配置") + @NotBlank(message = "触发配置不能为空") + @Length(max = 100, message = "触发配置最多100字符") + private String triggerValue; + + @Schema(description = "定时任务参数|可选") + @Length(max = 1000, message = "定时任务参数最多1000字符") + private String param; + + @Schema(description = "是否开启") + @NotNull(message = "是否开启不能为空") + private Boolean enabledFlag; + + @Schema(description = "备注") + @Length(max = 250, message = "任务备注最多250字符") + private String remark; + + @NotNull(message = "排序不能为空") + @Schema(description = "排序") + private Integer sort; + + @Schema(hidden = true) + private String updateName; +} diff --git a/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobQueryForm.java b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobQueryForm.java index a6091af7b..39a56c704 100644 --- a/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobQueryForm.java +++ b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobQueryForm.java @@ -27,4 +27,7 @@ public class SmartJobQueryForm extends PageParam { @Schema(description = "是否启用|可选") private Boolean enabledFlag; + + @Schema(description = "是否删除|可选") + private Boolean deletedFlag; } diff --git a/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobUpdateForm.java b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobUpdateForm.java index e30028f44..56a74139d 100644 --- a/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobUpdateForm.java +++ b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/api/domain/SmartJobUpdateForm.java @@ -2,12 +2,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import net.lab1024.sa.base.common.swagger.SchemaEnum; -import net.lab1024.sa.base.common.validator.enumeration.CheckEnum; -import net.lab1024.sa.base.module.support.job.constant.SmartJobTriggerTypeEnum; -import org.hibernate.validator.constraints.Length; -import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; /** @@ -17,47 +12,9 @@ * @date 2024/6/17 21:30 */ @Data -public class SmartJobUpdateForm { +public class SmartJobUpdateForm extends SmartJobAddForm { @Schema(description = "任务id") @NotNull(message = "任务id不能为空") private Integer jobId; - - @Schema(description = "任务名称") - @NotBlank(message = "任务名称不能为空") - @Length(max = 100, message = "任务名称最多100字符") - private String jobName; - - @Schema(description = "任务执行类") - @NotBlank(message = "任务执行类不能为空") - @Length(max = 200, message = "任务执行类最多200字符") - private String jobClass; - - @SchemaEnum(desc = "触发类型", value = SmartJobTriggerTypeEnum.class) - @CheckEnum(value = SmartJobTriggerTypeEnum.class, required = true, message = "触发类型错误") - private String triggerType; - - @Schema(description = "触发配置") - @NotBlank(message = "触发配置不能为空") - @Length(max = 100, message = "触发配置最多100字符") - private String triggerValue; - - @Schema(description = "定时任务参数|可选") - @Length(max = 1000, message = "定时任务参数最多1000字符") - private String param; - - @Schema(description = "是否开启") - @NotNull(message = "是否开启不能为空") - private Boolean enabledFlag; - - @Schema(description = "备注") - @Length(max = 250, message = "任务备注最多250字符") - private String remark; - - @NotNull(message = "排序不能为空") - @Schema(description = "排序") - private Integer sort; - - @Schema(hidden = true) - private String updateName; } diff --git a/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/constant/SmartJobUtil.java b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/constant/SmartJobUtil.java index adb2497d6..ac21b3daf 100644 --- a/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/constant/SmartJobUtil.java +++ b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/constant/SmartJobUtil.java @@ -1,5 +1,7 @@ package net.lab1024.sa.base.module.support.job.constant; +import net.lab1024.sa.base.common.domain.ResponseDTO; +import net.lab1024.sa.base.module.support.job.core.SmartJob; import org.springframework.scheduling.support.CronExpression; import java.lang.management.ManagementFactory; @@ -98,7 +100,7 @@ public static List queryNextTimeFromNow(String triggerType, } else if (SmartJobTriggerTypeEnum.FIXED_DELAY.equalsValue(triggerType)) { Integer fixedDelay = getFixedDelayVal(triggerVal); LocalDateTime startTime = null == lastExecuteTime || lastExecuteTime.plusSeconds(fixedDelay).isBefore(nowTime) - ? nowTime : lastExecuteTime; + ? nowTime : lastExecuteTime; nextTimeList = SmartJobUtil.queryNextTime(fixedDelay, startTime, num); } return nextTimeList; @@ -174,6 +176,24 @@ public static String getProcessId() { return runtime.getName().split("@")[0]; } + + /** + * 根据className 判断job class + */ + public static ResponseDTO checkJobClass(String className) { + try { + Class aClass = Class.forName(className); + // 判断是否实现了 SmartJob + if (!SmartJob.class.isAssignableFrom(aClass)) { + return ResponseDTO.userErrorParam(className + " 执行类没有实现 SmartJob 接口"); + } + } catch (ClassNotFoundException e) { + return ResponseDTO.userErrorParam("没有在代码中发现执行类:" + className); + } + return ResponseDTO.ok(); + } + + public static void main(String[] args) { LocalDateTime startTime = LocalDateTime.now(); List timeList = SmartJobUtil.queryNextTime("5 * * * * *", startTime, 3); @@ -184,5 +204,7 @@ public static void main(String[] args) { System.out.println("project path ->" + getProgramPath()); System.out.println("project process id ->" + getProcessId()); + ResponseDTO res = checkJobClass("net.lab1024.sa.base.module.support.job.sample.SmartJobSample1"); + System.out.println(res.getMsg()); } } diff --git a/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/core/SmartJobLauncher.java b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/core/SmartJobLauncher.java index 8aece1905..6b5175191 100644 --- a/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/core/SmartJobLauncher.java +++ b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/core/SmartJobLauncher.java @@ -103,6 +103,10 @@ public void startOrRefreshJob(List smartJobList) { if (!jobEntity.getEnabledFlag()) { continue; } + // 任务删除 + if (jobEntity.getDeletedFlag()) { + continue; + } // 查找任务实现类 SmartJob jobImpl = jobImplMap.get(jobEntity.getJobClass()); if (null == jobImpl) { @@ -135,6 +139,7 @@ private List queryJob() { private static boolean isNeedUpdate(SmartJobEntity oldJob, SmartJobEntity newJob) { // cron为空时 fixedDelay 才有意义 return !Objects.equals(oldJob.getEnabledFlag(), newJob.getEnabledFlag()) + || !Objects.equals(oldJob.getDeletedFlag(), newJob.getDeletedFlag()) || !Objects.equals(oldJob.getTriggerType(), newJob.getTriggerType()) || !Objects.equals(oldJob.getTriggerValue(), newJob.getTriggerValue()) || !Objects.equals(oldJob.getJobClass(), newJob.getJobClass()); diff --git a/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/repository/SmartJobDao.java b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/repository/SmartJobDao.java index 703a90de2..002e03fc2 100644 --- a/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/repository/SmartJobDao.java +++ b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/repository/SmartJobDao.java @@ -29,4 +29,20 @@ public interface SmartJobDao extends BaseMapper { * @return */ List query(Page page, @Param("query") SmartJobQueryForm queryForm); + + /** + * 假删除 + * + * @param jobId + * @return + */ + void updateDeletedFlag(@Param("jobId") Integer jobId, @Param("deletedFlag") Boolean deletedFlag); + + /** + * 根据 任务class 查找 + * + * @param jobClass + * @return + */ + SmartJobEntity selectByJobClass(@Param("jobClass") String jobClass); } diff --git a/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/repository/domain/SmartJobEntity.java b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/repository/domain/SmartJobEntity.java index 7b4708798..890bc6369 100644 --- a/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/repository/domain/SmartJobEntity.java +++ b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/repository/domain/SmartJobEntity.java @@ -76,6 +76,11 @@ public class SmartJobEntity { */ private Integer sort; + /** + * 是否删除 + */ + private Boolean deletedFlag; + private String updateName; private LocalDateTime updateTime; diff --git a/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/securityprotect/service/Level3ProtectConfigService.java b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/securityprotect/service/Level3ProtectConfigService.java index 37bba6888..40a9afb26 100644 --- a/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/securityprotect/service/Level3ProtectConfigService.java +++ b/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/module/support/securityprotect/service/Level3ProtectConfigService.java @@ -45,7 +45,7 @@ public class Level3ProtectConfigService { /** * 最低活跃时间(单位:秒),超过此时间没有操作系统就会被冻结,默认-1 代表不限制,永不冻结; 默认 30分钟 */ - private int loginActiveTimeoutSeconds = 1800; + private int loginActiveTimeoutSeconds = -1; /** * 密码复杂度 是否开启,默认:开启 diff --git a/smart-admin-api-java8-springboot2/sa-base/src/main/resources/mapper/support/SmartJobMapper.xml b/smart-admin-api-java8-springboot2/sa-base/src/main/resources/mapper/support/SmartJobMapper.xml index 41863b6db..bd1ad5676 100644 --- a/smart-admin-api-java8-springboot2/sa-base/src/main/resources/mapper/support/SmartJobMapper.xml +++ b/smart-admin-api-java8-springboot2/sa-base/src/main/resources/mapper/support/SmartJobMapper.xml @@ -2,6 +2,12 @@ + + update t_smart_job + set deleted_flag = #{deletedFlag} + where job_id = #{jobId} + + + + \ No newline at end of file diff --git a/smart-admin-web-javascript/src/api/support/job-api.js b/smart-admin-web-javascript/src/api/support/job-api.js index 805cef312..2d9e060cd 100644 --- a/smart-admin-web-javascript/src/api/support/job-api.js +++ b/smart-admin-web-javascript/src/api/support/job-api.js @@ -19,6 +19,10 @@ export const jobApi = { executeJob: (param) => { return postRequest('/support/job/execute', param); }, + // 定时任务-新增-任务信息 @huke + addJob: (param) => { + return postRequest('/support/job/add', param); + }, // 定时任务-更新-任务信息 @huke updateJob: (param) => { return postRequest('/support/job/update', param); @@ -31,4 +35,8 @@ export const jobApi = { queryJobLog: (param) => { return postRequest('/support/job/log/query', param); }, + // 定时任务-删除 @zhuoda + deleteJob: (param) => { + return getRequest(`/support/job/delete?jobId=${param}`); + }, }; diff --git a/smart-admin-web-javascript/src/assets/images/nav/active_bg2.svg b/smart-admin-web-javascript/src/assets/images/nav/active_bg2.svg new file mode 100644 index 000000000..60a4b362b --- /dev/null +++ b/smart-admin-web-javascript/src/assets/images/nav/active_bg2.svg @@ -0,0 +1,3 @@ + + + diff --git a/smart-admin-web-javascript/src/assets/images/nav/active_bg2_default.svg b/smart-admin-web-javascript/src/assets/images/nav/active_bg2_default.svg new file mode 100644 index 000000000..5a5552778 --- /dev/null +++ b/smart-admin-web-javascript/src/assets/images/nav/active_bg2_default.svg @@ -0,0 +1,3 @@ + + + diff --git a/smart-admin-web-javascript/src/config/app-config.js b/smart-admin-web-javascript/src/config/app-config.js index 183620f7e..a08098b4a 100644 --- a/smart-admin-web-javascript/src/config/app-config.js +++ b/smart-admin-web-javascript/src/config/app-config.js @@ -24,7 +24,7 @@ export const appDefaultConfig = { borderRadius: 6, // 标签页 pageTagFlag: true, - // 标签页样式: default、 antd + // 标签页样式: default、 antd、naive pageTagStyle: 'default', // 面包屑 breadCrumbFlag: true, diff --git a/smart-admin-web-javascript/src/constants/layout-const.js b/smart-admin-web-javascript/src/constants/layout-const.js index b5f124e03..db074a3ac 100644 --- a/smart-admin-web-javascript/src/constants/layout-const.js +++ b/smart-admin-web-javascript/src/constants/layout-const.js @@ -31,4 +31,8 @@ export const PAGE_TAG_ENUM = { value: 'antd', desc: 'Ant Design', }, + CHROME: { + value: 'chrome', + desc: 'Chrome', + }, }; diff --git a/smart-admin-web-javascript/src/layout/components/header-user-space/header-setting.vue b/smart-admin-web-javascript/src/layout/components/header-user-space/header-setting.vue index d77f5473f..f84bd14ff 100644 --- a/smart-admin-web-javascript/src/layout/components/header-user-space/header-setting.vue +++ b/smart-admin-web-javascript/src/layout/components/header-user-space/header-setting.vue @@ -73,7 +73,8 @@ 默认 - Ant Design + Ant + Chrome diff --git a/smart-admin-web-javascript/src/layout/components/page-tag/components/chrome-tab.vue b/smart-admin-web-javascript/src/layout/components/page-tag/components/chrome-tab.vue new file mode 100644 index 000000000..5e485b609 --- /dev/null +++ b/smart-admin-web-javascript/src/layout/components/page-tag/components/chrome-tab.vue @@ -0,0 +1,342 @@ + + + + + + diff --git a/smart-admin-web-javascript/src/layout/components/page-tag/index.vue b/smart-admin-web-javascript/src/layout/components/page-tag/index.vue index 048d2c012..4fc5549b1 100644 --- a/smart-admin-web-javascript/src/layout/components/page-tag/index.vue +++ b/smart-admin-web-javascript/src/layout/components/page-tag/index.vue @@ -11,6 +11,7 @@
+
@@ -19,6 +20,7 @@ import { useAppConfigStore } from '/@/store/modules/system/app-config'; import DefaultTab from './components/default-tab.vue'; import AntdTab from './components/antd-tab.vue'; + import ChromeTab from './components/chrome-tab.vue'; import { PAGE_TAG_ENUM } from '/@/constants/layout-const.js'; const pageTagStyle = computed(() => useAppConfigStore().$state.pageTagStyle); diff --git a/smart-admin-web-javascript/src/layout/components/side-expand-menu/recursion-menu.vue b/smart-admin-web-javascript/src/layout/components/side-expand-menu/recursion-menu.vue index fd979922c..67fd92b61 100644 --- a/smart-admin-web-javascript/src/layout/components/side-expand-menu/recursion-menu.vue +++ b/smart-admin-web-javascript/src/layout/components/side-expand-menu/recursion-menu.vue @@ -14,23 +14,25 @@ {{ topMenu.menuName }} - - @@ -19,6 +20,7 @@ import { useAppConfigStore } from '/@/store/modules/system/app-config'; import DefaultTab from './components/default-tab.vue'; import AntdTab from './components/antd-tab.vue'; + import ChromeTab from './components/chrome-tab.vue'; import { PAGE_TAG_ENUM } from '/@/constants/layout-const.js'; const pageTagStyle = computed(() => useAppConfigStore().$state.pageTagStyle); diff --git a/smart-admin-web-typescript/src/layout/components/side-expand-menu/recursion-menu.vue b/smart-admin-web-typescript/src/layout/components/side-expand-menu/recursion-menu.vue index 396abbb2a..8eef372e5 100644 --- a/smart-admin-web-typescript/src/layout/components/side-expand-menu/recursion-menu.vue +++ b/smart-admin-web-typescript/src/layout/components/side-expand-menu/recursion-menu.vue @@ -14,23 +14,25 @@ {{ topMenu.menuName }} - -