mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-11-09 16:57:16 +08:00
chore: continew-starter 2.0.0 => 2.0.1
This commit is contained in:
@@ -29,6 +29,7 @@ import lombok.NoArgsConstructor;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
import top.continew.admin.common.constant.RegexConstants;
|
import top.continew.admin.common.constant.RegexConstants;
|
||||||
|
import top.continew.starter.core.util.StrUtils;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@@ -130,9 +131,8 @@ public class GenConfigDO implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getClassNamePrefix() {
|
public String getClassNamePrefix() {
|
||||||
String rawClassName = StrUtil.isNotBlank(this.tablePrefix)
|
String rawClassName = StrUtils.blankToDefault(this.tablePrefix, this.tableName, prefix -> StrUtil
|
||||||
? StrUtil.removePrefix(this.tableName, this.tablePrefix)
|
.removePrefix(this.tableName, prefix));
|
||||||
: this.tableName;
|
|
||||||
return StrUtil.upperFirst(StrUtil.toCamelCase(rawClassName));
|
return StrUtil.upperFirst(StrUtil.toCamelCase(rawClassName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,16 +100,14 @@ public class LoginServiceImpl implements LoginService {
|
|||||||
if (maxErrorCount <= 0) {
|
if (maxErrorCount <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String key = CacheConstants.USER_KEY_PREFIX + "PASSWORD-ERROR:" + username;
|
|
||||||
Long currentErrorCount = RedisUtils.get(key);
|
|
||||||
currentErrorCount = currentErrorCount == null ? 0 : currentErrorCount;
|
|
||||||
int lockMinutes = optionService.getValueByCode2Int(OptionCodeEnum.PASSWORD_LOCK_MINUTES);
|
int lockMinutes = optionService.getValueByCode2Int(OptionCodeEnum.PASSWORD_LOCK_MINUTES);
|
||||||
|
String key = CacheConstants.USER_KEY_PREFIX + "PASSWORD-ERROR:" + username;
|
||||||
|
long currentErrorCount = 0;
|
||||||
if (isError) {
|
if (isError) {
|
||||||
// 密码错误自增次数,并重置时间
|
currentErrorCount = RedisUtils.incr(key);
|
||||||
currentErrorCount = currentErrorCount + 1;
|
RedisUtils.expire(key, Duration.ofMinutes(lockMinutes));
|
||||||
RedisUtils.set(key, currentErrorCount, Duration.ofMinutes(lockMinutes));
|
|
||||||
}
|
}
|
||||||
CheckUtils.throwIf(currentErrorCount >= maxErrorCount, "密码错误已达 {} 次,账户锁定 {} 分钟", maxErrorCount, lockMinutes);
|
CheckUtils.throwIf(currentErrorCount > maxErrorCount, "密码错误已达 {} 次,账户锁定 {} 分钟", maxErrorCount, lockMinutes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import top.continew.admin.system.model.entity.LogDO;
|
|||||||
import top.continew.admin.system.service.UserService;
|
import top.continew.admin.system.service.UserService;
|
||||||
import top.continew.starter.core.constant.StringConstants;
|
import top.continew.starter.core.constant.StringConstants;
|
||||||
import top.continew.starter.core.util.ExceptionUtils;
|
import top.continew.starter.core.util.ExceptionUtils;
|
||||||
|
import top.continew.starter.core.util.StrUtils;
|
||||||
import top.continew.starter.log.core.dao.LogDao;
|
import top.continew.starter.log.core.dao.LogDao;
|
||||||
import top.continew.starter.log.core.model.LogRecord;
|
import top.continew.starter.log.core.model.LogRecord;
|
||||||
import top.continew.starter.log.core.model.LogRequest;
|
import top.continew.starter.log.core.model.LogRequest;
|
||||||
@@ -67,9 +68,7 @@ public class LogDaoLocalImpl implements LogDao {
|
|||||||
LogDO logDO = new LogDO();
|
LogDO logDO = new LogDO();
|
||||||
logDO.setDescription(logRecord.getDescription());
|
logDO.setDescription(logRecord.getDescription());
|
||||||
String module = logRecord.getModule();
|
String module = logRecord.getModule();
|
||||||
logDO.setModule(StrUtil.isNotBlank(module)
|
logDO.setModule(StrUtils.blankToDefault(module, null, m -> m.replace("API", StringConstants.EMPTY).trim()));
|
||||||
? logRecord.getModule().replace("API", StringConstants.EMPTY).trim()
|
|
||||||
: null);
|
|
||||||
logDO.setCreateTime(LocalDateTime.ofInstant(logRecord.getTimestamp(), ZoneId.systemDefault()));
|
logDO.setCreateTime(LocalDateTime.ofInstant(logRecord.getTimestamp(), ZoneId.systemDefault()));
|
||||||
logDO.setTimeTaken(logRecord.getTimeTaken().toMillis());
|
logDO.setTimeTaken(logRecord.getTimeTaken().toMillis());
|
||||||
// 请求信息
|
// 请求信息
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import lombok.Data;
|
|||||||
import org.dromara.x.file.storage.core.FileInfo;
|
import org.dromara.x.file.storage.core.FileInfo;
|
||||||
import top.continew.admin.system.enums.FileTypeEnum;
|
import top.continew.admin.system.enums.FileTypeEnum;
|
||||||
import top.continew.starter.core.constant.StringConstants;
|
import top.continew.starter.core.constant.StringConstants;
|
||||||
|
import top.continew.starter.core.util.StrUtils;
|
||||||
import top.continew.starter.core.util.URLUtils;
|
import top.continew.starter.core.util.URLUtils;
|
||||||
import top.continew.starter.extension.crud.model.entity.BaseDO;
|
import top.continew.starter.extension.crud.model.entity.BaseDO;
|
||||||
|
|
||||||
@@ -93,9 +94,8 @@ public class FileDO extends BaseDO {
|
|||||||
*/
|
*/
|
||||||
public FileInfo toFileInfo(String storageCode) {
|
public FileInfo toFileInfo(String storageCode) {
|
||||||
FileInfo fileInfo = new FileInfo();
|
FileInfo fileInfo = new FileInfo();
|
||||||
fileInfo.setOriginalFilename(StrUtil.isNotBlank(this.extension)
|
fileInfo.setOriginalFilename(StrUtils
|
||||||
? this.name + StringConstants.DOT + this.extension
|
.blankToDefault(this.extension, this.name, ex -> this.name + StringConstants.DOT + ex));
|
||||||
: this.name);
|
|
||||||
fileInfo.setSize(this.size);
|
fileInfo.setSize(this.size);
|
||||||
fileInfo.setUrl(this.url);
|
fileInfo.setUrl(this.url);
|
||||||
fileInfo.setExt(this.extension);
|
fileInfo.setExt(this.extension);
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ public class FileServiceImpl extends BaseServiceImpl<FileMapper, FileDO, FileRes
|
|||||||
storage = storageService.getByCode(storageCode);
|
storage = storageService.getByCode(storageCode);
|
||||||
CheckUtils.throwIfNotExists(storage, "StorageDO", "Code", storageCode);
|
CheckUtils.throwIfNotExists(storage, "StorageDO", "Code", storageCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
UploadPretreatment uploadPretreatment = fileStorageService.of(file)
|
UploadPretreatment uploadPretreatment = fileStorageService.of(file)
|
||||||
.thumbnail(img -> img.size(100, 100))
|
.thumbnail(img -> img.size(100, 100))
|
||||||
.setPlatform(storage.getCode())
|
.setPlatform(storage.getCode())
|
||||||
|
|||||||
@@ -159,7 +159,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public String uploadAvatar(MultipartFile avatarFile, Long id) {
|
public String uploadAvatar(MultipartFile avatarFile, Long id) {
|
||||||
String avatarImageType = FileNameUtil.extName(avatarFile.getOriginalFilename());
|
String avatarImageType = FileNameUtil.extName(avatarFile.getOriginalFilename());
|
||||||
CheckUtils.throwIf(!StrUtil.equalsAnyIgnoreCase(avatarImageType, avatarSupportSuffix), "头像仅支持 {} 格式的图片", String
|
CheckUtils.throwIf(!StrUtil.equalsAnyIgnoreCase(avatarImageType, avatarSupportSuffix), "头像仅支持 {} 格式的图片", String
|
||||||
@@ -290,7 +289,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void updateRole(UserRoleUpdateReq updateReq, Long id) {
|
public void updateRole(UserRoleUpdateReq updateReq, Long id) {
|
||||||
super.getById(id);
|
super.getById(id);
|
||||||
// 保存用户和角色关联
|
// 保存用户和角色关联
|
||||||
@@ -335,31 +333,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void beforeAdd(UserReq req) {
|
protected QueryWrapper<UserDO> buildQueryWrapper(UserQuery query) {
|
||||||
final String errorMsgTemplate = "新增失败,[{}] 已存在";
|
|
||||||
String username = req.getUsername();
|
|
||||||
CheckUtils.throwIf(this.isNameExists(username, null), errorMsgTemplate, username);
|
|
||||||
String email = req.getEmail();
|
|
||||||
CheckUtils.throwIf(StrUtil.isNotBlank(email) && this.isEmailExists(email, null), errorMsgTemplate, email);
|
|
||||||
String phone = req.getPhone();
|
|
||||||
CheckUtils.throwIf(StrUtil.isNotBlank(phone) && this.isPhoneExists(phone, null), errorMsgTemplate, phone);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void afterAdd(UserReq req, UserDO user) {
|
|
||||||
Long userId = user.getId();
|
|
||||||
baseMapper.lambdaUpdate().set(UserDO::getPwdResetTime, LocalDateTime.now()).eq(UserDO::getId, userId).update();
|
|
||||||
// 保存用户和角色关联
|
|
||||||
userRoleService.add(req.getRoleIds(), userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建 QueryWrapper
|
|
||||||
*
|
|
||||||
* @param query 查询条件
|
|
||||||
* @return QueryWrapper
|
|
||||||
*/
|
|
||||||
private QueryWrapper<UserDO> buildQueryWrapper(UserQuery query) {
|
|
||||||
String description = query.getDescription();
|
String description = query.getDescription();
|
||||||
Integer status = query.getStatus();
|
Integer status = query.getStatus();
|
||||||
List<Date> createTimeList = query.getCreateTime();
|
List<Date> createTimeList = query.getCreateTime();
|
||||||
@@ -382,6 +356,25 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void beforeAdd(UserReq req) {
|
||||||
|
final String errorMsgTemplate = "新增失败,[{}] 已存在";
|
||||||
|
String username = req.getUsername();
|
||||||
|
CheckUtils.throwIf(this.isNameExists(username, null), errorMsgTemplate, username);
|
||||||
|
String email = req.getEmail();
|
||||||
|
CheckUtils.throwIf(StrUtil.isNotBlank(email) && this.isEmailExists(email, null), errorMsgTemplate, email);
|
||||||
|
String phone = req.getPhone();
|
||||||
|
CheckUtils.throwIf(StrUtil.isNotBlank(phone) && this.isPhoneExists(phone, null), errorMsgTemplate, phone);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void afterAdd(UserReq req, UserDO user) {
|
||||||
|
Long userId = user.getId();
|
||||||
|
baseMapper.lambdaUpdate().set(UserDO::getPwdResetTime, LocalDateTime.now()).eq(UserDO::getId, userId).update();
|
||||||
|
// 保存用户和角色关联
|
||||||
|
userRoleService.add(req.getRoleIds(), userId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 名称是否存在
|
* 名称是否存在
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -5,5 +5,5 @@
|
|||||||
\____|\___/ |_| |_| \__||_||_| \_| \___| \_/\_/ /_/ \_\\__,_||_| |_| |_||_||_| |_|
|
\____|\___/ |_| |_| \__||_||_| \_| \___| \_/\_/ /_/ \_\\__,_||_| |_| |_||_||_| |_|
|
||||||
|
|
||||||
:: ${project.name} :: v${project.version}
|
:: ${project.name} :: v${project.version}
|
||||||
:: ContiNew Starter :: v2.0.0
|
:: ContiNew Starter :: v2.0.1
|
||||||
:: Spring Boot :: v${spring-boot.version}
|
:: Spring Boot :: v${spring-boot.version}
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@@ -12,7 +12,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>top.continew</groupId>
|
<groupId>top.continew</groupId>
|
||||||
<artifactId>continew-starter</artifactId>
|
<artifactId>continew-starter</artifactId>
|
||||||
<version>2.0.0</version>
|
<version>2.0.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>top.continew</groupId>
|
<groupId>top.continew</groupId>
|
||||||
|
|||||||
Reference in New Issue
Block a user