fix(工作台-工时、周报、日志管理):
- 修改工时周聚合逻辑,从仅统计周一到周五改为周一到周日 - 修复周末工时分配逻辑,周末工时不参与工作日均摊而是保留在周末 - 修复头像上传时旧头像删除逻辑,通过URL查找文件路径进行删除 - 添加加班工时统计功能,在团队工时周报表中显示批准的加班时间 - 优化未提交报告提醒功能,避免重复发送未读消息的提醒 - 修改周报告提醒的cron表达式,从每周五改为每周日执行
This commit is contained in:
@@ -563,8 +563,8 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
|
||||
url = client.upload(content, path, type);
|
||||
|
||||
//删除旧的
|
||||
client.delete(user.getAvatar());
|
||||
// 旧头像删除失败不应影响新头像上传;而且 avatar 字段存的是 URL,不能直接当 path 删。
|
||||
deleteOldAvatarQuietly(client, user);
|
||||
|
||||
// 3. 保存到数据库
|
||||
fileDO = new FileDO().setConfigId(client.getId())
|
||||
@@ -574,11 +574,31 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
user.setAvatar(fileDO.getUrl());
|
||||
this.userMapper.updateById(user);
|
||||
} catch (Exception e) {
|
||||
log.warn("头像上传失败,userId={}, avatar={}, fileName={}, contentType={}",
|
||||
user == null ? null : user.getId(),
|
||||
user == null ? null : user.getAvatar(),
|
||||
name, type, e);
|
||||
throw exception(USER_AVATAR_UPLOAD_FAILED);
|
||||
}
|
||||
return fileDO;
|
||||
}
|
||||
|
||||
private void deleteOldAvatarQuietly(FileClient client, AdminUserDO user) {
|
||||
if (client == null || user == null || StrUtil.isBlank(user.getAvatar())) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
FileDO oldAvatar = fileMapper.selectByUrl(user.getAvatar());
|
||||
if (oldAvatar == null || StrUtil.isBlank(oldAvatar.getPath())) {
|
||||
log.warn("删除旧头像时未找到文件记录,userId={}, avatar={}", user.getId(), user.getAvatar());
|
||||
return;
|
||||
}
|
||||
client.delete(oldAvatar.getPath());
|
||||
} catch (Exception ex) {
|
||||
log.warn("删除旧头像失败,userId={}, avatar={}", user.getId(), user.getAvatar(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateImageFile(MultipartFile file) {
|
||||
// 检查文件类型
|
||||
String contentType = file.getContentType();
|
||||
|
||||
Reference in New Issue
Block a user