manage : 素材库管理 添加删除和修改功能

dev_2.1.0
xueqingkun 1 year ago
parent aa1235d4a3
commit 78ed589020

@ -39,4 +39,21 @@ public class MaterialLibraryManageController {
}
@ApiOperation("删除文件目录")
@DeleteMapping("/deleteDirectory")
public boolean deleteMaterial(@ApiParam("素材id") @RequestParam("id") String id) throws Exception {
return materialLibraryManageService.deleteMaterial(id);
}
@ApiOperation("修改文件目录")
@PutMapping("/updateDirectory")
public boolean updateMaterial(@RequestBody MaterialLibrary materialLibrary) {
return materialLibraryManageService.updateMaterial(materialLibrary);
}
}

@ -18,8 +18,9 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.NotBlank;
import java.io.IOException;
import java.util.List;
@Api(tags = "病历管理")
@ -108,5 +109,17 @@ public class MedicalRecManageController {
}
@ApiOperation("导入疾病问题回答")
@PostMapping("/uploadMedicalAnswer")
public String uploadMaterial(@ApiParam("文件") @RequestParam("file") MultipartFile multipartFile,
@ApiParam("病例id") @RequestParam("medicalRecId") String medicalRecId) throws IOException {
return medicalRecManageService.uploadMaterial(multipartFile, medicalRecId);
}
// 下载疾病问题模板
}

@ -9,4 +9,6 @@ public interface FileManageService {
FileResource uploadFile(MultipartFile multipartFile, String contentType) throws Exception;
void downloadFile(String fileId, HttpServletResponse response) throws Exception;
boolean deleteFile(String fileId) throws Exception;
}

@ -17,4 +17,8 @@ public interface MaterialLibraryManageService {
String uploadMaterial(MultipartFile multipartFile, String materialName, String materialType) throws Exception;
IPage<MaterialLibrary> queryMaterialPage(String materialType, String materialName, Integer pageNum, Integer pageSize);
boolean deleteMaterial(String id) throws Exception;
boolean updateMaterial(MaterialLibrary materialLibrary);
}

@ -7,13 +7,16 @@ import com.supervision.model.FileResource;
import com.supervision.service.FileResourceService;
import com.supervision.util.MinioUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.Objects;
@Slf4j
@Service
@RequiredArgsConstructor
public class FileManageServiceImpl implements FileManageService {
@ -56,4 +59,20 @@ public class FileManageServiceImpl implements FileManageService {
outputStream.flush();
}
}
@Override
public boolean deleteFile(String fileId) throws Exception {
Assert.notEmpty(fileId, "文件id不能为空");
FileResource fileResource = fileResourceService.getById(fileId);
if (Objects.isNull(fileResource)){
log.info("deleteFile: fileId:{} 未找到数据",fileId);
return false;
}
if (StrUtil.isNotEmpty(fileResource.getMinioId())){
log.info("deleteFile:删除minio中的数据.minioId:{}",fileResource.getMinioId());
MinioUtil.deleteObject(fileResource.getMinioId());
}
return fileResourceService.removeById(fileId);
}
}

@ -15,6 +15,8 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.util.Objects;
@Service
@RequiredArgsConstructor
public class MaterialLibraryManageServiceImpl implements MaterialLibraryManageService {
@ -50,4 +52,30 @@ public class MaterialLibraryManageServiceImpl implements MaterialLibraryManageSe
return materialLibraryService.page(new Page<>(pageNum, pageSize),wrapper);
}
@Override
@Transactional
public boolean deleteMaterial(String id) throws Exception {
Assert.notEmpty(id, "id不能为空");
MaterialLibrary materialLibrary = materialLibraryService.getById(id);
if (Objects.isNull(materialLibrary)){
return false;
}
boolean removed = materialLibraryService.removeById(id);
if (removed){
removed = fileManageService.deleteFile(materialLibrary.getFileResourceId());
}
return removed;
}
@Override
public boolean updateMaterial(MaterialLibrary materialLibrary) {
Assert.notEmpty(materialLibrary.getId(), "id不能为空");
Assert.notEmpty(materialLibrary.getMaterialName(), "素材名不能为空");
return materialLibraryService.updateById(materialLibrary);
}
}

@ -5,7 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
@ -39,24 +40,28 @@ public class MaterialLibrary implements Serializable {
* ID
*/
@TableField(fill = FieldFill.INSERT)
@ApiModelProperty(hidden = true)
private String createUserId;
/**
*
*/
@TableField(fill = FieldFill.INSERT)
@ApiModelProperty(hidden = true)
private LocalDateTime createTime;
/**
*
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@ApiModelProperty(hidden = true)
private String updateUserId;
/**
*
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@ApiModelProperty(hidden = true)
private LocalDateTime updateTime;
@TableField(exist = false)

Loading…
Cancel
Save