diff --git a/nladmin-system/nlsso-server/pom.xml b/nladmin-system/nlsso-server/pom.xml index acdf66d..c464c5c 100644 --- a/nladmin-system/nlsso-server/pom.xml +++ b/nladmin-system/nlsso-server/pom.xml @@ -24,15 +24,32 @@ 2.5.0 1.3.1.Final 1.31.0 - 5.7.14 + 5.8.1 0.11.1 - 5.9.0 + 5.8.0 1.9 4.1.59.Final + + + + p6spy + p6spy + 3.8.6 + + + + + + com.yomahub + tlog-all-spring-boot-starter + 1.5.0 + + + org.springframework.boot @@ -47,6 +64,13 @@ 1.6 + + + org.fusesource.jansi + jansi + 1.9 + + cn.dynamictp @@ -380,6 +404,14 @@ 1.9.2 + + + + org.springframework.retry + spring-retry + + + org.springframework.boot @@ -472,7 +504,7 @@ com.github.oshi oshi-core - 5.0.1 + 6.1.4 diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/AppRun.java b/nladmin-system/nlsso-server/src/main/java/org/nl/AppRun.java index 09fd9fa..14cca84 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/AppRun.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/AppRun.java @@ -1,8 +1,10 @@ package org.nl; +import cn.dev33.satoken.annotation.SaIgnore; import com.alicp.jetcache.anno.config.EnableCreateCacheAnnotation; import com.alicp.jetcache.anno.config.EnableMethodCache; import io.swagger.annotations.Api; +import lombok.extern.slf4j.Slf4j; import org.mybatis.spring.annotation.MapperScan; import org.nl.common.utils.SpringContextHolder; import org.springframework.boot.SpringApplication; @@ -11,9 +13,10 @@ import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactor import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.boot.web.servlet.server.ServletWebServerFactory; import org.springframework.context.annotation.Bean; -import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; +import org.springframework.retry.annotation.EnableRetry; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.transaction.annotation.EnableTransactionManagement; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; /** @@ -35,6 +38,9 @@ import org.springframework.web.bind.annotation.RestController; @EnableMethodCache(basePackages = "org.nl") @EnableCreateCacheAnnotation @MapperScan("org.nl.**.mapper") +@EnableRetry //https://juejin.cn/post/7094613787973517343 + +@Slf4j public class AppRun { public static void main(String[] args) { @@ -53,15 +59,16 @@ public class AppRun { return fa; } -// /** -// * 访问首页提示 -// * -// * @return / -// */ -// @GetMapping("/") -// @SaIgnore -// public String index() { -// return "Backend service started successfully"; -// } + /** + * 访问首页提示 + * + * @return / + */ + @GetMapping("/") + @SaIgnore + public String index() { + log.info("123"); + return "Backend service started successfully"; + } } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/param/impl/SysParamServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/param/impl/SysParamServiceImpl.java index cefd376..d58132d 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/param/impl/SysParamServiceImpl.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/param/impl/SysParamServiceImpl.java @@ -6,13 +6,14 @@ import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.yomahub.tlog.core.annotation.TLogAspect; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.common.aspect.exception.BadRequestException; import org.nl.common.domain.query.PageQuery; import org.nl.common.utils.MapOf; import org.nl.common.utils.SecurityUtils; - import org.nl.system.service.param.ISysParamService; +import org.nl.system.service.param.ISysParamService; import org.nl.system.service.param.dao.Param; import org.nl.system.service.param.dao.mapper.SysParamMapper; import org.springframework.stereotype.Service; @@ -22,9 +23,7 @@ import java.util.List; import java.util.Map; /** - *

* 系统参数表 服务实现类 - *

* * @author generator * @since 2022-12-14 @@ -33,59 +32,66 @@ import java.util.Map; @RequiredArgsConstructor @Slf4j @Transactional -public class SysParamServiceImpl extends ServiceImpl implements ISysParamService { +public class SysParamServiceImpl extends ServiceImpl + implements ISysParamService { - private final SysParamMapper paramMapper; + private final SysParamMapper paramMapper; - @Override - public Page queryPage(Map whereJson, PageQuery page) { - log.info("111"); - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.orderBy(true, true, "create_time"); - Page paramPage = paramMapper.selectPage(page.build(), queryWrapper); - return paramPage; - } + @Override + @TLogAspect + public Page queryPage(Map whereJson, PageQuery page) { + log.info("这是第一条日志"); + log.info("这是第二条日志"); + log.info("这是第三条日志"); + new Thread(() -> log.info("这是异步日志")).start(); - @Override - @Transactional(rollbackFor = Exception.class) - public void create(Param param) { - List code = paramMapper.selectByMap(MapOf.of("code", param.getCode())); - if (ObjectUtil.isNotEmpty(code)) throw new BadRequestException("编码不能一致"); - param.setId(IdUtil.getSnowflake(1, 1).nextIdStr()); - String currentUserId = SecurityUtils.getCurrentUserId(); - String nickName = SecurityUtils.getCurrentNickName(); - String now = DateUtil.now(); - param.setCreateId(currentUserId); - param.setCreateName(nickName); - param.setCreateTime(now); - param.setUpdateId(currentUserId); - param.setUpdateName(nickName); - param.setUpdateTime(now); - paramMapper.insert(param); - } - @Override - @Transactional(rollbackFor = Exception.class) - public void update(Param param) { - Param paramObj = paramMapper.selectById(param.getId()); - if (ObjectUtil.isEmpty(paramObj)) throw new BadRequestException("被删除或无权限,操作失败!"); - param.setUpdateId(SecurityUtils.getCurrentUserId()); - param.setUpdateName(SecurityUtils.getCurrentNickName()); - param.setUpdateTime(DateUtil.now()); - paramMapper.updateById(param); - } + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.orderBy(true, true, "create_time"); + Page paramPage = paramMapper.selectPage(page.build(), queryWrapper); + return paramPage; + } - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteByIds(List ids) { - paramMapper.deleteBatchIds(ids); - } + @Override + @Transactional(rollbackFor = Exception.class) + public void create(Param param) { + List code = paramMapper.selectByMap(MapOf.of("code", param.getCode())); + if (ObjectUtil.isNotEmpty(code)) throw new BadRequestException("编码不能一致"); + param.setId(IdUtil.getSnowflake(1, 1).nextIdStr()); + String currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + String now = DateUtil.now(); + param.setCreateId(currentUserId); + param.setCreateName(nickName); + param.setCreateTime(now); + param.setUpdateId(currentUserId); + param.setUpdateName(nickName); + param.setUpdateTime(now); + paramMapper.insert(param); + } - @Override - public Param findByCode(String code) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("code", code); - Param param = paramMapper.selectOne(queryWrapper); - return param; - } + @Override + @Transactional(rollbackFor = Exception.class) + public void update(Param param) { + Param paramObj = paramMapper.selectById(param.getId()); + if (ObjectUtil.isEmpty(paramObj)) throw new BadRequestException("被删除或无权限,操作失败!"); + param.setUpdateId(SecurityUtils.getCurrentUserId()); + param.setUpdateName(SecurityUtils.getCurrentNickName()); + param.setUpdateTime(DateUtil.now()); + paramMapper.updateById(param); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteByIds(List ids) { + paramMapper.deleteBatchIds(ids); + } + + @Override + public Param findByCode(String code) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("code", code); + Param param = paramMapper.selectOne(queryWrapper); + return param; + } } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/utils/ExecutionJob.java b/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/utils/ExecutionJob.java index 7534e49..619af02 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/utils/ExecutionJob.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/utils/ExecutionJob.java @@ -2,6 +2,7 @@ package org.nl.system.service.quartz.utils; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; +import com.yomahub.tlog.task.quartz.TLogQuartzJobBean; import lombok.extern.slf4j.Slf4j; import org.nl.common.utils.RedisUtils; import org.nl.common.utils.SpringContextHolder; @@ -12,10 +13,10 @@ import org.nl.system.service.quartz.dao.SysQuartzJob; import org.nl.system.service.quartz.dao.SysQuartzLog; import org.nl.system.service.quartz.dao.mapper.SysQuartzLogMapper; import org.nl.system.service.quartz.impl.SysQuartzJobServiceImpl; +import org.quartz.DisallowConcurrentExecution; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import org.springframework.scheduling.annotation.Async; -import org.springframework.scheduling.quartz.QuartzJobBean; import java.util.concurrent.Future; import java.util.concurrent.ThreadPoolExecutor; @@ -28,14 +29,16 @@ import java.util.concurrent.ThreadPoolExecutor; @Async @SuppressWarnings({"unchecked", "all"}) @Slf4j -public class ExecutionJob extends QuartzJobBean { +@DisallowConcurrentExecution +//public class ExecutionJob extends QuartzJobBean { +public class ExecutionJob extends TLogQuartzJobBean { /** * 该处仅供参考 */ private final static ThreadPoolExecutor EXECUTOR = ThreadPoolExecutorUtil.getPoll(); @Override - protected void executeInternal(JobExecutionContext context) throws JobExecutionException { + public void executeTask(JobExecutionContext context) throws JobExecutionException { SysQuartzJob quartzJob = (SysQuartzJob) context.getMergedJobDataMap().get(SysQuartzJob.JOB_KEY); // 获取spring bean ISysQuartzJobService quartzJobService = SpringContextHolder.getBean(SysQuartzJobServiceImpl.class); @@ -99,4 +102,5 @@ public class ExecutionJob extends QuartzJobBean { } } + } diff --git a/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml b/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml index 0c9ec4c..6fc6e05 100644 --- a/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml +++ b/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml @@ -21,9 +21,12 @@ https://juejin.cn/post/6844903775631572999 --> - + + true + + ${log.pattern} - ${log.charset} + @@ -41,15 +44,20 @@ https://juejin.cn/post/6844903775631572999 20GB - + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + ${log.charset} - + + + 0 500 @@ -120,10 +128,11 @@ https://juejin.cn/post/6844903775631572999 - + + - +