Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop
This commit is contained in:
commit
ad2f822dca
|
|
@ -6,6 +6,7 @@ import cn.hutool.json.JSONUtil;
|
|||
import com.electromagnetic.industry.software.common.annotations.UserOperation;
|
||||
import com.electromagnetic.industry.software.common.cons.UserConstants;
|
||||
import com.electromagnetic.industry.software.common.enums.AdminTypeEnum;
|
||||
import com.electromagnetic.industry.software.common.pojo.AccessSuccessInfo;
|
||||
import com.electromagnetic.industry.software.common.pojo.UserLoginInfo;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.IdWorker;
|
||||
|
|
@ -26,6 +27,7 @@ import javax.annotation.Resource;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Component
|
||||
|
|
@ -134,7 +136,8 @@ public class LoginInterceptor implements HandlerInterceptor {
|
|||
String reqArgs = UserThreadLocal.getReqArgs();
|
||||
|
||||
UserLoginInfo user = Optional.of(UserThreadLocal.getUser()).orElse(new UserLoginInfo());
|
||||
|
||||
List<AccessSuccessInfo> successInfoList = user.getSuccessInfoList();
|
||||
for (AccessSuccessInfo accessSuccessInfo : successInfoList) {
|
||||
UserAccessLog userAccessLog = new UserAccessLog()
|
||||
.setId(IdWorker.getSnowFlakeIdString())
|
||||
.setUserId(user.getUserId())
|
||||
|
|
@ -149,9 +152,9 @@ public class LoginInterceptor implements HandlerInterceptor {
|
|||
.setAccessSuccess(true)
|
||||
.setCreateTime(new Date())
|
||||
.setOperationModule(userOperation.modelName().key)
|
||||
.setOperationMsg(UserThreadLocal.getUser().getSuccessMsg())
|
||||
.setDataId(user.getDataId())
|
||||
.setParentId(user.getParentId());
|
||||
.setOperationMsg(accessSuccessInfo.getSuccessMsg())
|
||||
.setDataId(accessSuccessInfo.getDataId())
|
||||
.setParentId(accessSuccessInfo.getParentId());
|
||||
|
||||
ElectromagneticResult<?> result = user.getResult();
|
||||
if (result != null) {
|
||||
|
|
@ -165,6 +168,8 @@ public class LoginInterceptor implements HandlerInterceptor {
|
|||
userAccessLog.setAccessSuccess(false);
|
||||
}
|
||||
userAccessLogMapper.insert(userAccessLog);
|
||||
}
|
||||
|
||||
UserThreadLocal.remove();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,20 +23,20 @@ public class FileRecycleController {
|
|||
private FileRecycleService fileRecycleService;
|
||||
|
||||
@RequestMapping("list")
|
||||
@UserOperation(value = "查看回收站", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
@UserOperation(value = "查看回收站", modelName = UserOperationModuleEnum.BACKUP_FILE)
|
||||
public ElectromagneticResult<?> list(@RequestBody RecycleFileQueryDTO pars) {
|
||||
return fileRecycleService.list(pars);
|
||||
}
|
||||
|
||||
@RequestMapping("remove")
|
||||
@UserOperation(value = "彻底清除文件", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
@UserOperation(value = "彻底清除文件", modelName = UserOperationModuleEnum.BACKUP_FILE)
|
||||
public ElectromagneticResult<?> remove(@RequestParam String fileId) {
|
||||
Assert.isTrue(UserThreadLocal.getAdminType().equals(AdminTypeEnum.SYSTEM.getValue()), "当前用户没有删除文件权限");
|
||||
return fileRecycleService.remove(fileId);
|
||||
}
|
||||
|
||||
@RequestMapping("recover")
|
||||
@UserOperation(value = "文件恢复", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
@UserOperation(value = "文件恢复", modelName = UserOperationModuleEnum.BACKUP_FILE)
|
||||
public ElectromagneticResult<?> recover(@RequestParam String fileId) {
|
||||
Assert.isTrue(UserThreadLocal.getAdminType().equals(AdminTypeEnum.SYSTEM.getValue()), "当前用户没有文件恢复权限");
|
||||
return fileRecycleService.recover(fileId);
|
||||
|
|
|
|||
|
|
@ -34,9 +34,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
|
|
@ -98,10 +96,12 @@ public class FileRecycleServiceImpl implements FileRecycleService {
|
|||
}
|
||||
|
||||
if (!UserThreadLocal.getAdminType().equals(AdminTypeEnum.SYSTEM.getValue())) {
|
||||
List<String> ids = edFileInfoMapper.selectList(Wrappers.<EdFileInfo>lambdaQuery().select(EdFileInfo::getId).eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_FILE.code))
|
||||
.stream()
|
||||
.map(EdFileInfo::getId)
|
||||
.collect(Collectors.toList());
|
||||
LambdaQueryWrapper<EdFileInfo> userPrjWrapper = Wrappers.<EdFileInfo>lambdaQuery().select(EdFileInfo::getId, EdFileInfo::getFileCode)
|
||||
.eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_FILE.code)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)
|
||||
.eq(EdFileInfo::getAllDeleted, true)
|
||||
.eq(EdFileInfo::getPermanentDeleted, false);
|
||||
List<String> ids = edFileInfoMapper.selectList(userPrjWrapper).stream().map(EdFileInfo::getFileCode).map(e -> e.substring(0, 6)).collect(Collectors.toList());
|
||||
List<String> accessibleTree = permissionService.getAccessibleTree();
|
||||
accessibleTree.addAll(ids);
|
||||
if (CollUtil.isNotEmpty(accessibleTree)) {
|
||||
|
|
@ -133,7 +133,7 @@ public class FileRecycleServiceImpl implements FileRecycleService {
|
|||
.set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)
|
||||
.set(EdFileInfo::getPermanentDeleted, true)
|
||||
.set(EdFileInfo::getAllDeleted, true));
|
||||
UserThreadLocal.setSuccessInfo("", "", "删除文件 {} 成功,文件id {}", edFileInfos.get(0).getFileName() + "." + edFileInfos.get(0).getFileType(), fileId);
|
||||
UserThreadLocal.setSuccessInfo(edFileInfo.getParentId(), edFileInfo.getId(), "删除文件 {} 成功,文件id {}", edFileInfos.get(0).getFileName() + "." + edFileInfos.get(0).getFileType(), fileId);
|
||||
BackupFileResLog resLog = backupHandler.deleteFile(edFileInfo.getId());
|
||||
if (!Optional.ofNullable(resLog).map(BackupFileResLog::getBackupSuccess).orElse(false)) {
|
||||
log.warn("删除备份文件异常");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package com.electromagnetic.industry.software.common.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AccessSuccessInfo {
|
||||
private String successMsg;
|
||||
private String dataId;
|
||||
private String parentId;
|
||||
}
|
||||
|
|
@ -3,6 +3,9 @@ package com.electromagnetic.industry.software.common.pojo;
|
|||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UserLoginInfo {
|
||||
|
||||
|
|
@ -54,10 +57,11 @@ public class UserLoginInfo {
|
|||
|
||||
private String dataId;
|
||||
|
||||
private List<AccessSuccessInfo> successInfoList = new ArrayList<>();
|
||||
|
||||
public void setSuccessInfo(String parentId, String successMsg, String dataId) {
|
||||
this.successMsg = successMsg;
|
||||
this.dataId = dataId;
|
||||
this.parentId = parentId;
|
||||
AccessSuccessInfo successInfo = new AccessSuccessInfo(dataId, parentId, successMsg);
|
||||
successInfoList.add(successInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue