Browse Source

commit code

master
刘力 3 years ago
parent
commit
922ef8f445
  1. 6
      archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesDictionaryRepository.java
  2. 5
      archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesDictionaryImpl.java

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

@ -4,6 +4,7 @@ import com.storeroom.modules.dictionary.domain.ArchivesDictionary;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;
@ -37,8 +38,9 @@ public interface ArchivesDictionaryRepository extends JpaRepository<ArchivesDict
* @param fName
* @return
*/
@Query(value = "select * from archives_dictionary where field_name = ?1 or field_cn_name = ?2",nativeQuery = true)
ArchivesDictionary findByName(String fName, String fcName);
@Query(value = "select * from archives_dictionary where field_name = ?1 or field_cn_name = ?2 ", nativeQuery = true)
List<ArchivesDictionary> querybyName(String fName,String fcName);
}

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

@ -6,7 +6,6 @@ import com.storeroom.modules.dictionary.domain.ArchivesDictionary;
import com.storeroom.modules.dictionary.repository.ArchivesDictionaryRepository;
import com.storeroom.modules.dictionary.service.ArchivesDictionaryService;
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.utils.NanoIdUtils;
import com.storeroom.utils.ValidationUtil;
@ -93,8 +92,8 @@ public class ArchivesDictionaryImpl implements ArchivesDictionaryService {
@Override
public void create(ArchivesDictionaryDTO arcdicDto) {
ArchivesDictionary arc = archivesDictionaryMapper.toEntity(arcdicDto);
ArchivesDictionary arc1 = archivesDictionaryRepository.findByName(arc.getFieldCnName(), arc.getFieldName());
if (arc1==null){
List<ArchivesDictionary> arc1 = archivesDictionaryRepository.querybyName(arc.getFieldName(), arc.getFieldCnName());
if (arc1.size() == 0) {
arcdicDto.setId(NanoIdUtils.randomNanoId());
archivesDictionaryRepository.save(archivesDictionaryMapper.toEntity(arcdicDto));
}

Loading…
Cancel
Save