zbj//1.资源管理 修改

This commit is contained in:
zhangbaojian
2023-04-20 11:35:38 +08:00
parent 4b3ff6e3ff
commit a844123e43
4 changed files with 63 additions and 37 deletions

View File

@@ -45,10 +45,10 @@ public class ResourceAdministrationController extends BaseController {
public HttpResult<Boolean> uploadFile(@ApiParam(value = "文件", required = true) @RequestPart("multipartFile") MultipartFile multipartFile,
@ApiParam(value = "资源名称", required = true) String name,
@ApiParam(value = "资源类型", required = true) String type,
@ApiParam(value = "资源描述", required = false) String describe,
@ApiParam(value = "系统类型Guid", required = true) String systemType) {
@ApiParam(value = "资源描述", required = true) String description,
@ApiParam(value = "系统类型Guid", required = false) String systemType) {
String methodDescribe = getMethodDescribe("uploadFile");
Boolean flag = iResourceAdministrationService.uploadFile(multipartFile, name, type, describe, systemType);
Boolean flag = iResourceAdministrationService.uploadFile(multipartFile, name, type, description, systemType);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
}
@@ -58,10 +58,10 @@ public class ResourceAdministrationController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryData")
@ApiOperation("查询数据")
@ApiImplicitParam(name = "baseParam", value = "查询数据", required = true)
public HttpResult<List<Resinformation>> queryData(@RequestBody @Validated BaseParam baseParam) {
@ApiImplicitParam(name = "resinformation", value = "查询数据", required = true)
public HttpResult<List<Resinformation>> queryData(@RequestBody Resinformation resinformation) {
String methodDescribe = getMethodDescribe("queryData");
List<Resinformation> result = iResourceAdministrationService.queryData(baseParam);
List<Resinformation> result = iResourceAdministrationService.queryData(resinformation);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@@ -71,14 +71,14 @@ public class ResourceAdministrationController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/updateFile")
@ApiOperation("修改资源")
public HttpResult<Boolean> updateFile(@ApiParam(value = "文件", required = true) @RequestPart("multipartFile") MultipartFile multipartFile,
public HttpResult<Boolean> updateFile(@ApiParam(value = "文件", required = false) MultipartFile multipartFile,
@ApiParam(value = "id", required = true) String id,
@ApiParam(value = "资源名称", required = true) String name,
@ApiParam(value = "资源类型", required = true) String type,
@ApiParam(value = "资源描述", required = false) String describe,
@ApiParam(value = "系统类型Guid", required = true) String systemType) {
@ApiParam(value = "资源描述", required = true) String description,
@ApiParam(value = "系统类型Guid", required = false) String systemType) {
String methodDescribe = getMethodDescribe("updateFile");
Boolean flag = iResourceAdministrationService.updateFile(multipartFile, id, name, type, describe, systemType);
Boolean flag = iResourceAdministrationService.updateFile(multipartFile, id, name, type, description, systemType);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
}

View File

@@ -18,11 +18,11 @@ import java.util.List;
*/
public interface IResourceAdministrationService extends IService<Resinformation> {
Boolean uploadFile(MultipartFile multipartFile, String name, String type, String describe, String systemType);
Boolean uploadFile(MultipartFile multipartFile, String name, String type, String description, String systemType);
List<Resinformation> queryData(BaseParam baseParam);
List<Resinformation> queryData(Resinformation resinformation);
Boolean updateFile(MultipartFile multipartFile, String id, String name, String type, String describe, String systemType);
Boolean updateFile(MultipartFile multipartFile, String id, String name, String type, String description, String systemType);
Boolean deleteFile(String id);

View File

@@ -45,15 +45,13 @@ public class ResourceAdministrationServiceImpl extends ServiceImpl<ResourceAdmin
//private final GeneralInfo generalInfo;
@Override
public Boolean uploadFile(MultipartFile multipartFile, String name, String type, String describe, String systemType) {
public Boolean uploadFile(MultipartFile multipartFile, String name, String type, String description, String systemType) {
//通过封装好的文件工具类来传入文件和文件夹名称来获取文件路径
String url = fileStorageUtil.uploadMultipart(multipartFile, OssPath.RESOURCEADMINISTRATION);
//创建对象
Resinformation resinformation = new Resinformation();
resinformation.setName(name);
if (StringUtils.isNotBlank(describe)) {
resinformation.setDescription(describe);
}
resinformation.setDescription(description);
resinformation.setUrl(url);
//获取用户id
String userIndex = RequestUtil.getUserIndex();
@@ -61,41 +59,64 @@ public class ResourceAdministrationServiceImpl extends ServiceImpl<ResourceAdmin
resinformation.setUpdateUser(userIndex);
resinformation.setUpdateTime(LocalDateTime.now());
resinformation.setState(1);
resinformation.setSystemType(systemType);
resinformation.setFileName(multipartFile.getOriginalFilename());
if (StringUtils.isNotBlank(systemType)) {
resinformation.setSystemType(systemType);
}
resinformation.setType(type);
return this.save(resinformation);
}
@Override
public List<Resinformation> queryData(BaseParam baseParam) {
if (!StringUtils.isBlank(baseParam.getSearchValue())) {
public List<Resinformation> queryData(Resinformation resinformation) {
if (StringUtils.isNotBlank(resinformation.getType()) && StringUtils.isNotBlank(resinformation.getSystemType())) {
LambdaQueryWrapper<Resinformation> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Resinformation::getType, baseParam.getSearchValue());
return resourceAdministrationMapper.selectPage(new Page<>(baseParam.getPageNum(), baseParam.getPageSize()), wrapper).getRecords();
//type
wrapper.eq(Resinformation::getType, resinformation.getType());
//sysType
wrapper.eq(Resinformation::getSystemType, resinformation.getSystemType());
return resourceAdministrationMapper.selectList(wrapper);
} else if (StringUtils.isBlank(resinformation.getType()) && StringUtils.isBlank(resinformation.getSystemType())) {
return this.list();
} else if (StringUtils.isNotBlank(resinformation.getType()) && StringUtils.isBlank(resinformation.getSystemType())) {
LambdaQueryWrapper<Resinformation> wrapper = new LambdaQueryWrapper<>();
//type
wrapper.eq(Resinformation::getType, resinformation.getType());
return resourceAdministrationMapper.selectList(wrapper);
} else {
return this.page(new Page<>(baseParam.getPageNum(), baseParam.getPageSize())).getRecords();
LambdaQueryWrapper<Resinformation> wrapper = new LambdaQueryWrapper<>();
//sysType
wrapper.eq(Resinformation::getSystemType, resinformation.getSystemType());
return resourceAdministrationMapper.selectList(wrapper);
}
}
@Override
public Boolean updateFile(MultipartFile multipartFile, String id, String name, String type, String describe, String systemType) {
public Boolean updateFile(MultipartFile multipartFile, String id, String name, String type, String description, String systemType) {
Resinformation resinformation = resourceAdministrationMapper.selectById(id);
//删除文件
fileStorageUtil.deleteFile(resinformation.getUrl());
//获取路径
String url = fileStorageUtil.uploadMultipart(multipartFile, OssPath.RESOURCEADMINISTRATION);
resinformation.setUrl(url);
resinformation.setName(name);
if (StringUtils.isNotBlank(describe)) {
resinformation.setDescription(describe);
if (null != multipartFile && !multipartFile.isEmpty()) {
//删除文件
fileStorageUtil.deleteFile(resinformation.getUrl());
//获取路径
String url = fileStorageUtil.uploadMultipart(multipartFile, OssPath.RESOURCEADMINISTRATION);
resinformation.setUrl(url);
resinformation.setFileName(multipartFile.getOriginalFilename());
}
resinformation.setName(name);
resinformation.setDescription(description);
//获取用户id
//String userIndex = RequestUtil.getUserIndex();
String userIndex = "123456";
String userIndex = RequestUtil.getUserIndex();
//String userIndex = "123456";
resinformation.setUpdateUser(userIndex);
resinformation.setUpdateTime(LocalDateTime.now());
resinformation.setState(1);
resinformation.setSystemType(systemType);
if (StringUtils.isNotBlank(systemType)) {
resinformation.setSystemType(systemType);
}
resinformation.setType(type);
int i = resourceAdministrationMapper.updateById(resinformation);
return i > 0;
@@ -112,10 +133,10 @@ public class ResourceAdministrationServiceImpl extends ServiceImpl<ResourceAdmin
}
@Override
public void downloadFile(String id,HttpServletResponse response) throws IOException {
public void downloadFile(String id, HttpServletResponse response) throws IOException {
Resinformation resinformation = resourceAdministrationMapper.selectById(id);
//下载文件
fileStorageUtil.downloadStream(response,resinformation.getUrl());
fileStorageUtil.downloadStream(response, resinformation.getUrl());
}
@Override