Compare commits

...

6 Commits

7 changed files with 49 additions and 23 deletions

View File

@ -34,7 +34,7 @@ public interface EDDataService {
* @param edDataInfo
* @return
*/
Boolean createDataInfo(EDDataInfo edDataInfo) throws FileNotFoundException;
Boolean createDataInfo(EDDataInfo edDataInfo) throws Exception;
/**
* 获取文件信息列表
@ -55,7 +55,7 @@ public interface EDDataService {
* @param parames
* @return
*/
Boolean updateFileInfo(EDDataParams parames) throws FileNotFoundException;
Boolean updateFileInfo(EDDataParams parames) throws Exception;
/**
* 获取子文件数量
@ -69,7 +69,7 @@ public interface EDDataService {
* @param parames
* @return
*/
Boolean uploadFile(EDDataParams parames) throws FileNotFoundException;
Boolean uploadFile(EDDataParams parames) throws Exception;
/**
* 文件下载

View File

@ -145,14 +145,14 @@ public class EDDataServiceImpl implements EDDataService {
* @param edDataInfo
* @return
*/
public Boolean createDataInfo(EDDataInfo edDataInfo) throws FileNotFoundException
public Boolean createDataInfo(EDDataInfo edDataInfo) throws Exception
{
// 获取上级目录的名称
Category categoryParent = new Category();
categoryParent.setCategoryId(edDataInfo.getCategoryId());
List<Category> categoryParentList = categoryRepository.selectCategories(categoryParent);
if(categoryParentList.size() < 1) {
throw new FileNotFoundException("上级文件夹不存在");
throw new Exception("上级文件夹不存在");
}
else
{
@ -170,7 +170,7 @@ public class EDDataServiceImpl implements EDDataService {
for(EDDataInfo fileInfo : childFileInfoList)
{
if(fileInfo.getDataName().equals(edDataInfo.getDataName())){
throw new FileNotFoundException("文件夹已存在");
throw new Exception("文件夹已存在");
}
}
@ -216,19 +216,19 @@ public class EDDataServiceImpl implements EDDataService {
* @param parames
* @return
*/
public Boolean updateFileInfo(EDDataParams parames) throws FileNotFoundException
public Boolean updateFileInfo(EDDataParams parames) throws Exception
{
String dataStoragePath = getDataStoragePath();
if (!FileUtil.exist(dataStoragePath)){
throw new FileNotFoundException("数据存储文件夹不存在");
throw new Exception("数据存储文件夹不存在");
}
EDDataParams paramesFind = new EDDataParams();
paramesFind.setDataId(parames.getDataId());
List<EDDataInfo> edDataInfoList = edDataRepository.getDataInfoList(paramesFind);
if(edDataInfoList.size() < 1) {
throw new FileNotFoundException("文件信息不存在");
throw new Exception("文件信息不存在");
}
EDDataInfo edDataInfo = edDataInfoList.get(0);
@ -236,7 +236,7 @@ public class EDDataServiceImpl implements EDDataService {
String fileStorageFullPath = dataStoragePath + filePathOfFolder + File.separator + edDataInfo.getDataName();
if (!FileUtil.exist(fileStorageFullPath)){
throw new FileNotFoundException("文件不存在");
throw new Exception("文件不存在");
}
String fileNameNew = parames.getName();
@ -288,7 +288,7 @@ public class EDDataServiceImpl implements EDDataService {
* @param parames
* @return
*/
public Boolean uploadFile(EDDataParams parames) throws FileNotFoundException
public Boolean uploadFile(EDDataParams parames) throws Exception
{
// 获取目录编码ID
@ -299,7 +299,7 @@ public class EDDataServiceImpl implements EDDataService {
// 检查文件是否为空
if (fileInput == null || fileInput.isEmpty()) {
throw new FileNotFoundException("上传的文件为空");
throw new Exception("上传的文件为空");
}
// 获取文件名
@ -320,7 +320,7 @@ public class EDDataServiceImpl implements EDDataService {
for(EDDataInfo fileInfo : childFileInfoList)
{
if(fileInfo.getDataName().equals(fileFullName)){
throw new FileNotFoundException("上传的文件已存在");
throw new Exception("上传的文件已存在");
}
}
@ -413,7 +413,7 @@ public class EDDataServiceImpl implements EDDataService {
fileParames.setSaveStatus("failure");
edDataRepository.updateFileInfo(fileParames);
log.info("文件保存失败: " + fileSaveFullPath);
throw new FileNotFoundException(e.getMessage());
throw new Exception(e.getMessage());
}
}
@ -575,7 +575,7 @@ public class EDDataServiceImpl implements EDDataService {
log.error("文件加密错误..", e);
}
log.info("目录树数据+文件数据已成功复制到目标目录。" + zipPathFileName);
log.info("目录树数据+文件数据已成功复制到目标目录。" + enCodeZipPathFileName);
}
catch (Exception e) {
log.error("导出数据异常..", e);

View File

@ -8,6 +8,7 @@ import com.electromagnetic.industry.software.data.manage.domain.boardservice.use
import com.electromagnetic.industry.software.data.manage.domain.boardservice.user.params.UserDeleteKeyWords;
import com.electromagnetic.industry.software.data.manage.domain.boardservice.user.repository.UserRepository;
import com.electromagnetic.industry.software.data.manage.domain.boardservice.user.service.UserService;
import electromagnetic.data.framework.share.constants.UserConstants;
import electromagnetic.data.framework.share.exception.LoggerConstant;
import electromagnetic.data.framework.share.util.SignUtils;
import org.slf4j.Logger;
@ -112,6 +113,11 @@ public class UserServiceImpl implements UserService {
*/
@Override
public Boolean deleteUser(UserDeleteKeyWords userDeleteKeyWords) {
String workNumber = userRepository.getSingleUser(userDeleteKeyWords.getUserId()).getWorkNumber();
if (UserConstants.ADMIN_WORK_NUMBER.equals(workNumber)) {
throw new RuntimeException("管理员用户无法删除");
}
return userRepository.deleteUser(userDeleteKeyWords)>0;
}

View File

@ -80,6 +80,10 @@
<artifactId>zip4j</artifactId>
<version>2.11.5</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -28,4 +28,9 @@ public class UserConstants {
public static final String LOGIN_USER_NAME = "userName";
public static final String LOGIN_WORK_NUMBER = "workNumber";
public static final String LOGIN_USER_ID = "userId";
/**
* 管理员账号
*/
public static final String ADMIN_WORK_NUMBER = "100000";
}

View File

@ -104,6 +104,12 @@
<if test="effectFlag != null and effectFlag!=''">
effect_flag = #{effectFlag,jdbcType=VARCHAR},
</if>
<if test="userId != null and userId!=''">
modifier = #{userId,jdbcType=VARCHAR},
</if>
<if test="userName != null and userName!=''">
modifier_name = #{userName,jdbcType=VARCHAR},
</if>
gmt_modified = now()
</set>
<where>

View File

@ -20,6 +20,7 @@ import com.electromagnetic.industry.software.data.manage.service.mappers.EDDataM
import electromagnetic.data.framework.share.id.IdWorker;
import electromagnetic.data.framework.share.model.ElectromagneticResult;
import electromagnetic.data.framework.share.model.ElectromagneticResultUtil;
import electromagnetic.data.framework.share.util.UserThreadLocal;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
@ -73,10 +74,10 @@ public class EDDataFacadeImpl implements EDDataFacade {
public ElectromagneticResult<Boolean> createFolder(EDDataRequest request) {
EDDataInfo edDataInfo = EDDataMappers.INSTANCE.getEDDataInfo(request);
edDataInfo.setCreator(request.getUserId());
edDataInfo.setCreatorName(request.getUserName());
edDataInfo.setModifier(request.getUserId());
edDataInfo.setModifierName(request.getUserName());
edDataInfo.setCreator(UserThreadLocal.getUserId());
edDataInfo.setCreatorName(UserThreadLocal.getUsername());
edDataInfo.setModifier(UserThreadLocal.getUserId());
edDataInfo.setModifierName(UserThreadLocal.getUsername());
edDataInfo.setCategoryId(request.getParentId());
edDataInfo.setDataName(request.getName());
edDataInfo.setNote(request.getNote());
@ -91,7 +92,7 @@ public class EDDataFacadeImpl implements EDDataFacade {
try {
return ElectromagneticResultUtil.success(edDataService.createDataInfo(edDataInfo));
} catch (FileNotFoundException e) {
} catch (Exception e) {
log.error("创建文件夹失败。。。", e);
return ElectromagneticResultUtil.fail("500", e.getMessage());
}
@ -127,9 +128,11 @@ public class EDDataFacadeImpl implements EDDataFacade {
public ElectromagneticResult<Boolean> updateFileInfo(EDDataRequest request)
{
try {
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
EDDataParams parames = EDDataMappers.INSTANCE.getEDDataParames(request);
parames.setUserId(UserThreadLocal.getUserId());
parames.setUserName(UserThreadLocal.getUsername());
return ElectromagneticResultUtil.success(edDataService.updateFileInfo(parames));
} catch (FileNotFoundException e) {
} catch (Exception e) {
log.error("文件信息更新失败。。。", e);
return ElectromagneticResultUtil.fail("500", e.getMessage());
}
@ -162,8 +165,10 @@ public class EDDataFacadeImpl implements EDDataFacade {
{
try {
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
parames.setUserId(UserThreadLocal.getUserId());
parames.setUserName(UserThreadLocal.getUsername());
return ElectromagneticResultUtil.success(edDataService.uploadFile(parames));
} catch (FileNotFoundException e) {
} catch (Exception e) {
log.error("上传文件失败。。。", e);
return ElectromagneticResultUtil.fail("500", e.getMessage());
}