|
|
|
@ -3,7 +3,6 @@ package cn.estsh.i3plus.core.apiservice.controller.busi;
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysDictionaryService;
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysFileService;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.StringTool;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.util.PlatformConstWords;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.BaseConstWords;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
|
|
|
@ -26,7 +25,6 @@ import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.BufferedInputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
@ -63,6 +61,7 @@ public class SysFileController extends CoreBaseController{
|
|
|
|
|
// 条件验证
|
|
|
|
|
ValidatorBean.beginValid(sysFile)
|
|
|
|
|
.notNull("id", sysFile.getId())
|
|
|
|
|
.notNull("fileSoftType", sysFile.getFileSoftType())
|
|
|
|
|
.notNull("name", sysFile.getName());
|
|
|
|
|
|
|
|
|
|
sysFileService.updateSysFile(sysFile);
|
|
|
|
@ -76,9 +75,17 @@ public class SysFileController extends CoreBaseController{
|
|
|
|
|
|
|
|
|
|
@DeleteMapping(value = "/delete/{id}")
|
|
|
|
|
@ApiOperation(value = "根据id删除文件资源", notes = "根据id删除文件资源")
|
|
|
|
|
public ResultBean deleteSysFileById(@PathVariable("id") String id){
|
|
|
|
|
public ResultBean deleteSysFileById(@PathVariable("id") String idStr){
|
|
|
|
|
try {
|
|
|
|
|
sysFileService.deleteSysFileById(Long.parseLong(id));
|
|
|
|
|
ValidatorBean.checkNotNull(idStr, "id不能为空");
|
|
|
|
|
SysFile sysFile = sysFileService.getSysFileById(Long.parseLong(idStr));
|
|
|
|
|
ValidatorBean.checkNotNull(sysFile, "文件信息不存在");
|
|
|
|
|
|
|
|
|
|
LOGGER.info("FastDFS删除文件 == groupName: {},name:{}", sysFile.getDfsGroupName(), sysFile.getDfsFileName());
|
|
|
|
|
dfsClient.deleteFile(sysFile.getDfsGroupName(), sysFile.getDfsFileName());
|
|
|
|
|
|
|
|
|
|
sysFileService.deleteSysFileById(Long.parseLong(idStr));
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
}catch(ImppBusiException busExcep){
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
@ -109,6 +116,8 @@ public class SysFileController extends CoreBaseController{
|
|
|
|
|
ValidatorBean.checkIsNumber(id, "id必须为数字");
|
|
|
|
|
|
|
|
|
|
SysFile sysFile = sysFileService.getSysFileById(Long.parseLong(id));
|
|
|
|
|
ValidatorBean.checkNotNull(sysFile, "文件信息不存在");
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("操作成功")
|
|
|
|
|
.setResultObject(sysFile)
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
@ -255,6 +264,7 @@ public class SysFileController extends CoreBaseController{
|
|
|
|
|
ValidatorBean.beginValid(sysFile)
|
|
|
|
|
.notNull("dfsFileName", sysFile.getDfsFileName())
|
|
|
|
|
.notNull("dfsGroupName", sysFile.getDfsGroupName())
|
|
|
|
|
.notNull("fileSoftType", sysFile.getFileSoftType())
|
|
|
|
|
.notNull("fileOriginalName", sysFile.getFileOriginalName());
|
|
|
|
|
|
|
|
|
|
// 文件类型验证
|
|
|
|
@ -282,4 +292,25 @@ public class SysFileController extends CoreBaseController{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据文件代码查询文件信息
|
|
|
|
|
* @param fileCode 文件代码
|
|
|
|
|
* @return 处理结果
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/get-file-code/{code}")
|
|
|
|
|
@ApiOperation(value = "根据文件代码查询文件信息")
|
|
|
|
|
public ResultBean getSysFileByFileCode(@PathVariable("code") String fileCode) {
|
|
|
|
|
try {
|
|
|
|
|
// 条件验证
|
|
|
|
|
ValidatorBean.checkNotNull(fileCode, "文件代码不能为空");
|
|
|
|
|
SysFile sysFile = sysFileService.getSysFileByFileCode(fileCode);
|
|
|
|
|
ValidatorBean.checkNotNull(sysFile, "文件信息不存在");
|
|
|
|
|
|
|
|
|
|
return ResultBean.success().setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultObject(sysFile);
|
|
|
|
|
}catch(ImppBusiException busExcep){
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|