|
|
@ -11,6 +11,7 @@ import com.storeroom.modules.dictionary.service.dto.ArchivesTypeDTO; |
|
|
|
import com.storeroom.modules.dictionary.service.mapstruct.ArchivesTypeMapper; |
|
|
|
import com.storeroom.utils.DateUtils; |
|
|
|
import com.storeroom.utils.NanoIdUtils; |
|
|
|
import com.storeroom.utils.SpringUtils; |
|
|
|
import com.storeroom.utils.ValidationUtil; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
|
|
@ -33,13 +34,14 @@ public class ArchivesTypeServiceImpl implements ArchivesTypeService { |
|
|
|
private final ArchivesTypeRepository archivesTypeRepository; |
|
|
|
private final DynamicTableService dynamicTableService; |
|
|
|
|
|
|
|
@Value("${table-template.archive}") |
|
|
|
private String tableName; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void create(ArchivesTypeDTO archivesTypeDTO) { |
|
|
|
//#生成表名称 |
|
|
|
String tableName="tb_"; |
|
|
|
ArchivesType archivesType = archivesTypeMapper.toEntity(archivesTypeDTO); |
|
|
|
List<ArchivesType> archivesType1 = archivesTypeRepository.findByCnName(archivesType.getCnName()); |
|
|
|
if (archivesType1.size() == 0) { |
|
|
@ -48,6 +50,7 @@ public class ArchivesTypeServiceImpl implements ArchivesTypeService { |
|
|
|
archivesType.setEnName(tableName); |
|
|
|
archivesTypeRepository.save(archivesType); |
|
|
|
dynamicTableService.DynamicCreate(archivesType.getIsType(), archivesType.getId(), tableName); |
|
|
|
|
|
|
|
} else { |
|
|
|
throw new BaseException("门类名称不能重复"); |
|
|
|
} |
|
|
@ -60,7 +63,9 @@ public class ArchivesTypeServiceImpl implements ArchivesTypeService { |
|
|
|
List<ArchivesTypeDTO> trees = new ArrayList<>(); |
|
|
|
Set<String> ids = new HashSet<>(); |
|
|
|
for (ArchivesTypeDTO archivesTypeDTO : archivesTypeDTOS) { |
|
|
|
//如果父节点id为空就是一级菜单 |
|
|
|
if (archivesTypeDTO.getPid() == null) { |
|
|
|
//直接加入树列表 |
|
|
|
trees.add(archivesTypeDTO); |
|
|
|
} |
|
|
|
for (ArchivesTypeDTO at : archivesTypeDTOS) { |
|
|
|