Compare commits

...

3 Commits

Author SHA1 Message Date
smallchill de41acdd51 SqlKeyword类增加特殊字符清除逻辑 2024-04-26 00:25:22 +08:00
smallchill 5622c81a11 Merge remote-tracking branch 'origin/master' 2024-04-26 00:24:54 +08:00
smallchill ff7cf290c5 🎉 优化swagger配置逻辑 2024-04-26 00:24:43 +08:00
4 changed files with 20 additions and 12 deletions

View File

@ -50,14 +50,14 @@ public class BaseEntity implements Serializable {
* 创建人
*/
@JsonSerialize(using = ToStringSerializer.class)
@Schema(description = "创建人")
@Schema(description = "创建人", hidden = true)
private Long createUser;
/**
* 创建部门
*/
@JsonSerialize(using = ToStringSerializer.class)
@Schema(description = "创建部门")
@Schema(description = "创建部门", hidden = true)
private Long createDept;
/**
@ -65,14 +65,14 @@ public class BaseEntity implements Serializable {
*/
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
@Schema(description = "创建时间")
@Schema(description = "创建时间", hidden = true)
private Date createTime;
/**
* 更新人
*/
@JsonSerialize(using = ToStringSerializer.class)
@Schema(description = "更新人")
@Schema(description = "更新人", hidden = true)
private Long updateUser;
/**
@ -80,19 +80,19 @@ public class BaseEntity implements Serializable {
*/
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
@Schema(description = "更新时间")
@Schema(description = "更新时间", hidden = true)
private Date updateTime;
/**
* 状态[1:正常]
*/
@Schema(description = "业务状态")
@Schema(description = "业务状态", hidden = true)
private Integer status;
/**
* 状态[0:未删除,1:删除]
*/
@TableLogic
@Schema(description = "是否已删除")
@Schema(description = "是否已删除", hidden = true)
private Integer isDeleted;
}

View File

@ -138,11 +138,13 @@ public class SqlKeyword {
*/
@SneakyThrows(SQLException.class)
public static String filter(String param) {
if (param == null) {
// 清除特殊字符
String cleaned = StringUtil.cleanIdentifier(param);
if (cleaned == null) {
return null;
}
// 将校验到的sql关键词替换为空字符串
String sql = param.replaceAll(SQL_REGEX, StringPool.EMPTY);
String sql = cleaned.replaceAll(SQL_REGEX, StringPool.EMPTY);
// 二次校验避免双写绕过等情况出现
if (match(sql)) {
throw new SQLException(SQL_INJECTION_MESSAGE);

View File

@ -34,11 +34,15 @@ public class SwaggerLauncherServiceImpl implements LauncherService {
public void launcher(SpringApplicationBuilder builder, String appName, String profile) {
Properties props = System.getProperties();
if (profile.equals(AppConstant.PROD_CODE)) {
props.setProperty("knife4j.production", "true");
props.setProperty("swagger.enabled", "false");
props.setProperty("knife4j.enable", "false");
props.setProperty("knife4j.production", "true");
} else {
props.setProperty("swagger.enabled", "true");
props.setProperty("knife4j.enable", "true");
props.setProperty("knife4j.production", "false");
props.setProperty("spring.mvc.pathmatch.matching-strategy", "ANT_PATH_MATCHER");
}
props.setProperty("knife4j.enable", "true");
props.setProperty("spring.mvc.pathmatch.matching-strategy", "ANT_PATH_MATCHER");
}
@Override

View File

@ -8,6 +8,8 @@ springdoc:
api-docs:
enabled: true
path: /v3/api-docs
# 默认是false需要设置为true
default-flat-param-object: true
#knife4j配置
knife4j: