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.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@ -114,6 +115,11 @@ public class UserController {
|
|||||||
userLoginInfoService.save(userLoginInfo);
|
userLoginInfoService.save(userLoginInfo);
|
||||||
UserBean user = userService.getById(sessionUserBean.getUserId());
|
UserBean user = userService.getById(sessionUserBean.getUserId());
|
||||||
BeanUtil.copyProperties(user, userLoginVo);
|
BeanUtil.copyProperties(user, userLoginVo);
|
||||||
|
if (StringUtils.isEmpty(user.getWxOpenId())) {
|
||||||
|
userLoginVo.setHasWxAuth(false);
|
||||||
|
} else {
|
||||||
|
userLoginVo.setHasWxAuth(true);
|
||||||
|
}
|
||||||
return RestResult.success().data(userLoginVo);
|
return RestResult.success().data(userLoginVo);
|
||||||
|
|
||||||
} else {
|
} 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;
|
private String modifyTime;
|
||||||
@Column(columnDefinition = "bigint(20) comment '修改用户id'")
|
@Column(columnDefinition = "bigint(20) comment '修改用户id'")
|
||||||
private Long modifyUserId;
|
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());
|
String repeatFileName = fileDealComp.getRepeatFileName(userFile, userFile.getFilePath());
|
||||||
userFile.setFileName(repeatFileName);
|
userFile.setFileName(repeatFileName);
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
userFileMapper.updateById(userFile);
|
userFileMapper.updateById(userFile);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn(e.getMessage());
|
||||||
|
}
|
||||||
//移动子目录
|
//移动子目录
|
||||||
oldfilePath = new QiwenFile(oldfilePath, fileName, true).getPath();
|
oldfilePath = new QiwenFile(oldfilePath, fileName, true).getPath();
|
||||||
newfilePath = new QiwenFile(newfilePath, fileName, true).getPath();
|
newfilePath = new QiwenFile(newfilePath, fileName, true).getPath();
|
||||||
|
|
||||||
if (userFile.isDirectory()) { //为空说明是目录,则需要移动子目录
|
if (userFile.isDirectory()) { //如果是目录,则需要移动子目录
|
||||||
List<UserFile> list = selectUserFileByLikeRightFilePath(oldfilePath, userId);
|
List<UserFile> list = selectUserFileByLikeRightFilePath(oldfilePath, userId);
|
||||||
|
|
||||||
for (UserFile newUserFile : list) {
|
for (UserFile newUserFile : list) {
|
||||||
@ -109,7 +112,11 @@ public class UserFileService extends ServiceImpl<UserFileMapper, UserFile> imple
|
|||||||
String repeatFileName = fileDealComp.getRepeatFileName(newUserFile, newUserFile.getFilePath());
|
String repeatFileName = fileDealComp.getRepeatFileName(newUserFile, newUserFile.getFilePath());
|
||||||
newUserFile.setFileName(repeatFileName);
|
newUserFile.setFileName(repeatFileName);
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
userFileMapper.updateById(newUserFile);
|
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());
|
String repeatFileName = fileDealComp.getRepeatFileName(userFile, userFile.getFilePath());
|
||||||
userFile.setFileName(repeatFileName);
|
userFile.setFileName(repeatFileName);
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
userFileMapper.insert(userFile);
|
userFileMapper.insert(userFile);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
oldfilePath = new QiwenFile(oldfilePath, fileName, true).getPath();
|
oldfilePath = new QiwenFile(oldfilePath, fileName, true).getPath();
|
||||||
newfilePath = new QiwenFile(newfilePath, 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) {
|
for (UserFile newUserFile : subUserFileList) {
|
||||||
newUserFile.setFilePath(newUserFile.getFilePath().replaceFirst(oldfilePath, newfilePath));
|
newUserFile.setFilePath(newUserFile.getFilePath().replaceFirst(oldfilePath, newfilePath));
|
||||||
newUserFile.setUserFileId(IdUtil.getSnowflakeNextIdStr());
|
newUserFile.setUserFileId(IdUtil.getSnowflakeNextIdStr());
|
||||||
if (!newUserFile.isFile()) {
|
if (newUserFile.isDirectory()) {
|
||||||
String repeatFileName = fileDealComp.getRepeatFileName(newUserFile, newUserFile.getFilePath());
|
String repeatFileName = fileDealComp.getRepeatFileName(newUserFile, newUserFile.getFilePath());
|
||||||
newUserFile.setFileName(repeatFileName);
|
newUserFile.setFileName(repeatFileName);
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
userFileMapper.insert(newUserFile);
|
userFileMapper.insert(newUserFile);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,5 +47,7 @@ public class UserLoginVo {
|
|||||||
private String lastLoginTime;
|
private String lastLoginTime;
|
||||||
@Schema(description = "Token 接口访问凭证")
|
@Schema(description = "Token 接口访问凭证")
|
||||||
private String token;
|
private String token;
|
||||||
|
@Schema(description = "是否微信认证")
|
||||||
|
private boolean hasWxAuth;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user