删除模块

This commit is contained in:
筱锋xiao_lfeng 2023-08-18 16:40:48 +08:00
parent 94e07f2848
commit d7a01756bf
3 changed files with 10 additions and 4 deletions

View File

@ -5,7 +5,7 @@ import com.wxjw.common.ResultUtil;
import com.wxjw.dal.dao.ExcelInfoMapper;
import com.wxjw.dal.pojo.ErrorCode;
import com.wxjw.dal.pojo.data.DeleteFile.DeleteFileData;
import com.wxjw.dal.pojo.entity.ExcelInfoEntity;
import com.wxjw.service.DeleteFileService;
import jakarta.annotation.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
@ -28,7 +28,9 @@ public class DeleteFileController {
@PostMapping("/file")
public ResponseEntity<BaseResponse<Object>> deleteFile(@RequestBody DeleteFileData requestBody) {
if ("deletefile".equals(requestBody.getAction())) {
return d;
DeleteFileService deleteFileService = new DeleteFileService(excelInfoMapper);
deleteFileService.deleteFile(requestBody);
return deleteFileService.getReturnResult();
} else {
return ResultUtil.error(ErrorCode.PARAMETER_ERROR);
}

View File

@ -15,6 +15,7 @@ public enum ErrorCode {
PARAMETER_ERROR("ParameterError", 40011, "参数错误", HttpCode.BAD_REQUEST),
DATA_DUPLICATION("DataDuplication", 40012, "数据重复", HttpCode.BAD_REQUEST),
DATA_WRITE_FAILURE("DataWriteFailure", 40013, "数据写入失败", HttpCode.BAD_REQUEST),
DATA_DELETE_FAILURE("DataDeleteFailure", 40014, "数据删除失败", HttpCode.BAD_REQUEST),
FILE_TYPE_IS_INCORRECT("FileTypeIncorrect", 40014, "文件类型错误", HttpCode.BAD_REQUEST),
FILE_CREATION_FAILED("FileCreationFailed", 40015, "文件创建失败", HttpCode.BAD_REQUEST),
FILE_ALREADY_EXISTS("FileAlreadyExists", 40016, "文件已经存在", HttpCode.BAD_REQUEST),

View File

@ -31,8 +31,11 @@ public class DeleteFileService {
ExcelInfoEntity excelInfo = excelInfoMapper.getExcelForId(requestBody.getNodeId());
if (excelInfo != null && excelInfo.getId() != null) {
// 查找到数据执行删除
excelInfoMapper.deleteExcelForId(excelInfo.getId());
returnResult = ResultUtil.success("删除成功");
if (excelInfoMapper.deleteExcelForId(excelInfo.getId())) {
returnResult = ResultUtil.success("删除成功");
} else {
returnResult = ResultUtil.error(ErrorCode.DATA_DELETE_FAILURE);
}
} else {
returnResult = ResultUtil.error(ErrorCode.DATA_IS_EMPTY);
}