mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-10 19:00:53 +08:00
chore: continew-starter 2.0.0 => 2.0.1
This commit is contained in:
@@ -100,16 +100,14 @@ public class LoginServiceImpl implements LoginService {
|
||||
if (maxErrorCount <= 0) {
|
||||
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);
|
||||
String key = CacheConstants.USER_KEY_PREFIX + "PASSWORD-ERROR:" + username;
|
||||
long currentErrorCount = 0;
|
||||
if (isError) {
|
||||
// 密码错误自增次数,并重置时间
|
||||
currentErrorCount = currentErrorCount + 1;
|
||||
RedisUtils.set(key, currentErrorCount, Duration.ofMinutes(lockMinutes));
|
||||
currentErrorCount = RedisUtils.incr(key);
|
||||
RedisUtils.expire(key, Duration.ofMinutes(lockMinutes));
|
||||
}
|
||||
CheckUtils.throwIf(currentErrorCount >= maxErrorCount, "密码错误已达 {} 次,账户锁定 {} 分钟", maxErrorCount, lockMinutes);
|
||||
CheckUtils.throwIf(currentErrorCount > maxErrorCount, "密码错误已达 {} 次,账户锁定 {} 分钟", maxErrorCount, lockMinutes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -35,6 +35,7 @@ import top.continew.admin.system.model.entity.LogDO;
|
||||
import top.continew.admin.system.service.UserService;
|
||||
import top.continew.starter.core.constant.StringConstants;
|
||||
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.model.LogRecord;
|
||||
import top.continew.starter.log.core.model.LogRequest;
|
||||
@@ -67,9 +68,7 @@ public class LogDaoLocalImpl implements LogDao {
|
||||
LogDO logDO = new LogDO();
|
||||
logDO.setDescription(logRecord.getDescription());
|
||||
String module = logRecord.getModule();
|
||||
logDO.setModule(StrUtil.isNotBlank(module)
|
||||
? logRecord.getModule().replace("API", StringConstants.EMPTY).trim()
|
||||
: null);
|
||||
logDO.setModule(StrUtils.blankToDefault(module, null, m -> m.replace("API", StringConstants.EMPTY).trim()));
|
||||
logDO.setCreateTime(LocalDateTime.ofInstant(logRecord.getTimestamp(), ZoneId.systemDefault()));
|
||||
logDO.setTimeTaken(logRecord.getTimeTaken().toMillis());
|
||||
// 请求信息
|
||||
|
@@ -24,6 +24,7 @@ import lombok.Data;
|
||||
import org.dromara.x.file.storage.core.FileInfo;
|
||||
import top.continew.admin.system.enums.FileTypeEnum;
|
||||
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.extension.crud.model.entity.BaseDO;
|
||||
|
||||
@@ -93,9 +94,8 @@ public class FileDO extends BaseDO {
|
||||
*/
|
||||
public FileInfo toFileInfo(String storageCode) {
|
||||
FileInfo fileInfo = new FileInfo();
|
||||
fileInfo.setOriginalFilename(StrUtil.isNotBlank(this.extension)
|
||||
? this.name + StringConstants.DOT + this.extension
|
||||
: this.name);
|
||||
fileInfo.setOriginalFilename(StrUtils
|
||||
.blankToDefault(this.extension, this.name, ex -> this.name + StringConstants.DOT + ex));
|
||||
fileInfo.setSize(this.size);
|
||||
fileInfo.setUrl(this.url);
|
||||
fileInfo.setExt(this.extension);
|
||||
|
@@ -84,7 +84,6 @@ public class FileServiceImpl extends BaseServiceImpl<FileMapper, FileDO, FileRes
|
||||
storage = storageService.getByCode(storageCode);
|
||||
CheckUtils.throwIfNotExists(storage, "StorageDO", "Code", storageCode);
|
||||
}
|
||||
|
||||
UploadPretreatment uploadPretreatment = fileStorageService.of(file)
|
||||
.thumbnail(img -> img.size(100, 100))
|
||||
.setPlatform(storage.getCode())
|
||||
|
@@ -159,7 +159,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String uploadAvatar(MultipartFile avatarFile, Long id) {
|
||||
String avatarImageType = FileNameUtil.extName(avatarFile.getOriginalFilename());
|
||||
CheckUtils.throwIf(!StrUtil.equalsAnyIgnoreCase(avatarImageType, avatarSupportSuffix), "头像仅支持 {} 格式的图片", String
|
||||
@@ -290,7 +289,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateRole(UserRoleUpdateReq updateReq, Long id) {
|
||||
super.getById(id);
|
||||
// 保存用户和角色关联
|
||||
@@ -335,31 +333,7 @@ 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建 QueryWrapper
|
||||
*
|
||||
* @param query 查询条件
|
||||
* @return QueryWrapper
|
||||
*/
|
||||
private QueryWrapper<UserDO> buildQueryWrapper(UserQuery query) {
|
||||
protected QueryWrapper<UserDO> buildQueryWrapper(UserQuery query) {
|
||||
String description = query.getDescription();
|
||||
Integer status = query.getStatus();
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 名称是否存在
|
||||
*
|
||||
|
Reference in New Issue
Block a user