|
@@ -4,8 +4,11 @@ import cn.dev33.satoken.stp.StpUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
+import com.fdkankan.manage.common.OssPath;
|
|
|
import com.fdkankan.manage.common.PageInfo;
|
|
|
import com.fdkankan.manage.common.ResultCode;
|
|
|
+import com.fdkankan.manage.config.ManageConfig;
|
|
|
import com.fdkankan.manage.constant.FileTypeEnum;
|
|
|
import com.fdkankan.manage.entity.CommonUpload;
|
|
|
import com.fdkankan.manage.entity.Dict;
|
|
@@ -17,15 +20,19 @@ import com.fdkankan.manage.service.IDictFileService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fdkankan.manage.service.IDictService;
|
|
|
import com.fdkankan.manage.vo.request.DictFileParam;
|
|
|
+import com.fdkankan.manage.vo.request.addMediaLibraryParam;
|
|
|
import com.fdkankan.manage.vo.response.DictFileVo;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.UUID;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -37,6 +44,7 @@ import java.util.stream.Collectors;
|
|
|
* @since 2024-12-02
|
|
|
*/
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class DictFileServiceImpl extends ServiceImpl<IDictFileMapper, DictFile> implements IDictFileService {
|
|
|
|
|
|
@Autowired
|
|
@@ -97,4 +105,71 @@ public class DictFileServiceImpl extends ServiceImpl<IDictFileMapper, DictFile>
|
|
|
}
|
|
|
return list.get(0);
|
|
|
}
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FYunFileServiceInterface fYunFileServiceInterface;
|
|
|
+ @Autowired
|
|
|
+ ManageConfig manageConfig;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void checkMediaLibrary(addMediaLibraryParam param) {
|
|
|
+ if(StringUtils.isBlank(param.getFilePath())){
|
|
|
+ throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+
|
|
|
+ String extName = param.getFilePath().substring(param.getFilePath().lastIndexOf(".")).toLowerCase();
|
|
|
+
|
|
|
+ FileTypeEnum fileTypeEnum = FileTypeEnum.getByType(extName.replace(".", ""));
|
|
|
+ if(fileTypeEnum == null){
|
|
|
+ throw new BusinessException(ResultCode.FILE_TYPE_ERROR2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addMediaLibrary(addMediaLibraryParam param) {
|
|
|
+
|
|
|
+ if(StringUtils.isBlank(param.getFilePath())){
|
|
|
+ throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+
|
|
|
+ String uuid = UUID.randomUUID().toString().replace("-","");
|
|
|
+ String extName = param.getFilePath().substring(param.getFilePath().lastIndexOf(".")).toLowerCase();
|
|
|
+
|
|
|
+ FileTypeEnum fileTypeEnum = FileTypeEnum.getByType(extName.replace(".", ""));
|
|
|
+ if(fileTypeEnum == null){
|
|
|
+ throw new BusinessException(ResultCode.FILE_TYPE_ERROR2);
|
|
|
+ }
|
|
|
+
|
|
|
+ String ossPath = String.format(OssPath.MANAGE_MODEL_FILE_PATH, uuid+ extName);
|
|
|
+ fYunFileServiceInterface.copyFileInBucket(param.getFilePath(),ossPath);
|
|
|
+ try {
|
|
|
+ if(param.getDelSource() == 1){
|
|
|
+ fYunFileServiceInterface.deleteFile(param.getFilePath());
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.info("删除原文件失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ CommonUpload commonUpload = new CommonUpload();
|
|
|
+ commonUpload.setFileName(param.getFileName());
|
|
|
+ commonUpload.setFileUrl(manageConfig.getQueryPath() + ossPath);
|
|
|
+ commonUpload.setFileSize(param.getFileSize());
|
|
|
+ commonUpload.setFileType(fileTypeEnum.getCode());
|
|
|
+ commonUpload.setFileTypeStr(fileTypeEnum.getMsg());
|
|
|
+ commonUpload.setFileFormat(extName);
|
|
|
+ commonUpload.setResultFileFormat(extName);
|
|
|
+ commonUpload.setStatus(1);
|
|
|
+ commonUpload.setUseType("trace_evidence");
|
|
|
+ commonUploadService.saveOrUpdate(commonUpload);
|
|
|
+
|
|
|
+ DictFile dictFile = new DictFile();
|
|
|
+ dictFile.setName(param.getFileName());
|
|
|
+ dictFile.setTypeKey("media-library");
|
|
|
+ dictFile.setSysUserId(Long.valueOf(StpUtil.getLoginId().toString()));
|
|
|
+ dictFile.setUseType("trace_evidence");
|
|
|
+ dictFile.setUploadId(commonUpload.getId());
|
|
|
+ dictFile.setKno(param.getKno());
|
|
|
+ dictFile.setContent(param.getContent());
|
|
|
+ this.saveOrUpdate(dictFile);
|
|
|
+ }
|
|
|
}
|