125 lines
3.5 KiB
Java
125 lines
3.5 KiB
Java
package com.bonus.file.service;
|
|
|
|
import com.bonus.common.domain.file.po.ResourceFilePo;
|
|
import com.bonus.common.domain.file.po.ResourceFileRecordPo;
|
|
import com.bonus.common.domain.file.vo.ResourceFileVo;
|
|
import com.bonus.common.domain.mainDatabase.dto.EnterpriseDto;
|
|
import com.bonus.file.mapper.ISourceFileMapper;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.validation.constraints.NotNull;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Optional;
|
|
|
|
/**
|
|
* @className:SourceFileService
|
|
* @author:cwchen
|
|
* @date:2025-10-17-13:46
|
|
* @version:1.0
|
|
* @description:系统资源库实现类
|
|
*/
|
|
@Slf4j
|
|
@Service(value = "SourceFileService")
|
|
public class SourceFileService {
|
|
|
|
@Resource(name = "ISourceFileMapper")
|
|
private ISourceFileMapper mapper;
|
|
|
|
/**
|
|
* 保存系统文件
|
|
* @param list
|
|
* @return void
|
|
* @author cwchen
|
|
* @date 2025/10/17 14:45
|
|
*/
|
|
public void saveResourceFile(List<ResourceFilePo> list) {
|
|
mapper.saveResourceFile(list);
|
|
}
|
|
|
|
/**
|
|
* 删除系统资源文件
|
|
* @param list
|
|
* @param dataBaseName
|
|
* @return void
|
|
* @author cwchen
|
|
* @date 2025/10/23 10:55
|
|
*/
|
|
public void delResourceFile(List<String> list, String dataBaseName) {
|
|
mapper.delResourceFile(list,dataBaseName);
|
|
}
|
|
|
|
/**
|
|
* 删除系统资源文件-根据业务id和来源表
|
|
* @param businessId
|
|
* @param dataBaseName
|
|
* @return void
|
|
* @author cwchen
|
|
* @date 2025/10/23 13:06
|
|
*/
|
|
public void delResourceFileByTable(Long businessId, String dataBaseName) {
|
|
mapper.delResourceFileByTable(businessId,dataBaseName);
|
|
}
|
|
|
|
/**
|
|
* 查询资源文件 根据来源表和业务id
|
|
* @param businessId
|
|
* @param dataBaseName
|
|
* @return List<ResourceFileVo>
|
|
* @author cwchen
|
|
* @date 2025/10/23 13:40
|
|
*/
|
|
public List<ResourceFileVo> getFilesByTable(Long businessId, String dataBaseName) {
|
|
try {
|
|
List<ResourceFileVo> list = Optional.ofNullable(mapper.getFilesByTable(businessId,dataBaseName)).orElse(new ArrayList<>());
|
|
return list;
|
|
} catch (Exception e) {
|
|
log.error(e.toString(),e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 删除证书资源文件根据业务id、来源表、业务类型
|
|
* @param delFiles
|
|
* @return void
|
|
* @author cwchen
|
|
* @date 2025/10/24 11:10
|
|
*/
|
|
public void delResourceFileBybusinessId(List<ResourceFilePo> delFiles) {
|
|
mapper.delResourceFileBybusinessId(delFiles);
|
|
}
|
|
|
|
/**
|
|
* 根据文件id获取文件对象
|
|
* @param po
|
|
* @return ResourceFileVo
|
|
* @author cwchen
|
|
* @date 2025/11/7 22:15
|
|
*/
|
|
public ResourceFileVo getFileById(ResourceFilePo po) {
|
|
return mapper.getFileById(po);
|
|
}
|
|
|
|
/**
|
|
* 添加系统资源存储记录
|
|
* @param list
|
|
* @return void
|
|
* @author cwchen
|
|
* @date 2025/11/14 15:26
|
|
*/
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public void addResourceFileRecord(List<ResourceFileRecordPo> list){
|
|
try {
|
|
mapper.addResourceFileRecord(list);
|
|
} catch (Exception e) {
|
|
log.error(e.toString(),e);
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
}
|
|
}
|
|
}
|