mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-11-05 04:03:41 +08:00
Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cdbb854e6c | ||
|
|
db5e0062a0 | ||
|
|
29064c176f | ||
|
|
b7c71189e1 | ||
|
|
55fb01174f | ||
|
|
1943431df0 | ||
|
|
bbc382bc38 | ||
|
|
31f0041f74 | ||
|
|
36ebb16574 | ||
|
|
23b75137bb | ||
|
|
e3888cef9b | ||
|
|
7b681e44a8 | ||
|
|
83d970095b | ||
|
|
a3a7cf63a8 | ||
|
|
fff3ec203f | ||
|
|
a53acc504e | ||
|
|
64ebe2bfdb | ||
|
|
69ea81b020 | ||
|
|
cb39dedfd5 | ||
|
|
b27b004edc | ||
|
|
b3b20bc029 | ||
|
|
b350918501 | ||
|
|
69fa9088f5 | ||
|
|
dab0afdb59 | ||
|
|
17a3e1fd86 | ||
|
|
053d562157 |
35
smart-admin-api-java17-springboot3/.gitignore
vendored
35
smart-admin-api-java17-springboot3/.gitignore
vendored
@@ -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/
|
||||
@@ -29,7 +29,6 @@
|
||||
<google-linkedhashmap.version>1.4.2</google-linkedhashmap.version>
|
||||
<google-guava.version>20.0</google-guava.version>
|
||||
<user-agent-utils.version>1.21</user-agent-utils.version>
|
||||
<kaptcha.version>2.3.2</kaptcha.version>
|
||||
<reflections.version>0.9.11</reflections.version>
|
||||
<commons-io.version>2.15.0</commons-io.version>
|
||||
<commons-lang3.version>3.12.0</commons-lang3.version>
|
||||
@@ -127,18 +126,6 @@
|
||||
<version>${user-agent-utils.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.penggle</groupId>
|
||||
<artifactId>kaptcha</artifactId>
|
||||
<version>${kaptcha.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package net.lab1024.sa.admin.module.business.goods.domain.form;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import net.lab1024.sa.admin.module.business.goods.constant.GoodsStatusEnum;
|
||||
import net.lab1024.sa.base.common.domain.PageParam;
|
||||
import net.lab1024.sa.base.common.json.deserializer.DictValueVoDeserializer;
|
||||
import net.lab1024.sa.base.common.swagger.SchemaEnum;
|
||||
import net.lab1024.sa.base.common.validator.enumeration.CheckEnum;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
@@ -32,6 +34,7 @@ public class GoodsQueryForm extends PageParam {
|
||||
private Integer goodsStatus;
|
||||
|
||||
@Schema(description = "产地")
|
||||
@JsonDeserialize(using = DictValueVoDeserializer.class)
|
||||
private String place;
|
||||
|
||||
@Schema(description = "上架状态")
|
||||
|
||||
@@ -52,7 +52,6 @@ public class NoticeEmployeeService {
|
||||
public ResponseDTO<PageResult<NoticeEmployeeVO>> queryList(Long requestEmployeeId, NoticeEmployeeQueryForm noticeEmployeeQueryForm) {
|
||||
Page<?> page = SmartPageUtil.convert2PageQuery(noticeEmployeeQueryForm);
|
||||
|
||||
//获取请求人的 部门及其子部门
|
||||
List<Long> employeeDepartmentIdList = Lists.newArrayList();
|
||||
EmployeeEntity employeeEntity = employeeService.getById(requestEmployeeId);
|
||||
// 如果不是管理员 则获取请求人的 部门及其子部门
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.List;
|
||||
* @Date 2021-12-09 22:57:49
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@RestController
|
||||
@Tag(name = AdminSwaggerTagConst.System.SYSTEM_EMPLOYEE)
|
||||
@@ -110,7 +110,7 @@ public class EmployeeController {
|
||||
@Operation(summary = "重置员工密码 @author 卓大")
|
||||
@GetMapping("/employee/update/password/reset/{employeeId}")
|
||||
@SaCheckPermission("system:employee:password:reset")
|
||||
public ResponseDTO<String> resetPassword(@PathVariable Integer employeeId) {
|
||||
public ResponseDTO<String> resetPassword(@PathVariable Long employeeId) {
|
||||
return employeeService.resetPassword(employeeId);
|
||||
}
|
||||
|
||||
|
||||
@@ -113,6 +113,6 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
||||
/**
|
||||
* 员工重置密码
|
||||
*/
|
||||
Integer updatePassword(@Param("employeeId") Integer employeeId, @Param("password") String password);
|
||||
Integer updatePassword(@Param("employeeId") Long employeeId, @Param("password") String password);
|
||||
|
||||
}
|
||||
@@ -47,8 +47,6 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
public class EmployeeService {
|
||||
|
||||
private static final String PASSWORD_SALT_FORMAT = "smart_%s_admin_$^&*";
|
||||
|
||||
@Resource
|
||||
private EmployeeDao employeeDao;
|
||||
|
||||
@@ -364,7 +362,7 @@ public class EmployeeService {
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
public ResponseDTO<String> resetPassword(Integer employeeId) {
|
||||
public ResponseDTO<String> resetPassword(Long employeeId) {
|
||||
String password = securityPasswordService.randomPassword();
|
||||
employeeDao.updatePassword(employeeId, SecurityPasswordService.getEncryptPwd(password));
|
||||
return ResponseDTO.ok(password);
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.List;
|
||||
* @Date 2022-04-08 21:53:04
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Service
|
||||
public class RoleEmployeeManager extends ServiceImpl<RoleEmployeeDao, RoleEmployeeEntity> {
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* @Date 2023/10/17 19:07:27
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>,Since 2012
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>,Since 2012
|
||||
*/
|
||||
|
||||
@RestController
|
||||
|
||||
@@ -52,6 +52,15 @@ public class AdminSmartJobController extends SupportBaseController {
|
||||
return jobService.queryJob(queryForm);
|
||||
}
|
||||
|
||||
@Operation(summary = "定时任务-添加任务 @huke")
|
||||
@PostMapping("/job/add")
|
||||
@RepeatSubmit
|
||||
public ResponseDTO<String> 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 class AdminSmartJobController extends SupportBaseController {
|
||||
return jobService.updateJobEnabled(updateForm);
|
||||
}
|
||||
|
||||
@Operation(summary = "定时任务-删除 @zhuoda")
|
||||
@GetMapping("/job/delete")
|
||||
@RepeatSubmit
|
||||
public ResponseDTO<String> deleteJob(@RequestParam Integer jobId) {
|
||||
return jobService.deleteJob(jobId, SmartRequestUtil.getRequestUser());
|
||||
}
|
||||
|
||||
@Operation(summary = "定时任务-执行记录-分页查询 @huke")
|
||||
@PostMapping("/job/log/query")
|
||||
public ResponseDTO<PageResult<SmartJobLogVO>> queryJobLog(@RequestBody @Valid SmartJobLogQueryForm queryForm) {
|
||||
|
||||
@@ -95,25 +95,25 @@
|
||||
left join t_notice_type on t_notice.notice_type_id = t_notice_type.notice_type_id
|
||||
<where>
|
||||
<if test="!administratorFlag">
|
||||
(
|
||||
(
|
||||
t_notice.notice_id in
|
||||
(select t_notice_visible_range.notice_id
|
||||
from t_notice_visible_range
|
||||
where
|
||||
( t_notice_visible_range.data_type = #{departmentDataType}
|
||||
<if test="requestEmployeeDepartmentIdList != null and requestEmployeeDepartmentIdList.size > 0">
|
||||
and
|
||||
t_notice_visible_range.data_id
|
||||
in
|
||||
<foreach collection="requestEmployeeDepartmentIdList" open="(" close=")" separator="," item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
)
|
||||
or ( t_notice_visible_range.data_type = #{employeeDataType} and t_notice_visible_range.data_id = #{requestEmployeeId} )
|
||||
<if test="requestEmployeeDepartmentIdList != null and requestEmployeeDepartmentIdList.size > 0">
|
||||
and
|
||||
t_notice_visible_range.data_id
|
||||
in
|
||||
<foreach collection="requestEmployeeDepartmentIdList" open="(" close=")" separator="," item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
)
|
||||
or ( t_notice_visible_range.data_type = #{employeeDataType} and t_notice_visible_range.data_id = #{requestEmployeeId} )
|
||||
)
|
||||
or t_notice.all_visible_flag = true
|
||||
)
|
||||
)
|
||||
</if>
|
||||
|
||||
and t_notice.deleted_flag = #{deletedFlag}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
# 项目配置: 名称、日志目录
|
||||
project:
|
||||
name: sa-admin
|
||||
log-directory: /home/project/smartadmin/sit/log
|
||||
log-directory: /home/project/smartadmin/test/log
|
||||
|
||||
# 项目端口和url根路径
|
||||
server:
|
||||
|
||||
@@ -143,11 +143,6 @@
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.penggle</groupId>
|
||||
<artifactId>kaptcha</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.googlecode.concurrentlinkedhashmap</groupId>
|
||||
<artifactId>concurrentlinkedhashmap-lru</artifactId>
|
||||
|
||||
@@ -14,15 +14,24 @@ import java.io.IOException;
|
||||
* @Date 2020-06-02 22:55:07
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
public class LongJsonSerializer extends JsonSerializer<Long> {
|
||||
|
||||
public static final LongJsonSerializer INSTANCE = new LongJsonSerializer();
|
||||
|
||||
@Override
|
||||
public void serialize(Long value, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
|
||||
String text = (value == null ? null : String.valueOf(value));
|
||||
if (text != null) {
|
||||
jsonGenerator.writeString(text);
|
||||
public void serialize(Long value, JsonGenerator gen, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
|
||||
if (null == value) {
|
||||
gen.writeNull();
|
||||
return;
|
||||
}
|
||||
// js中最大安全整数16位 Number.MAX_SAFE_INTEGER
|
||||
String longStr = String.valueOf(value);
|
||||
if (longStr.length() > 16) {
|
||||
gen.writeString(longStr);
|
||||
} else {
|
||||
gen.writeNumber(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package net.lab1024.sa.base.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
@@ -17,6 +18,7 @@ import org.springframework.web.filter.CorsFilter;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Configuration
|
||||
@Conditional(SystemEnvironmentConfig.class)
|
||||
public class CorsFilterConfig {
|
||||
|
||||
@Value("${access-control-allow-origin}")
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.baomidou.mybatisplus.annotation.DbType;
|
||||
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.Bean;
|
||||
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 class DataSourceConfig {
|
||||
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一定要放在后面
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||
import net.lab1024.sa.base.common.json.serializer.LongJsonSerializer;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -17,16 +18,16 @@ import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeParseException;
|
||||
|
||||
/**
|
||||
* java8 localDate 时间类格式化配置
|
||||
* json 序列化配置
|
||||
*
|
||||
* @Author 1024创新实验室-主任: 卓大
|
||||
* @Date 2017-11-28 15:21:10
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Configuration
|
||||
public class DateConfig {
|
||||
public class JsonConfig {
|
||||
|
||||
@Bean
|
||||
public Jackson2ObjectMapperBuilderCustomizer customizer() {
|
||||
@@ -35,6 +36,7 @@ public class DateConfig {
|
||||
builder.deserializers(new LocalDateTimeDeserializer(DatePattern.NORM_DATETIME_FORMAT.getDateTimeFormatter()));
|
||||
builder.serializers(new LocalDateSerializer(DatePattern.NORM_DATE_FORMAT.getDateTimeFormatter()));
|
||||
builder.serializers(new LocalDateTimeSerializer(DatePattern.NORM_DATETIME_FORMAT.getDateTimeFormatter()));
|
||||
builder.serializerByType(Long.class, LongJsonSerializer.INSTANCE);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class RedisConfig {
|
||||
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate() {
|
||||
|
||||
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<Object>(Object.class);
|
||||
ObjectMapper om = new ObjectMapper();
|
||||
om.registerModule(new JavaTimeModule())
|
||||
.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false)
|
||||
@@ -41,10 +41,11 @@ public class RedisConfig {
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false)
|
||||
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
Jackson2JsonRedisSerializer<Object> 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<String, Object> template = new RedisTemplate<>();
|
||||
template.setConnectionFactory(factory);
|
||||
template.setKeySerializer(new StringRedisSerializer());
|
||||
|
||||
@@ -31,10 +31,9 @@ import java.util.Optional;
|
||||
/**
|
||||
* springdoc-openapi 配置
|
||||
* nginx配置前缀时如果需要访问【/swagger-ui/index.html】需添加额外nginx配置
|
||||
* location /v3/api-docs/ {
|
||||
* proxy_pass http://127.0.0.1:11024/v3/api-docs/;
|
||||
* location /v3/api-docs/ {
|
||||
* proxy_pass http://127.0.0.1:1024/v3/api-docs/;
|
||||
* }
|
||||
*
|
||||
* @Author 1024创新实验室-主任: 卓大
|
||||
* @Date 2020-03-25 22:54:46
|
||||
* @Wechat zhuoda1024
|
||||
@@ -48,7 +47,7 @@ public class SwaggerConfig {
|
||||
/**
|
||||
* 用于解决/swagger-ui/index.html页面ServersUrl 测试环境部署错误问题
|
||||
*/
|
||||
@Value("${springdoc.swagger-ui.server-base-url:''}")
|
||||
@Value("${springdoc.swagger-ui.server-base-url}")
|
||||
private String serverBaseUrl;
|
||||
|
||||
public static final String[] SWAGGER_WHITELIST = {
|
||||
@@ -59,20 +58,20 @@ public class SwaggerConfig {
|
||||
"/v3/api-docs",
|
||||
"/v3/api-docs/**",
|
||||
"/doc.html",
|
||||
};
|
||||
};
|
||||
|
||||
@Bean
|
||||
public OpenAPI api() {
|
||||
return new OpenAPI()
|
||||
.components(components())
|
||||
.info(new Info()
|
||||
.title("SmartAdmin 3.X 接口文档")
|
||||
.contact(new Contact().name("1024创新实验室").email("lab1024@163.com").url("https://1024lab.net"))
|
||||
.version("v3.X")
|
||||
.description("<font color=\"#DC143C\">**以「高质量代码」为核心,「简洁、高效、安全」**</font>基于 SpringBoot + Sa-Token + Mybatis-Plus 和 Vue3 + Vite5 + Ant Design (同时支持JavaScript和TypeScript双版本) 的快速开发平台。" +
|
||||
"<br/><font color=\"#DC143C\">**国内首个满足《网络安全》、《数据安全》、三级等保**</font>, 支持登录限制、支持国产接口加解密等安全、支持数据加解密等一系列安全体系的开源项目。" +
|
||||
"<br/><font color=\"#DC143C\">**我们开源一套漂亮的代码和一套整洁的代码规范**</font>,让大家在这浮躁的代码世界里感受到一股把代码写好的清流!同时又让开发者节省大量的时间,减少加班,快乐工作,保持谦逊,保持学习,热爱代码,更热爱生活!")
|
||||
)
|
||||
.title("SmartAdmin 3.X 接口文档")
|
||||
.contact(new Contact().name("1024创新实验室").email("lab1024@163.com").url("https://1024lab.net"))
|
||||
.version("v3.X")
|
||||
.description("<font color=\"#DC143C\">**以「高质量代码」为核心,「简洁、高效、安全」**</font>基于 SpringBoot + Sa-Token + Mybatis-Plus 和 Vue3 + Vite5 + Ant Design (同时支持JavaScript和TypeScript双版本) 的快速开发平台。" +
|
||||
"<br/><font color=\"#DC143C\">**国内首个满足《网络安全》、《数据安全》、三级等保**</font>, 支持登录限制、支持国产接口加解密等安全、支持数据加解密等一系列安全体系的开源项目。" +
|
||||
"<br/><font color=\"#DC143C\">**我们开源一套漂亮的代码和一套整洁的代码规范**</font>,让大家在这浮躁的代码世界里感受到一股把代码写好的清流!同时又让开发者节省大量的时间,减少加班,快乐工作,保持谦逊,保持学习,热爱代码,更热爱生活!")
|
||||
)
|
||||
.addSecurityItem(new SecurityRequirement().addList(RequestHeaderConst.TOKEN));
|
||||
}
|
||||
|
||||
@@ -84,27 +83,26 @@ public class SwaggerConfig {
|
||||
@Bean
|
||||
public GroupedOpenApi businessApi() {
|
||||
return GroupedOpenApi.builder()
|
||||
.group("业务接口")
|
||||
.pathsToMatch("/**")
|
||||
.pathsToExclude(SwaggerTagConst.Support.URL_PREFIX + "/**")
|
||||
.addOperationCustomizer(new SmartOperationCustomizer())
|
||||
.build();
|
||||
.group("业务接口")
|
||||
.pathsToMatch("/**")
|
||||
.pathsToExclude(SwaggerTagConst.Support.URL_PREFIX + "/**")
|
||||
.addOperationCustomizer(new SmartOperationCustomizer())
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
@Bean
|
||||
public GroupedOpenApi supportApi() {
|
||||
return GroupedOpenApi.builder()
|
||||
.group("支撑接口(Support)")
|
||||
.pathsToMatch(SwaggerTagConst.Support.URL_PREFIX + "/**")
|
||||
.addOperationCustomizer(new SmartOperationCustomizer())
|
||||
.build();
|
||||
.group("支撑接口(Support)")
|
||||
.pathsToMatch(SwaggerTagConst.Support.URL_PREFIX + "/**")
|
||||
.addOperationCustomizer(new SmartOperationCustomizer())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 以下代码可以用于设置 /swagger-ui/index.html 的serverBaseUrl
|
||||
* 如果使用knife4j则不需要
|
||||
*
|
||||
* @param openAPI
|
||||
* @param securityParser
|
||||
* @param springDocConfigProperties
|
||||
@@ -132,6 +130,6 @@ public class SwaggerConfig {
|
||||
}
|
||||
});
|
||||
return new OpenAPIService(openAPI, securityParser, springDocConfigProperties,
|
||||
propertyResolverUtils, openApiBuilderCustomizers, Optional.of(list), javadocProvider);
|
||||
propertyResolverUtils, openApiBuilderCustomizers, Optional.of(list), javadocProvider);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 <a href="https://1024lab.net">1024创新实验室</a> ,Since 2012
|
||||
*/
|
||||
|
||||
@Configuration
|
||||
public class TokenConfig {
|
||||
|
||||
@Resource
|
||||
private Level3ProtectConfigService level3ProtectConfigService;
|
||||
|
||||
// 此配置会覆盖 sa-base.yaml 中的配置
|
||||
@Resource
|
||||
public void configSaToken(SaTokenConfig config) {
|
||||
|
||||
config.setActiveTimeout(level3ProtectConfigService.getLoginActiveTimeoutSeconds());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import org.apache.commons.collections4.CollectionUtils;
|
||||
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;
|
||||
|
||||
@@ -28,7 +29,7 @@ import java.util.Set;
|
||||
* @Date 2022-05-30 21:22:12
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Configuration
|
||||
@Slf4j
|
||||
@@ -47,11 +48,12 @@ public class UrlConfig {
|
||||
Map<RequestMappingInfo, HandlerMethod> map = requestMappingHandlerMapping.getHandlerMethods();
|
||||
for (Map.Entry<RequestMappingInfo, HandlerMethod> entry : map.entrySet()) {
|
||||
RequestMappingInfo requestMappingInfo = entry.getKey();
|
||||
if(requestMappingInfo.getPatternsCondition() == null){
|
||||
PathPatternsRequestCondition pathPatternsCondition = requestMappingInfo.getPathPatternsCondition();
|
||||
if(pathPatternsCondition == null){
|
||||
continue;
|
||||
}
|
||||
|
||||
Set<String> urls = requestMappingInfo.getPatternsCondition().getPatterns();
|
||||
Set<String> urls = pathPatternsCondition.getPatternValues();
|
||||
if (CollectionUtils.isEmpty(urls)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -67,14 +67,14 @@ public class WebServerListener implements ApplicationListener<WebServerInitializ
|
||||
String swaggerUrl = URLUtil.normalize(String.format("http://localhost:%d%s/swagger-ui/index.html", port, contextPath), false, true);
|
||||
String knife4jUrl = URLUtil.normalize(String.format("http://localhost:%d%s/doc.html", port, contextPath), false, true);
|
||||
log.warn("\n{}\n" +
|
||||
"\t当前启动环境:\t{} , {}" +
|
||||
"\n\t返回码初始化:\t完成{}个返回码初始化" +
|
||||
"\n\t服务本机地址:\t{}" +
|
||||
"\n\t服务外网地址:\t{}" +
|
||||
"\n\tSwagger地址:\t{}" +
|
||||
"\n\tknife4j地址:\t{}" +
|
||||
"\n-------------------------------------------------------------------------------------\n",
|
||||
title, profile, environmentEnum.getDesc(), codeCount, localhostUrl, externalUrl, swaggerUrl, knife4jUrl);
|
||||
"\t当前启动环境:\t{} , {}" +
|
||||
"\n\t返回码初始化:\t完成{}个返回码初始化" +
|
||||
"\n\t服务本机地址:\t{}" +
|
||||
"\n\t服务外网地址:\t{}" +
|
||||
"\n\tSwagger地址:\t{}" +
|
||||
"\n\tknife4j地址:\t{}" +
|
||||
"\n-------------------------------------------------------------------------------------\n",
|
||||
title, profile, environmentEnum.getDesc(), codeCount, localhostUrl, externalUrl, swaggerUrl, knife4jUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.lab1024.sa.base.module.support.apiencrypt.advice;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||
@@ -33,6 +35,9 @@ public class EncryptResponseAdvice implements ResponseBodyAdvice<ResponseDTO> {
|
||||
@Resource
|
||||
private ApiEncryptService apiEncryptService;
|
||||
|
||||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@Override
|
||||
public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {
|
||||
return returnType.hasMethodAnnotation(ApiEncrypt.class) || returnType.getContainingClass().isAnnotationPresent(ApiEncrypt.class);
|
||||
@@ -44,7 +49,12 @@ public class EncryptResponseAdvice implements ResponseBodyAdvice<ResponseDTO> {
|
||||
return body;
|
||||
}
|
||||
|
||||
String encrypt = apiEncryptService.encrypt(JSON.toJSONString(body.getData()));
|
||||
String encrypt = null;
|
||||
try {
|
||||
encrypt = apiEncryptService.encrypt(objectMapper.writeValueAsString(body.getData()));
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
body.setData(encrypt);
|
||||
body.setDataType(DataTypeEnum.ENCRYPT.getValue());
|
||||
return body;
|
||||
|
||||
@@ -52,14 +52,6 @@ public class ApiEncryptServiceSmImpl implements ApiEncryptService {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String content = "zkm1024";
|
||||
String en = new ApiEncryptServiceSmImpl().encrypt(content);
|
||||
System.out.println(en);
|
||||
String ori = new ApiEncryptServiceSmImpl().decrypt(en);
|
||||
System.out.println(ori);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String decrypt(String data) {
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
package net.lab1024.sa.base.module.support.captcha;
|
||||
|
||||
import com.google.code.kaptcha.impl.DefaultKaptcha;
|
||||
import cn.hutool.captcha.CaptchaUtil;
|
||||
import cn.hutool.captcha.LineCaptcha;
|
||||
import cn.hutool.core.img.ImgUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.sa.base.common.constant.StringConst;
|
||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||
import net.lab1024.sa.base.common.domain.SystemEnvironment;
|
||||
import net.lab1024.sa.base.common.exception.BusinessException;
|
||||
import net.lab1024.sa.base.constant.RedisKeyConst;
|
||||
import net.lab1024.sa.base.module.support.captcha.domain.CaptchaForm;
|
||||
import net.lab1024.sa.base.module.support.captcha.domain.CaptchaVO;
|
||||
import net.lab1024.sa.base.module.support.redis.RedisService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Base64Utils;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.awt.*;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -29,7 +27,7 @@ import java.util.UUID;
|
||||
* @Date 2021/8/31 20:52
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -41,29 +39,31 @@ public class CaptchaService {
|
||||
private static final long EXPIRE_SECOND = 65L;
|
||||
|
||||
@Resource
|
||||
private DefaultKaptcha defaultKaptcha;
|
||||
@Autowired
|
||||
private SystemEnvironment systemEnvironment;
|
||||
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
|
||||
/**
|
||||
* 生成图形验证码
|
||||
* 默认 1 分钟有效期
|
||||
*
|
||||
*/
|
||||
public CaptchaVO generateCaptcha() {
|
||||
String captchaText = defaultKaptcha.createText();
|
||||
BufferedImage image = defaultKaptcha.createImage(captchaText);
|
||||
|
||||
String base64Code;
|
||||
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
|
||||
ImageIO.write(image, "jpg", os);
|
||||
base64Code = Base64Utils.encodeToString(os.toByteArray());
|
||||
} catch (Exception e) {
|
||||
log.error("generateCaptcha error:", e);
|
||||
throw new BusinessException("生成验证码错误");
|
||||
}
|
||||
//生成四位验证码
|
||||
String captchaText = RandomUtil.randomNumbers(4);
|
||||
|
||||
//定义图形验证码的长、宽、验证码位数、干扰线数量
|
||||
LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(125, 43, 4, 80);
|
||||
|
||||
//设置背景颜色
|
||||
lineCaptcha.setBackground(new Color(230, 244, 255));
|
||||
|
||||
//生成图片
|
||||
Image image = lineCaptcha.createImage(captchaText);
|
||||
|
||||
//转为base64
|
||||
String base64Code = ImgUtil.toBase64(image, "jpg");
|
||||
|
||||
/*
|
||||
* 返回验证码对象
|
||||
@@ -86,7 +86,6 @@ public class CaptchaService {
|
||||
|
||||
/**
|
||||
* 校验图形验证码
|
||||
*
|
||||
*/
|
||||
public ResponseDTO<String> checkCaptcha(CaptchaForm captchaForm) {
|
||||
if (StringUtils.isBlank(captchaForm.getCaptchaUuid()) || StringUtils.isBlank(captchaForm.getCaptchaCode())) {
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.captcha.config;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* 验证码颜色
|
||||
*
|
||||
* @Author 1024创新实验室-主任: 卓大
|
||||
* @Date 2021-09-02 20:21:10
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
public class CaptchaColor {
|
||||
|
||||
public static Color getColor() {
|
||||
|
||||
List<Color> colors = Lists.newArrayList();
|
||||
colors.add(new Color(0, 135, 255));
|
||||
colors.add(new Color(51, 153, 51));
|
||||
colors.add(new Color(255, 102, 102));
|
||||
colors.add(new Color(255, 153, 0));
|
||||
colors.add(new Color(153, 102, 0));
|
||||
colors.add(new Color(153, 102, 153));
|
||||
colors.add(new Color(51, 153, 153));
|
||||
colors.add(new Color(102, 102, 255));
|
||||
colors.add(new Color(0, 102, 204));
|
||||
colors.add(new Color(204, 51, 51));
|
||||
colors.add(new Color(128, 153, 65));
|
||||
Random random = new Random();
|
||||
int colorIndex = random.nextInt(10);
|
||||
return colors.get(colorIndex);
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.captcha.config;
|
||||
|
||||
import com.google.code.kaptcha.impl.DefaultKaptcha;
|
||||
import com.google.code.kaptcha.util.Config;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* 验证码配置
|
||||
*
|
||||
* @Author 1024创新实验室-主任: 卓大
|
||||
* @Date 2021-09-02 20:21:10
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Configuration
|
||||
public class CaptchaConfig {
|
||||
|
||||
@Bean
|
||||
public DefaultKaptcha getDefaultKaptcha() {
|
||||
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("kaptcha.border", "no");
|
||||
properties.setProperty("kaptcha.border.color", "34,114,200");
|
||||
properties.setProperty("kaptcha.image.width", "125");
|
||||
properties.setProperty("kaptcha.image.height", "45");
|
||||
properties.setProperty("kaptcha.textproducer.char.string", "123456789");
|
||||
properties.setProperty("kaptcha.textproducer.char.length", "4");
|
||||
properties.setProperty("kaptcha.textproducer.font.names", "Arial,Arial Narrow,Serif,Helvetica,Tahoma,Times New Roman,Verdana");
|
||||
properties.setProperty("kaptcha.textproducer.font.size", "38");
|
||||
|
||||
properties.setProperty("kaptcha.background.clear.from", "white");
|
||||
properties.setProperty("kaptcha.background.clear.to", "white");
|
||||
|
||||
properties.setProperty("kaptcha.word.impl", CaptchaWordRenderer.class.getName());
|
||||
properties.setProperty("kaptcha.noise.impl", CaptchaNoise.class.getName());
|
||||
|
||||
Config config = new Config(properties);
|
||||
defaultKaptcha.setConfig(config);
|
||||
return defaultKaptcha;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.captcha.config;
|
||||
|
||||
import com.google.code.kaptcha.NoiseProducer;
|
||||
import com.google.code.kaptcha.util.Configurable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* 验证码加噪处理
|
||||
*
|
||||
* @Author 1024创新实验室-主任: 卓大
|
||||
* @Date 2021-09-02 20:21:10
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
public class CaptchaNoise extends Configurable implements NoiseProducer {
|
||||
|
||||
public CaptchaNoise() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void makeNoise(BufferedImage image, float factorOne, float factorTwo, float factorThree, float factorFour) {
|
||||
|
||||
int width = image.getWidth();
|
||||
int height = image.getHeight();
|
||||
Graphics2D graph = (Graphics2D) image.getGraphics();
|
||||
graph.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
|
||||
graph.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
|
||||
Random random = new Random();
|
||||
int noiseLineNum = random.nextInt(3);
|
||||
if (noiseLineNum == 0) {
|
||||
noiseLineNum = 1;
|
||||
}
|
||||
for (int i = 0; i < noiseLineNum; i++) {
|
||||
graph.setColor(CaptchaColor.getColor());
|
||||
graph.drawLine(random.nextInt(width), random.nextInt(height), 10 + random.nextInt(20), 10 + random.nextInt(20));
|
||||
}
|
||||
|
||||
graph.dispose();
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.captcha.config;
|
||||
|
||||
import com.google.code.kaptcha.text.WordRenderer;
|
||||
import com.google.code.kaptcha.util.Configurable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import java.awt.font.GlyphVector;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* 验证码字体生成
|
||||
*
|
||||
* @Author 1024创新实验室-主任: 卓大
|
||||
* @Date 2021-09-02 20:21:10
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
public class CaptchaWordRenderer extends Configurable implements WordRenderer {
|
||||
|
||||
public CaptchaWordRenderer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedImage renderWord(String word, int width, int height) {
|
||||
int fontSize = this.getConfig().getTextProducerFontSize();
|
||||
Font[] fonts = this.getConfig().getTextProducerFonts(fontSize);
|
||||
int charSpace = this.getConfig().getTextProducerCharSpace();
|
||||
BufferedImage image = new BufferedImage(width, height, 2);
|
||||
|
||||
Graphics2D g2D = image.createGraphics();
|
||||
g2D.setColor(Color.WHITE);
|
||||
RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
hints.add(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
|
||||
g2D.setRenderingHints(hints);
|
||||
g2D.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
|
||||
|
||||
FontRenderContext frc = g2D.getFontRenderContext();
|
||||
Random random = new Random();
|
||||
int startPosY = (height - fontSize) / 5 + fontSize;
|
||||
char[] wordChars = word.toCharArray();
|
||||
Font[] chosenFonts = new Font[wordChars.length];
|
||||
int[] charWidths = new int[wordChars.length];
|
||||
int widthNeeded = 0;
|
||||
|
||||
int startPosX;
|
||||
for (startPosX = 0; startPosX < wordChars.length; ++startPosX) {
|
||||
chosenFonts[startPosX] = fonts[random.nextInt(fonts.length)];
|
||||
char[] charToDraw = new char[]{wordChars[startPosX]};
|
||||
GlyphVector gv = chosenFonts[startPosX].createGlyphVector(frc, charToDraw);
|
||||
charWidths[startPosX] = (int) gv.getVisualBounds().getWidth();
|
||||
if (startPosX > 0) {
|
||||
widthNeeded += 2;
|
||||
}
|
||||
|
||||
widthNeeded += charWidths[startPosX];
|
||||
}
|
||||
|
||||
startPosX = (width - widthNeeded) / 2;
|
||||
|
||||
for (int i = 0; i < wordChars.length; ++i) {
|
||||
g2D.setColor(CaptchaColor.getColor());
|
||||
g2D.setFont(chosenFonts[i].deriveFont(Font.PLAIN));
|
||||
char[] charToDraw = new char[]{wordChars[i]};
|
||||
g2D.drawChars(charToDraw, 0, charToDraw.length, startPosX, startPosY);
|
||||
startPosX = startPosX + charWidths[i] + charSpace;
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -45,7 +45,7 @@ import java.util.stream.Collectors;
|
||||
* @Date 2022-06-30 22:15:38
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Service
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.util.stream.Collectors;
|
||||
* @Date 2022/9/29 17:20:41
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
public abstract class CodeGenerateBaseVariableService {
|
||||
|
||||
|
||||
@@ -96,12 +96,11 @@ public class AddFormVariableService extends CodeGenerateBaseVariableService {
|
||||
if (Boolean.TRUE.equals(field.getRequiredFlag())) {
|
||||
String notEmptyPrefix = "String".equals(codeField.getJavaType()) ? "@NotBlank" : "@NotNull";
|
||||
finalFieldMap.put("notEmpty", "\n " + notEmptyPrefix + "(message = \"" + codeField.getLabel() + " 不能为空\")");
|
||||
packageList.add("String".equals(codeField.getJavaType()) ? "import javax.validation.constraints.NotBlank;"
|
||||
: "import javax.validation.constraints.NotNull;");
|
||||
packageList.add("String".equals(codeField.getJavaType()) ? "import jakarta.validation.constraints.NotBlank;"
|
||||
: "import jakarta.validation.constraints.NotNull;");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//字典
|
||||
if (SmartStringUtil.isNotEmpty(codeField.getDict())) {
|
||||
finalFieldMap.put("dict", "\n @JsonDeserialize(using = DictValueVoDeserializer.class)");
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.stream.Collectors;
|
||||
* @Date 2022/9/29 17:20:41
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
public class EntityVariableService extends CodeGenerateBaseVariableService {
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.*;
|
||||
* @Date 2022/9/29 17:20:41
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
public class MapperVariableService extends CodeGenerateBaseVariableService {
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.util.stream.Collectors;
|
||||
* @Date 2022/9/29 17:20:41
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
public class QueryFormVariableService extends CodeGenerateBaseVariableService {
|
||||
|
||||
@@ -111,7 +111,7 @@ public class UpdateFormVariableService extends CodeGenerateBaseVariableService {
|
||||
if (Boolean.TRUE.equals(field.getRequiredFlag())) {
|
||||
String notEmptyPrefix = "String".equals(codeField.getJavaType()) ? "@NotBlank" : "@NotNull";
|
||||
finalFieldMap.put("notEmpty", "\n " + notEmptyPrefix + "(message = \"" + codeField.getLabel() + " 不能为空\")");
|
||||
packageList.add("String".equals(codeField.getJavaType()) ? "import javax.validation.constraints.NotBlank;" : "import javax.validation.constraints.NotNull;");
|
||||
packageList.add("String".equals(codeField.getJavaType()) ? "import jakarta.validation.constraints.NotBlank;" : "import jakarta.validation.constraints.NotNull;");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.stream.Collectors;
|
||||
* @Date 2022/9/29 17:20:41
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
public class VOVariableService extends CodeGenerateBaseVariableService {
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.List;
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Service
|
||||
public class DictService {
|
||||
@@ -39,10 +39,6 @@ public class DictService {
|
||||
private DictValueDao dictValueDao;
|
||||
@Resource
|
||||
private DictCacheService dictCacheService;
|
||||
/**
|
||||
* CODE锁
|
||||
*/
|
||||
private static final Interner<String> CODE_POOL = Interners.newWeakInterner();
|
||||
|
||||
|
||||
/**
|
||||
@@ -51,15 +47,15 @@ public class DictService {
|
||||
* @param keyAddForm
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> 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<String> 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 class DictService {
|
||||
* @param valueAddForm
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> 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<String> 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 class DictService {
|
||||
* @param keyUpdateForm
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> 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<String> 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 class DictService {
|
||||
* @param valueUpdateForm
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> valueEdit(DictValueUpdateForm valueUpdateForm) {
|
||||
public synchronized ResponseDTO<String> 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 class DictService {
|
||||
* @param keyIdList
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> keyDelete(List<Long> keyIdList) {
|
||||
public synchronized ResponseDTO<String> keyDelete(List<Long> keyIdList) {
|
||||
if (CollectionUtils.isEmpty(keyIdList)) {
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
dictKeyDao.updateDeletedFlagByIdList(keyIdList, true);
|
||||
//刷新缓存
|
||||
dictCacheService.cacheRefresh();
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
@@ -141,11 +139,13 @@ public class DictService {
|
||||
* @param valueIdList
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> valueDelete(List<Long> valueIdList) {
|
||||
public synchronized ResponseDTO<String> valueDelete(List<Long> valueIdList) {
|
||||
if (CollectionUtils.isEmpty(valueIdList)) {
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
dictValueDao.updateDeletedFlagByIdList(valueIdList, true);
|
||||
//刷新缓存
|
||||
dictCacheService.cacheRefresh();
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ public class DictService {
|
||||
* @return
|
||||
*/
|
||||
public List<DictKeyVO> queryAllKey() {
|
||||
return SmartBeanUtil.copyList(dictKeyDao.selectList(null), DictKeyVO.class);
|
||||
return SmartBeanUtil.copyList(dictKeyDao.selectByDeletedFlag(false), DictKeyVO.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,7 +39,7 @@ import java.util.stream.Collectors;
|
||||
* @Date 2019年10月11日 15:34:47
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Service
|
||||
public class FileService {
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.google.common.collect.Lists;
|
||||
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 class SmartJobService {
|
||||
return ResponseDTO.ok(pageResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加定时任务
|
||||
*
|
||||
* @param addForm
|
||||
* @return
|
||||
*/
|
||||
public synchronized ResponseDTO<String> addJob(SmartJobAddForm addForm) {
|
||||
// 校验参数
|
||||
ResponseDTO<String> 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<String> updateJob(SmartJobUpdateForm updateForm) {
|
||||
public synchronized ResponseDTO<String> 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<String> 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 class SmartJobService {
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验参数
|
||||
* 如需其他校验,请自行添加校验逻辑
|
||||
*
|
||||
* @param addForm
|
||||
* @return
|
||||
*/
|
||||
private ResponseDTO<String> 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,28 +274,23 @@ public class SmartJobService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增定时任务
|
||||
* ps:目前没有业务场景需要通过接口 添加任务
|
||||
* 因为新增定时任务无论如何都需要 手动编码
|
||||
* 需要时手动给数据库增加一条就行
|
||||
* 移除定时任务
|
||||
* 物理删除
|
||||
*
|
||||
* @return
|
||||
* @author huke
|
||||
*/
|
||||
public ResponseDTO<String> addJob() {
|
||||
return ResponseDTO.userErrorParam("暂未支持");
|
||||
public synchronized ResponseDTO<String> 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除定时任务
|
||||
* ps:目前没有业务场景需要通过接口移除,理由同 {@link SmartJobService#addJob},
|
||||
* 彻底移除始终都需要手动删除代码
|
||||
* 如果只是想暂停任务执行,可以调用 {@link SmartJobService#updateJobEnabled}
|
||||
*
|
||||
* @return
|
||||
* @author huke
|
||||
*/
|
||||
public ResponseDTO<String> delJob() {
|
||||
return ResponseDTO.userErrorParam("暂未支持");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -27,4 +27,7 @@ public class SmartJobQueryForm extends PageParam {
|
||||
|
||||
@Schema(description = "是否启用|可选")
|
||||
private Boolean enabledFlag;
|
||||
|
||||
@Schema(description = "是否删除|可选")
|
||||
private Boolean deletedFlag;
|
||||
}
|
||||
|
||||
@@ -16,47 +16,9 @@ import org.hibernate.validator.constraints.Length;
|
||||
* @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;
|
||||
}
|
||||
|
||||
@@ -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 class SmartJobUtil {
|
||||
} 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 class SmartJobUtil {
|
||||
return runtime.getName().split("@")[0];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据className 判断job class
|
||||
*/
|
||||
public static ResponseDTO<String> 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<LocalDateTime> timeList = SmartJobUtil.queryNextTime("5 * * * * *", startTime, 3);
|
||||
@@ -184,5 +204,7 @@ public class SmartJobUtil {
|
||||
|
||||
System.out.println("project path ->" + getProgramPath());
|
||||
System.out.println("project process id ->" + getProcessId());
|
||||
ResponseDTO<String> res = checkJobClass("net.lab1024.sa.base.module.support.job.sample.SmartJobSample1");
|
||||
System.out.println(res.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +103,10 @@ public class SmartJobLauncher {
|
||||
if (!jobEntity.getEnabledFlag()) {
|
||||
continue;
|
||||
}
|
||||
// 任务删除
|
||||
if (jobEntity.getDeletedFlag()) {
|
||||
continue;
|
||||
}
|
||||
// 查找任务实现类
|
||||
SmartJob jobImpl = jobImplMap.get(jobEntity.getJobClass());
|
||||
if (null == jobImpl) {
|
||||
@@ -135,6 +139,7 @@ public class SmartJobLauncher {
|
||||
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());
|
||||
|
||||
@@ -29,4 +29,20 @@ public interface SmartJobDao extends BaseMapper<SmartJobEntity> {
|
||||
* @return
|
||||
*/
|
||||
List<SmartJobVO> 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);
|
||||
}
|
||||
|
||||
@@ -76,6 +76,11 @@ public class SmartJobEntity {
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
private Boolean deletedFlag;
|
||||
|
||||
private String updateName;
|
||||
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@@ -6,6 +6,8 @@ import freemarker.cache.StringTemplateLoader;
|
||||
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.JavaMailSender;
|
||||
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;
|
||||
|
||||
@@ -2,9 +2,11 @@ package net.lab1024.sa.base.module.support.reload.core;
|
||||
|
||||
|
||||
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 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* @Date 2015-03-02 19:11:52
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
public abstract class AbstractSmartReloadCommand {
|
||||
|
||||
/**
|
||||
* 当前ReloadItem的存储器
|
||||
*/
|
||||
private static final ConcurrentHashMap<String, String> TAG_IDENTIFIER_MAP = new ConcurrentHashMap<>();
|
||||
private ConcurrentHashMap<String, String> tagIdentifierMap = new ConcurrentHashMap<>();
|
||||
|
||||
private SmartReloadManager smartReloadManager;
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public void setReloadManager(SmartReloadManager smartReloadManager) {
|
||||
this.smartReloadManager = smartReloadManager;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
List<SmartReloadItem> 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 abstract class AbstractSmartReloadCommand {
|
||||
* @return
|
||||
*/
|
||||
public ConcurrentHashMap<String, String> getTagIdentifierMap() {
|
||||
return TAG_IDENTIFIER_MAP;
|
||||
return tagIdentifierMap;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,6 +77,20 @@ public abstract class AbstractSmartReloadCommand {
|
||||
* @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<String, SmartReloadObject> reloadObjectMap = smartReloadManager.reloadObjectMap();
|
||||
return reloadObjectMap.get(tag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SmartReloadManager implements ApplicationListener<ContextRefreshedEvent> {
|
||||
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<ContextRefreshedE
|
||||
@Resource
|
||||
private AbstractSmartReloadCommand reloadCommand;
|
||||
|
||||
private final static Map<String, SmartReloadObject> RELOAD_OBJECT_MAP = new ConcurrentHashMap<>();
|
||||
private final Map<String, SmartReloadObject> 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 class SmartReloadManager implements ApplicationListener<ContextRefreshedE
|
||||
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 class SmartReloadManager implements ApplicationListener<ContextRefreshedE
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册 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("<<SmartReloadManager>> 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("<<SmartReloadManager>> 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 class SmartReloadManager implements ApplicationListener<ContextRefreshedE
|
||||
* @param smartReloadObject
|
||||
*/
|
||||
private void register(String tag, SmartReloadObject smartReloadObject) {
|
||||
if (RELOAD_OBJECT_MAP.containsKey(tag)) {
|
||||
if (reloadObjectMap.containsKey(tag)) {
|
||||
log.error("<<SmartReloadManager>> register duplicated tag reload : " + tag + " , and it will be cover!");
|
||||
}
|
||||
RELOAD_OBJECT_MAP.put(tag, smartReloadObject);
|
||||
reloadObjectMap.put(tag, smartReloadObject);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,7 +116,9 @@ public class SmartReloadManager implements ApplicationListener<ContextRefreshedE
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static SmartReloadObject getReloadObject(String tag) {
|
||||
return RELOAD_OBJECT_MAP.get(tag);
|
||||
public Map<String, SmartReloadObject> reloadObjectMap() {
|
||||
return this.reloadObjectMap;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -20,17 +20,17 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* @Date 2015-03-02 19:11:52
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@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 class SmartReloadRunnable implements Runnable {
|
||||
*/
|
||||
private void doTask() {
|
||||
if (!isInit) {
|
||||
this.reloadCommand.init();
|
||||
this.abstractSmartReloadCommand.init();
|
||||
isInit = true;
|
||||
return;
|
||||
}
|
||||
|
||||
List<SmartReloadItem> smartReloadItemList = this.reloadCommand.readReloadItem();
|
||||
ConcurrentHashMap<String, String> tagIdentifierMap = this.reloadCommand.getTagIdentifierMap();
|
||||
List<SmartReloadItem> smartReloadItemList = this.abstractSmartReloadCommand.readReloadItem();
|
||||
ConcurrentHashMap<String, String> 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 @@ public class SmartReloadRunnable implements Runnable {
|
||||
*/
|
||||
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);
|
||||
|
||||
@@ -44,7 +44,7 @@ public class Level3ProtectConfigService {
|
||||
/**
|
||||
* 最低活跃时间(单位:秒),超过此时间没有操作系统就会被冻结,默认-1 代表不限制,永不冻结; 默认 30分钟
|
||||
*/
|
||||
private int loginActiveTimeoutSeconds = 1800;
|
||||
private int loginActiveTimeoutSeconds = -1;
|
||||
|
||||
/**
|
||||
* 密码复杂度 是否开启,默认:开启
|
||||
@@ -107,7 +107,7 @@ public class Level3ProtectConfigService {
|
||||
* 最低活跃时间(单位:秒),超过此时间没有操作系统就会被冻结,默认-1 代表不限制,永不冻结; 默认 30分钟
|
||||
*/
|
||||
public int getLoginActiveTimeoutSeconds() {
|
||||
return loginActiveTimeoutSeconds;
|
||||
return loginActiveTimeoutSeconds > 0 ? loginActiveTimeoutSeconds : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,6 +167,7 @@ public class Level3ProtectConfigService {
|
||||
|
||||
if (configForm.getLoginActiveTimeoutMinutes() != null) {
|
||||
this.loginActiveTimeoutSeconds = configForm.getLoginActiveTimeoutMinutes() * 60;
|
||||
this.loginActiveTimeoutSeconds = loginActiveTimeoutSeconds > 0 ? loginActiveTimeoutSeconds : -1;
|
||||
}
|
||||
|
||||
if (configForm.getPasswordComplexityEnabled() != null) {
|
||||
|
||||
@@ -5,6 +5,8 @@ import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* 三级等保 文件上传 相关
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -37,17 +37,16 @@ public interface ${name.upperCamel}Dao extends BaseMapper<${name.upperCamel}Enti
|
||||
/**
|
||||
* 更新删除状态
|
||||
*/
|
||||
long updateDeleted(@Param("${primaryKeyFieldName}")${primaryKeyJavaType} ${primaryKeyFieldName},@Param("${deletedFlag}")boolean deletedFlag);
|
||||
long updateDeleted(@Param("${primaryKeyFieldName}")${primaryKeyJavaType} ${primaryKeyFieldName},@Param("deletedFlag")boolean deletedFlag);
|
||||
|
||||
#end
|
||||
#if($deleteInfo.deleteEnum == "Batch" || $deleteInfo.deleteEnum == "SingleAndBatch")
|
||||
/**
|
||||
* 批量更新删除状态
|
||||
*/
|
||||
void batchUpdateDeleted(@Param("idList")List<${primaryKeyJavaType}> idList,@Param("${deletedFlag}")boolean deletedFlag);
|
||||
void batchUpdateDeleted(@Param("idList")List<${primaryKeyJavaType}> idList,@Param("deletedFlag")boolean deletedFlag);
|
||||
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ spring:
|
||||
host: smtp.163.com
|
||||
port: 465
|
||||
username: lab1024@163.com
|
||||
password: 1
|
||||
password: LAB1024LAB
|
||||
properties:
|
||||
mail:
|
||||
smtp:
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="net.lab1024.sa.base.module.support.job.repository.SmartJobDao">
|
||||
|
||||
<update id="updateDeletedFlag">
|
||||
update t_smart_job
|
||||
set deleted_flag = #{deletedFlag}
|
||||
where job_id = #{jobId}
|
||||
</update>
|
||||
|
||||
<!-- 定时任务-分页查询 -->
|
||||
<select id="query" resultType="net.lab1024.sa.base.module.support.job.api.domain.SmartJobVO">
|
||||
SELECT *
|
||||
@@ -19,10 +25,19 @@
|
||||
<if test="query.enabledFlag != null">
|
||||
AND enabled_flag = #{query.enabledFlag}
|
||||
</if>
|
||||
<if test="query.deletedFlag != null">
|
||||
AND deleted_flag = #{query.deletedFlag}
|
||||
</if>
|
||||
</where>
|
||||
<if test="query.sortItemList == null or query.sortItemList.size == 0">
|
||||
ORDER BY sort ASC,job_id DESC
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectByJobClass" resultType="net.lab1024.sa.base.module.support.job.repository.domain.SmartJobEntity">
|
||||
SELECT *
|
||||
FROM t_smart_job
|
||||
WHERE job_class = #{jobClass}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -40,7 +40,7 @@ spring:
|
||||
host: smtp.163.com
|
||||
port: 465
|
||||
username: lab1024@163.com
|
||||
password: 1
|
||||
password: LAB1024LAB
|
||||
properties:
|
||||
mail:
|
||||
smtp:
|
||||
|
||||
@@ -118,9 +118,6 @@ http:
|
||||
write-timeout: 50000
|
||||
keep-alive: 300000
|
||||
|
||||
# 跨域配置
|
||||
access-control-allow-origin: 'https://preview.smartadmin.vip'
|
||||
|
||||
# 心跳配置
|
||||
heart-beat:
|
||||
interval-seconds: 60
|
||||
|
||||
@@ -40,7 +40,7 @@ spring:
|
||||
host: smtp.163.com
|
||||
port: 465
|
||||
username: lab1024@163.com
|
||||
password: 1
|
||||
password: LAB1024LAB
|
||||
properties:
|
||||
mail:
|
||||
smtp:
|
||||
|
||||
1
smart-admin-api-java8-springboot2/README.md
Normal file
1
smart-admin-api-java8-springboot2/README.md
Normal file
@@ -0,0 +1 @@
|
||||
# Smart Admin API
|
||||
@@ -31,7 +31,6 @@
|
||||
<google-linkedhashmap.version>1.4.2</google-linkedhashmap.version>
|
||||
<google-guava.version>20.0</google-guava.version>
|
||||
<user-agent-utils.version>1.21</user-agent-utils.version>
|
||||
<kaptcha.version>2.3.2</kaptcha.version>
|
||||
<reflections.version>0.9.11</reflections.version>
|
||||
<commons-io.version>2.15.0</commons-io.version>
|
||||
<commons-lang3.version>3.12.0</commons-lang3.version>
|
||||
@@ -152,12 +151,6 @@
|
||||
<version>${user-agent-utils.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.penggle</groupId>
|
||||
<artifactId>kaptcha</artifactId>
|
||||
<version>${kaptcha.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
@@ -86,7 +86,7 @@ public class AdminInterceptor implements HandlerInterceptor {
|
||||
Method method = ((HandlerMethod) handler).getMethod();
|
||||
NoNeedLogin noNeedLogin = ((HandlerMethod) handler).getMethodAnnotation(NoNeedLogin.class);
|
||||
if (noNeedLogin != null) {
|
||||
checkActiveTimeout(requestEmployee,debugNumberTokenFlag);
|
||||
checkActiveTimeout(requestEmployee, debugNumberTokenFlag);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class AdminInterceptor implements HandlerInterceptor {
|
||||
}
|
||||
|
||||
// 检测token 活跃频率
|
||||
checkActiveTimeout(requestEmployee,debugNumberTokenFlag);
|
||||
checkActiveTimeout(requestEmployee, debugNumberTokenFlag);
|
||||
|
||||
|
||||
// --------------- 第三步: 校验 权限 ---------------
|
||||
@@ -107,8 +107,8 @@ public class AdminInterceptor implements HandlerInterceptor {
|
||||
}
|
||||
|
||||
// 如果是超级管理员的话,不需要校验权限
|
||||
if(requestEmployee.getAdministratorFlag()){
|
||||
return true;
|
||||
if (requestEmployee.getAdministratorFlag()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
SaStrategy.instance.checkMethodAnnotation.accept(method);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user