Compare commits

...

7 Commits

Author SHA1 Message Date
丁磊
db575be748 // 移除占位符对应的值为空或null的占位符//日期格式化 2025-02-11 16:16:10 +08:00
曾文豪
f8d7e49290 publish 2.0.18
All checks were successful
/ local-deploy (push) Successful in 19s
2024-12-13 20:20:29 +08:00
曾文豪
2cf88cefa7 publish 2.0.17
All checks were successful
/ local-deploy (push) Successful in 20s
2024-12-08 12:00:48 +08:00
曾文豪
9a56994342 publish 2.0.16
All checks were successful
/ local-deploy (push) Successful in 20s
2024-12-08 11:53:36 +08:00
曾文豪
a987689bd6 perf:优化登录次数校验 2024-12-08 11:53:11 +08:00
曾文豪
690dffa779 publish 2.0.15
All checks were successful
/ local-deploy (push) Successful in 18s
2024-12-08 10:23:38 +08:00
曾文豪
3ccbd6cd8e feat:configKey增加缓存 2024-12-08 10:22:44 +08:00
16 changed files with 100 additions and 42 deletions

18
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.14</version> <version>2.0.18</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>springboot-parent</name> <name>springboot-parent</name>
<description>杭州铁晟科技有限公司基础依赖</description> <description>杭州铁晟科技有限公司基础依赖</description>
@@ -58,49 +58,49 @@
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-database</artifactId> <artifactId>springboot-database</artifactId>
<version>2.0.14</version> <version>2.0.18</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-login</artifactId> <artifactId>springboot-login</artifactId>
<version>2.0.14</version> <version>2.0.18</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-web</artifactId> <artifactId>springboot-web</artifactId>
<version>2.0.14</version> <version>2.0.18</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-util</artifactId> <artifactId>springboot-util</artifactId>
<version>2.0.14</version> <version>2.0.18</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-platform</artifactId> <artifactId>springboot-platform</artifactId>
<version>2.0.14</version> <version>2.0.18</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-message</artifactId> <artifactId>springboot-message</artifactId>
<version>2.0.14</version> <version>2.0.18</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-role</artifactId> <artifactId>springboot-role</artifactId>
<version>2.0.14</version> <version>2.0.18</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-annotation</artifactId> <artifactId>springboot-annotation</artifactId>
<version>2.0.14</version> <version>2.0.18</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@@ -6,11 +6,11 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.14</version> <version>2.0.18</version>
</parent> </parent>
<artifactId>springboot-ademo</artifactId> <artifactId>springboot-ademo</artifactId>
<version>2.0.14</version> <version>2.0.18</version>
<properties> <properties>
<maven.compiler.source>8</maven.compiler.source> <maven.compiler.source>8</maven.compiler.source>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.14</version> <version>2.0.18</version>
</parent> </parent>
<artifactId>springboot-annotation</artifactId> <artifactId>springboot-annotation</artifactId>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.14</version> <version>2.0.18</version>
</parent> </parent>
<artifactId>springboot-database</artifactId> <artifactId>springboot-database</artifactId>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.14</version> <version>2.0.18</version>
</parent> </parent>
<artifactId>springboot-login</artifactId> <artifactId>springboot-login</artifactId>

View File

@@ -43,9 +43,12 @@ public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueM
*/ */
public TokenBean login(DoLoginInfo loginInfo) { public TokenBean login(DoLoginInfo loginInfo) {
int loginErrorTimes = coreLogLoginMapper.getLoginErrorTimes(loginInfo.getLoginIp()); int loginErrorTimes = tsLoginConfigurer.getLoginErrorTimes();
if (loginErrorTimes > 4) { if (loginErrorTimes > 0) {
throw new ApiException("登录失败已达5次请10分钟后再试"); int currentErrorTimes = coreLogLoginMapper.getLoginErrorTimes(loginInfo.getLoginIp());
if (currentErrorTimes >= loginErrorTimes) {
throw new ApiException("登录失败已达" + loginErrorTimes + "请10分钟后再试");
}
} }
CorePlatformUnique platformUnique = getOneByColumn("unique_id", loginInfo.getUnique()); CorePlatformUnique platformUnique = getOneByColumn("unique_id", loginInfo.getUnique());

View File

@@ -36,7 +36,7 @@ public interface TsLoginConfigurer {
/** /**
* 登录失败的时候 * 登录失败的时候
*/ */
default void onLoginError(String to,HttpServletResponse response) { default void onLoginError(String to, HttpServletResponse response) {
ServletKit.write(response, "404", "text"); ServletKit.write(response, "404", "text");
} }
@@ -66,4 +66,14 @@ public interface TsLoginConfigurer {
*/ */
RequestUserInfo getCurrentUserName(TokenBean userId); RequestUserInfo getCurrentUserName(TokenBean userId);
/**
* 获取登录失败的次数默认5次
*
* @return
*/
default int getLoginErrorTimes() {
return 0;
}
} }

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.14</version> <version>2.0.18</version>
</parent> </parent>
<artifactId>springboot-message</artifactId> <artifactId>springboot-message</artifactId>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.14</version> <version>2.0.18</version>
</parent> </parent>
<artifactId>springboot-platform</artifactId> <artifactId>springboot-platform</artifactId>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.14</version> <version>2.0.18</version>
</parent> </parent>
<artifactId>springboot-role</artifactId> <artifactId>springboot-role</artifactId>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.14</version> <version>2.0.18</version>
</parent> </parent>
<artifactId>springboot-util</artifactId> <artifactId>springboot-util</artifactId>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.14</version> <version>2.0.18</version>
</parent> </parent>
<artifactId>springboot-web</artifactId> <artifactId>springboot-web</artifactId>

View File

@@ -1,6 +1,7 @@
package com.tiesheng.web.config.operation; package com.tiesheng.web.config.operation;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
@@ -19,6 +20,7 @@ import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@@ -100,6 +102,18 @@ public class OperationAspect {
subject = (StrUtil.isEmpty(insertVal) ? "添加" : "编辑") + subject; subject = (StrUtil.isEmpty(insertVal) ? "添加" : "编辑") + subject;
} }
for (String key : allParams.keySet()) {
Object value = allParams.get(key);
if (value == null || StrUtil.isEmpty(value.toString())) {
// 移除占位符对应的值为空或null的占位符
String placeholder = "{" + key + "}";
subject = subject.replace(placeholder, "");
} else if (value instanceof Date) {
//日期格式化
allParams.put(key, DateUtil.format((Date) value,"yyyy-MM-dd HH:mm:ss"));
}
}
// 占位符处理 // 占位符处理
subject = StrUtil.format(subject, allParams); subject = StrUtil.format(subject, allParams);
} else { } else {

View File

@@ -4,7 +4,6 @@ package com.tiesheng.web.controller.system;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tiesheng.annotation.role.RoleAuthority; import com.tiesheng.annotation.role.RoleAuthority;
import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.pojos.ApiResp; import com.tiesheng.util.pojos.ApiResp;
import com.tiesheng.util.pojos.PageDTO; import com.tiesheng.util.pojos.PageDTO;
import com.tiesheng.web.pojos.dao.CoreConfigSystem; import com.tiesheng.web.pojos.dao.CoreConfigSystem;
@@ -57,21 +56,8 @@ public class ConfigSystemController {
*/ */
@PostMapping("/system/update") @PostMapping("/system/update")
public ApiResp<String> systemUpdate(@RequestBody ConfigSystemDTO dto) { public ApiResp<String> systemUpdate(@RequestBody ConfigSystemDTO dto) {
tieshengWebConfigurer.configSystemCheck(dto);
CoreConfigSystem configKey = coreConfigService.getOneByColumn("config_key", dto.getConfigKey()); coreConfigService.updateConfigSystem(dto);
if (configKey == null) {
throw new ApiException("该配置不存在,请检查");
}
if (configKey.getReadOnly() == 1) {
throw new ApiException("该配置只读,不可修改");
}
configKey.setConfigVal(dto.getConfigVal());
configKey.setRemark(dto.getRemark());
configKey.setExtra(dto.getExtra());
tieshengWebConfigurer.configSystemCheck(configKey);
coreConfigService.updateById(configKey);
return ApiResp.respOK(""); return ApiResp.respOK("");
} }

View File

@@ -1,12 +1,17 @@
package com.tiesheng.web.service; package com.tiesheng.web.service;
import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.service.TsCacheService;
import com.tiesheng.util.service.TsServiceBase;
import com.tiesheng.web.mapper.CoreConfigEnumMapper; import com.tiesheng.web.mapper.CoreConfigEnumMapper;
import com.tiesheng.web.mapper.CoreConfigSystemMapper; import com.tiesheng.web.mapper.CoreConfigSystemMapper;
import com.tiesheng.web.pojos.dao.CoreConfigSystem; import com.tiesheng.web.pojos.dao.CoreConfigSystem;
import com.tiesheng.util.service.TsServiceBase; import com.tiesheng.web.pojos.dto.config.ConfigSystemDTO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/** /**
* @author hao * @author hao
*/ */
@@ -15,6 +20,11 @@ public class CoreConfigService extends TsServiceBase<CoreConfigSystemMapper, Cor
@Autowired @Autowired
CoreConfigEnumMapper coreConfigEnumMapper; CoreConfigEnumMapper coreConfigEnumMapper;
@Resource
TsCacheService tsCacheService;
private static final String CONFIG_SYSTEM_PREFIX = "CONFIG:SYSTEM:";
public CoreConfigEnumMapper getEnumMapper() { public CoreConfigEnumMapper getEnumMapper() {
return coreConfigEnumMapper; return coreConfigEnumMapper;
@@ -28,7 +38,14 @@ public class CoreConfigService extends TsServiceBase<CoreConfigSystemMapper, Cor
* @return * @return
*/ */
public CoreConfigSystem getTextOrCreate(String configKey, String defaultValue) { public CoreConfigSystem getTextOrCreate(String configKey, String defaultValue) {
CoreConfigSystem oneByColumn = getOneByColumn("config_key", configKey); CoreConfigSystem oneByColumn = tsCacheService.getObj(CONFIG_SYSTEM_PREFIX + configKey,
CoreConfigSystem.class, -1);
if (oneByColumn != null) {
return oneByColumn;
}
oneByColumn = getOneByColumn("config_key", configKey);
if (oneByColumn == null) { if (oneByColumn == null) {
oneByColumn = new CoreConfigSystem(); oneByColumn = new CoreConfigSystem();
oneByColumn.setId(configKey); oneByColumn.setId(configKey);
@@ -38,7 +55,34 @@ public class CoreConfigService extends TsServiceBase<CoreConfigSystemMapper, Cor
oneByColumn.setConfigType(0); oneByColumn.setConfigType(0);
save(oneByColumn); save(oneByColumn);
} }
tsCacheService.putObj(CONFIG_SYSTEM_PREFIX + configKey, oneByColumn, 10 * 60);
return oneByColumn; return oneByColumn;
} }
/**
* 更新数据
*
* @param dto
*/
public void updateConfigSystem(ConfigSystemDTO dto) {
CoreConfigSystem coreConfigSystem = getOneByColumn("config_key", dto.getConfigKey());
if (coreConfigSystem == null) {
throw new ApiException("该配置不存在,请检查");
}
if (coreConfigSystem.getReadOnly() == 1) {
throw new ApiException("该配置只读,不可修改");
}
coreConfigSystem.setConfigVal(dto.getConfigVal());
coreConfigSystem.setRemark(dto.getRemark());
coreConfigSystem.setExtra(dto.getExtra());
updateById(coreConfigSystem);
tsCacheService.putObj(CONFIG_SYSTEM_PREFIX + coreConfigSystem.getConfigKey(),
coreConfigSystem, 10 * 60);
}
} }

View File

@@ -5,6 +5,7 @@ import com.tiesheng.login.service.TsLoginConfigurer;
import com.tiesheng.util.exception.ApiRespEnum; import com.tiesheng.util.exception.ApiRespEnum;
import com.tiesheng.util.pojos.ApiResp; import com.tiesheng.util.pojos.ApiResp;
import com.tiesheng.web.pojos.dao.CoreConfigSystem; import com.tiesheng.web.pojos.dao.CoreConfigSystem;
import com.tiesheng.web.pojos.dto.config.ConfigSystemDTO;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
/** /**
@@ -58,7 +59,7 @@ public interface TieshengWebConfigurer {
* 系统配置验证 * 系统配置验证
* 如果不符合规则,可以抛出异常 * 如果不符合规则,可以抛出异常
*/ */
default void configSystemCheck(CoreConfigSystem configSystem) { default void configSystemCheck(ConfigSystemDTO dto) {
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////