Browse Source

commit code

master
刘力 3 years ago
parent
commit
a2ddd2499d
  1. 40
      archives/src/main/java/com/storeroom/modules/dictionary/controller/ArchivesTypeController.java
  2. 9
      archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesDictionaryRepository.java
  3. 25
      archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesDictionaryService.java
  4. 4
      archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesTypeService.java
  5. 62
      archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesDictionaryImpl.java
  6. 2
      archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java
  7. 6
      archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DynamicTableImpl.java

40
archives/src/main/java/com/storeroom/modules/dictionary/controller/ArchivesTypeController.java

@ -4,14 +4,18 @@ package com.storeroom.modules.dictionary.controller;
import com.storeroom.annotaion.rest.AnonymousGetMapping; import com.storeroom.annotaion.rest.AnonymousGetMapping;
import com.storeroom.annotaion.rest.AnonymousPostMapping; import com.storeroom.annotaion.rest.AnonymousPostMapping;
import com.storeroom.exception.BaseException; import com.storeroom.exception.BaseException;
import com.storeroom.exception.constant.ResponseStatus;
import com.storeroom.modules.common.ArchivesTypeEnum; import com.storeroom.modules.common.ArchivesTypeEnum;
import com.storeroom.modules.dictionary.service.ArchivesDictionaryService;
import com.storeroom.modules.dictionary.service.ArchivesTypeService; import com.storeroom.modules.dictionary.service.ArchivesTypeService;
import com.storeroom.modules.dictionary.service.dto.ArchivesDictionaryDTO;
import com.storeroom.modules.dictionary.service.dto.ArchivesTypeDTO; import com.storeroom.modules.dictionary.service.dto.ArchivesTypeDTO;
import com.storeroom.utils.ApiResponse; import com.storeroom.utils.ApiResponse;
import com.storeroom.utils.StringUtils; import com.storeroom.utils.StringUtils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -26,6 +30,7 @@ import java.util.*;
public class ArchivesTypeController { public class ArchivesTypeController {
private final ArchivesTypeService archivesTypeService; private final ArchivesTypeService archivesTypeService;
private final ArchivesDictionaryService archivesDictionaryService;
@ApiOperation("门类类型") @ApiOperation("门类类型")
@ -36,7 +41,7 @@ public class ArchivesTypeController {
list.put(ArchivesTypeEnum.project.getCode(), ArchivesTypeEnum.project.getType()); list.put(ArchivesTypeEnum.project.getCode(), ArchivesTypeEnum.project.getType());
list.put(ArchivesTypeEnum.archives.getCode(), ArchivesTypeEnum.archives.getType()); list.put(ArchivesTypeEnum.archives.getCode(), ArchivesTypeEnum.archives.getType());
list.put(ArchivesTypeEnum.inChive.getCode(), ArchivesTypeEnum.inChive.getType()); list.put(ArchivesTypeEnum.inChive.getCode(), ArchivesTypeEnum.inChive.getType());
list.put(ArchivesTypeEnum.files.getCode(), ArchivesTypeEnum.folder.getType());
list.put(ArchivesTypeEnum.files.getCode(), ArchivesTypeEnum.files.getType());
list.put(ArchivesTypeEnum.Template.getCode(), ArchivesTypeEnum.Template.getType()); list.put(ArchivesTypeEnum.Template.getCode(), ArchivesTypeEnum.Template.getType());
return ApiResponse.success(list); return ApiResponse.success(list);
} }
@ -45,13 +50,13 @@ public class ArchivesTypeController {
@AnonymousPostMapping("create") @AnonymousPostMapping("create")
//TODO:权限未添加 //TODO:权限未添加
public ApiResponse<Object> save(@RequestBody ArchivesTypeDTO archivesTypeDTO) { public ApiResponse<Object> save(@RequestBody ArchivesTypeDTO archivesTypeDTO) {
if (archivesTypeDTO.getId() != null) {
if (!StringUtils.isEmpty(archivesTypeDTO.getId())) {
throw new BaseException("this is not empty Data"); throw new BaseException("this is not empty Data");
} }
if (archivesTypeDTO.getIsType() == null) { if (archivesTypeDTO.getIsType() == null) {
throw new BaseException("type cannot be Null"); throw new BaseException("type cannot be Null");
} }
if (archivesTypeDTO.getCnName().isEmpty()) {
if (StringUtils.isEmpty(archivesTypeDTO.getCnName())) {
throw new BaseException("Name canot be null"); throw new BaseException("Name canot be null");
} }
archivesTypeService.create(archivesTypeDTO); archivesTypeService.create(archivesTypeDTO);
@ -64,4 +69,33 @@ public class ArchivesTypeController {
public ApiResponse<Object> getMenuTree() { public ApiResponse<Object> getMenuTree() {
return ApiResponse.success(archivesTypeService.buildTree()); return ApiResponse.success(archivesTypeService.buildTree());
} }
@ApiOperation("门类字段管理")
@AnonymousGetMapping("manage")
public ApiResponse<Object> getFieldName(String categoryId) {
if (!StringUtils.isEmpty(categoryId)) {
return ApiResponse.success(archivesDictionaryService.getAll(categoryId));
}
throw new BaseException("id异常");
}
@ApiOperation("通过id查询门类字典")
@AnonymousGetMapping("query")
public ApiResponse<Object> getArcDic(String arcdicId) {
if (!StringUtils.isEmpty(arcdicId)) {
return ApiResponse.success(archivesDictionaryService.findById(arcdicId));
}
throw new BaseException("id异常");
}
@ApiOperation("修改数据")
@AnonymousPostMapping("update")
public ApiResponse<Object> update(@RequestBody ArchivesDictionaryDTO arcdicDto) {
if (!StringUtils.isEmpty(arcdicDto.getId())) {
archivesDictionaryService.update(arcdicDto);
return ApiResponse.success(ResponseStatus.SUCCESS);
}
throw new BaseException("id异常");
}
} }

9
archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesDictionaryRepository.java

@ -28,4 +28,13 @@ public interface ArchivesDictionaryRepository extends JpaRepository<ArchivesDict
@Query(value = "from ArchivesDictionary where categoryId = ?1 and isDisplay = true order by displayOrder asc") @Query(value = "from ArchivesDictionary where categoryId = ?1 and isDisplay = true order by displayOrder asc")
List<ArchivesDictionary> findDisPlay(String categoryId); List<ArchivesDictionary> findDisPlay(String categoryId);
/**
* 通过门类id查询
* @param categoryId
* @return
*/
List<ArchivesDictionary> findByCategoryId(String categoryId);
} }

25
archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesDictionaryService.java

@ -2,6 +2,7 @@ package com.storeroom.modules.dictionary.service;
import com.storeroom.modules.dictionary.service.dto.ArchivesDictionaryDTO; import com.storeroom.modules.dictionary.service.dto.ArchivesDictionaryDTO;
import com.storeroom.modules.dictionary.service.dto.ArchivesTypeDTO;
import java.util.List; import java.util.List;
@ -12,4 +13,28 @@ public interface ArchivesDictionaryService {
* @param list * @param list
*/ */
void saveAll(List<ArchivesDictionaryDTO> list); void saveAll(List<ArchivesDictionaryDTO> list);
/**
* 获取所有门类字典字段
* @return
*/
List<ArchivesDictionaryDTO> getAll(String categoryId);
/**
* 通过id 查询字段数据
* @param adId 字典id
* @return
*/
ArchivesDictionaryDTO findById(String adId);
/**
* 修改保存
* @param
* @return
*/
void update(ArchivesDictionaryDTO arcdicDto);
} }

4
archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesTypeService.java

@ -1,6 +1,7 @@
package com.storeroom.modules.dictionary.service; package com.storeroom.modules.dictionary.service;
import com.storeroom.modules.dictionary.service.dto.ArchivesTypeDTO; import com.storeroom.modules.dictionary.service.dto.ArchivesTypeDTO;
import java.util.List; import java.util.List;
@ -24,4 +25,7 @@ public interface ArchivesTypeService {
} }

62
archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesDictionaryImpl.java

@ -1,12 +1,15 @@
package com.storeroom.modules.dictionary.service.impl; package com.storeroom.modules.dictionary.service.impl;
import com.storeroom.exception.BaseException;
import com.storeroom.modules.dictionary.domain.ArchivesDictionary; import com.storeroom.modules.dictionary.domain.ArchivesDictionary;
import com.storeroom.modules.dictionary.repository.ArchivesDictionaryRepository; import com.storeroom.modules.dictionary.repository.ArchivesDictionaryRepository;
import com.storeroom.modules.dictionary.service.ArchivesDictionaryService; import com.storeroom.modules.dictionary.service.ArchivesDictionaryService;
import com.storeroom.modules.dictionary.service.dto.ArchivesDictionaryDTO; import com.storeroom.modules.dictionary.service.dto.ArchivesDictionaryDTO;
import com.storeroom.modules.dictionary.service.dto.ArchivesTypeDTO;
import com.storeroom.modules.dictionary.service.mapstruct.ArchivesDictionaryMapper; import com.storeroom.modules.dictionary.service.mapstruct.ArchivesDictionaryMapper;
import com.storeroom.utils.NanoIdUtils; import com.storeroom.utils.NanoIdUtils;
import com.storeroom.utils.ValidationUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -25,14 +28,67 @@ public class ArchivesDictionaryImpl implements ArchivesDictionaryService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void saveAll(List<ArchivesDictionaryDTO> list) { public void saveAll(List<ArchivesDictionaryDTO> list) {
List<ArchivesDictionary> list1=new ArrayList<>();
List<ArchivesDictionary> list1 = new ArrayList<>();
for (ArchivesDictionaryDTO o : list) { for (ArchivesDictionaryDTO o : list) {
ArchivesDictionary a = archivesDictionaryMapper.toEntity(o); ArchivesDictionary a = archivesDictionaryMapper.toEntity(o);
a.setId(NanoIdUtils.randomNanoId()); a.setId(NanoIdUtils.randomNanoId());
//this.archivesDictionaryRepository.saveAndFlush(a);
list1.add(a);
// archivesDictionaryRepository.save(a);
list1.add(a);
} }
archivesDictionaryRepository.saveAll(list1); archivesDictionaryRepository.saveAll(list1);
} }
@Override
public List<ArchivesDictionaryDTO> getAll(String categoryId) {
return archivesDictionaryMapper.toDto(archivesDictionaryRepository.findByCategoryId(categoryId));
}
@Override
public ArchivesDictionaryDTO findById(String adId) {
return archivesDictionaryMapper.toDto(archivesDictionaryRepository.findById(adId).orElseGet(ArchivesDictionary::new));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(ArchivesDictionaryDTO arcdicDto){
ArchivesDictionary dictionary = archivesDictionaryMapper.toEntity(arcdicDto);
ArchivesDictionary dictionary1 = archivesDictionaryRepository.findById(dictionary.getId()).orElseGet(ArchivesDictionary::new);
ValidationUtil.isNull(dictionary1.getId(), "ArchivesDictionary", "id", dictionary.getId());
dictionary1.setFieldName(dictionary.getFieldName());
dictionary1.setFieldCnName(dictionary.getFieldCnName());
dictionary1.setIsDefaultValue(dictionary.getIsDefaultValue());
dictionary1.setIsInput(dictionary.getIsInput());
dictionary1.setIsInputClass(dictionary.getIsInputClass());
dictionary1.setIsDataTypeDetails(dictionary.getIsDataTypeDetails());
dictionary1.setIsColumnLength(dictionary.getIsColumnLength());
dictionary1.setIsColumnType(dictionary.getIsColumnType());
dictionary1.setIsSequence(dictionary.getIsSequence());
dictionary1.setIsType(dictionary.getIsType());
dictionary1.setIsSystem(dictionary.getIsSystem());
dictionary1.setIsLine(dictionary.getIsLine());
dictionary1.setIsInput(dictionary.getIsInput());
dictionary1.setIsRequired(dictionary.getIsRequired());
dictionary1.setIsAutomatic(dictionary.getIsAutomatic());
dictionary1.setIsAdd(dictionary.getIsAdd());
dictionary1.setIsSearch(dictionary.getIsSearch());
dictionary1.setIsInherit(dictionary.getIsInherit());
dictionary1.setIsFilling(dictionary.getIsFilling());
dictionary1.setFillingDigit(dictionary.getFillingDigit());
dictionary1.setIsRepeat(dictionary.getIsRepeat());
dictionary1.setIsDisplay(dictionary.getIsDisplay());
dictionary1.setDisplayOrder(dictionary.getDisplayOrder());
dictionary1.setIsDisplayformat(dictionary.getIsDisplayformat());
dictionary1.setEditLength(dictionary.getEditLength());
dictionary1.setDisplayformatType(dictionary.getDisplayformatType());
dictionary1.setDisplayLength(dictionary.getDisplayLength());
archivesDictionaryRepository.save(dictionary1);
}
} }

2
archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java

@ -75,4 +75,6 @@ public class ArchivesTypeServiceImpl implements ArchivesTypeService {
} }
return trees; return trees;
} }
} }

6
archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DynamicTableImpl.java

@ -14,6 +14,7 @@ import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -78,10 +79,11 @@ public class DynamicTableImpl implements DynamicTableService {
* @param list * @param list
* @param archiveTypeId * @param archiveTypeId
*/ */
private void DynamicInsert(List<FieldVO> list, String archiveTypeId) { private void DynamicInsert(List<FieldVO> list, String archiveTypeId) {
List<ArchivesDictionaryDTO> newList = new ArrayList<>(); List<ArchivesDictionaryDTO> newList = new ArrayList<>();
ArchivesDictionaryDTO archivesDictionaryDTO = new ArchivesDictionaryDTO();
for (FieldVO j : list) { for (FieldVO j : list) {
ArchivesDictionaryDTO archivesDictionaryDTO = new ArchivesDictionaryDTO();
j.setCategoryId(archiveTypeId); j.setCategoryId(archiveTypeId);
archivesDictionaryDTO.setFieldName(j.getFieldName()); archivesDictionaryDTO.setFieldName(j.getFieldName());
archivesDictionaryDTO.setFieldCnName(j.getFieldCnName()); archivesDictionaryDTO.setFieldCnName(j.getFieldCnName());
@ -95,6 +97,8 @@ public class DynamicTableImpl implements DynamicTableService {
archivesDictionaryDTO.setIsSystem(j.getIsSystem()); archivesDictionaryDTO.setIsSystem(j.getIsSystem());
newList.add(archivesDictionaryDTO); newList.add(archivesDictionaryDTO);
} }
archivesDictionaryService.saveAll(newList); archivesDictionaryService.saveAll(newList);
} }

Loading…
Cancel
Save