fix(移动和复制): 同名文件或目录移动或复制报错问题修复
This commit is contained in:
parent
a184d2f392
commit
126e948b72
@ -19,6 +19,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -114,6 +115,11 @@ public class UserController {
|
||||
userLoginInfoService.save(userLoginInfo);
|
||||
UserBean user = userService.getById(sessionUserBean.getUserId());
|
||||
BeanUtil.copyProperties(user, userLoginVo);
|
||||
if (StringUtils.isEmpty(user.getWxOpenId())) {
|
||||
userLoginVo.setHasWxAuth(false);
|
||||
} else {
|
||||
userLoginVo.setHasWxAuth(true);
|
||||
}
|
||||
return RestResult.success().data(userLoginVo);
|
||||
|
||||
} else {
|
||||
@ -122,4 +128,25 @@ public class UserController {
|
||||
|
||||
}
|
||||
|
||||
@Operation(summary = "检查微信认证", description = "检查微信认证", tags = {"user"})
|
||||
@GetMapping("/checkWxAuth")
|
||||
@ResponseBody
|
||||
public RestResult<Boolean> checkWxAuth() {
|
||||
JwtUser sessionUserBean = SessionUtil.getSession();
|
||||
|
||||
if (sessionUserBean != null && !"anonymousUser".equals(sessionUserBean.getUsername())) {
|
||||
UserBean user = userService.getById(sessionUserBean.getUserId());
|
||||
|
||||
if (StringUtils.isEmpty(user.getWxOpenId())) {
|
||||
return RestResult.success().data(false);
|
||||
} else {
|
||||
return RestResult.success().data(true);
|
||||
}
|
||||
|
||||
} else {
|
||||
return RestResult.fail().message("用户暂未登录");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -78,6 +78,8 @@ public class UserBean {
|
||||
private String modifyTime;
|
||||
@Column(columnDefinition = "bigint(20) comment '修改用户id'")
|
||||
private Long modifyUserId;
|
||||
@Column(columnDefinition = "varchar(28) comment 'open id'")
|
||||
private String wxOpenId;
|
||||
|
||||
|
||||
}
|
||||
|
@ -94,13 +94,16 @@ public class UserFileService extends ServiceImpl<UserFileMapper, UserFile> imple
|
||||
String repeatFileName = fileDealComp.getRepeatFileName(userFile, userFile.getFilePath());
|
||||
userFile.setFileName(repeatFileName);
|
||||
}
|
||||
userFileMapper.updateById(userFile);
|
||||
|
||||
try {
|
||||
userFileMapper.updateById(userFile);
|
||||
} catch (Exception e) {
|
||||
log.warn(e.getMessage());
|
||||
}
|
||||
//移动子目录
|
||||
oldfilePath = new QiwenFile(oldfilePath, fileName, true).getPath();
|
||||
newfilePath = new QiwenFile(newfilePath, fileName, true).getPath();
|
||||
|
||||
if (userFile.isDirectory()) { //为空说明是目录,则需要移动子目录
|
||||
if (userFile.isDirectory()) { //如果是目录,则需要移动子目录
|
||||
List<UserFile> list = selectUserFileByLikeRightFilePath(oldfilePath, userId);
|
||||
|
||||
for (UserFile newUserFile : list) {
|
||||
@ -109,7 +112,11 @@ public class UserFileService extends ServiceImpl<UserFileMapper, UserFile> imple
|
||||
String repeatFileName = fileDealComp.getRepeatFileName(newUserFile, newUserFile.getFilePath());
|
||||
newUserFile.setFileName(repeatFileName);
|
||||
}
|
||||
userFileMapper.updateById(newUserFile);
|
||||
try {
|
||||
userFileMapper.updateById(newUserFile);
|
||||
} catch (Exception e) {
|
||||
log.warn(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,7 +134,11 @@ public class UserFileService extends ServiceImpl<UserFileMapper, UserFile> imple
|
||||
String repeatFileName = fileDealComp.getRepeatFileName(userFile, userFile.getFilePath());
|
||||
userFile.setFileName(repeatFileName);
|
||||
}
|
||||
userFileMapper.insert(userFile);
|
||||
try {
|
||||
userFileMapper.insert(userFile);
|
||||
} catch (Exception e) {
|
||||
log.warn(e.getMessage());
|
||||
}
|
||||
|
||||
oldfilePath = new QiwenFile(oldfilePath, fileName, true).getPath();
|
||||
newfilePath = new QiwenFile(newfilePath, fileName, true).getPath();
|
||||
@ -139,11 +150,15 @@ public class UserFileService extends ServiceImpl<UserFileMapper, UserFile> imple
|
||||
for (UserFile newUserFile : subUserFileList) {
|
||||
newUserFile.setFilePath(newUserFile.getFilePath().replaceFirst(oldfilePath, newfilePath));
|
||||
newUserFile.setUserFileId(IdUtil.getSnowflakeNextIdStr());
|
||||
if (!newUserFile.isFile()) {
|
||||
if (newUserFile.isDirectory()) {
|
||||
String repeatFileName = fileDealComp.getRepeatFileName(newUserFile, newUserFile.getFilePath());
|
||||
newUserFile.setFileName(repeatFileName);
|
||||
}
|
||||
userFileMapper.insert(newUserFile);
|
||||
try {
|
||||
userFileMapper.insert(newUserFile);
|
||||
} catch (Exception e) {
|
||||
log.warn(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,5 +47,7 @@ public class UserLoginVo {
|
||||
private String lastLoginTime;
|
||||
@Schema(description = "Token 接口访问凭证")
|
||||
private String token;
|
||||
@Schema(description = "是否微信认证")
|
||||
private boolean hasWxAuth;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user