Browse Source

commit code

master
刘力 3 years ago
parent
commit
ca3a6dab56
  1. 38
      archives/src/main/java/com/storeroom/modules/dictionary/controller/ArchivesDisplayController.java
  2. 9
      archives/src/main/java/com/storeroom/modules/dictionary/controller/ArchivesTypeController.java
  3. 2
      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. 6
      archives/src/main/java/com/storeroom/modules/dictionary/service/dto/ArcTypeSmallDTO.java
  6. 7
      archives/src/main/java/com/storeroom/modules/dictionary/service/dto/ArchivesTypeDTO.java
  7. 15
      archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesDictionaryImpl.java
  8. 17
      archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java

38
archives/src/main/java/com/storeroom/modules/dictionary/controller/ArchivesDisplayController.java

@ -0,0 +1,38 @@
package com.storeroom.modules.dictionary.controller;
import com.storeroom.annotaion.rest.AnonymousPutMapping;
import com.storeroom.exception.BaseException;
import com.storeroom.exception.constant.ResponseStatus;
import com.storeroom.modules.dictionary.service.ArchivesDictionaryService;
import com.storeroom.modules.dictionary.service.dto.ArchivesDictionaryDTO;
import com.storeroom.utils.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@Api(tags = "著录界面预览")
@RestController
@RequiredArgsConstructor
@RequestMapping("/arc-display/")
public class ArchivesDisplayController {
private final ArchivesDictionaryService archivesDictionaryService;
@ApiOperation("修改门类字典排序")
@AnonymousPutMapping("sort")
public ApiResponse<Object> ardicSort(@RequestBody List<ArchivesDictionaryDTO> arcDicDto) {
if (arcDicDto.size() != 0 && arcDicDto.size() > 1) {
archivesDictionaryService.upSort(arcDicDto);
return ApiResponse.success(ResponseStatus.SUCCESS);
}
throw new BaseException("排序数据至少两条");
}
}

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

@ -11,12 +11,11 @@ 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.DictionaryService;
import com.storeroom.modules.dictionary.service.dto.ArcDicSmallDTO;
import com.storeroom.modules.dictionary.service.dto.ArcTypeSmallDTO;
import com.storeroom.modules.dictionary.service.dto.ArchivesDictionaryDTO;
import com.storeroom.modules.dictionary.service.dto.ArchivesTypeDTO;
import com.storeroom.utils.ApiResponse;
import com.storeroom.utils.StringUtils;
import com.storeroom.utils.ValidationUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
@ -159,10 +158,12 @@ public class ArchivesTypeController {
throw new BaseException("id异常");
}
@ApiOperation("修改排序")
@ApiOperation("修改门类菜单排序")
@AnonymousPutMapping("sort")
public ApiResponse<Object> upSort(@Validated @RequestBody Set<ArcDicSmallDTO> arcDicSmallDTO){
public ApiResponse<Object> dicTypeSort(@Validated @RequestBody Set<ArcTypeSmallDTO> arcDicSmallDTO) {
archivesTypeService.updateSort(arcDicSmallDTO);
return ApiResponse.success(ResponseStatus.SUCCESS);
}
}

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

@ -57,7 +57,7 @@ public interface ArchivesDictionaryService {
* @param archivesDictionaryDTO /
* @return /
*/
ArchivesDictionaryDTO upSort(ArchivesDictionaryDTO archivesDictionaryDTO);
List<ArchivesDictionaryDTO> upSort(List<ArchivesDictionaryDTO> archivesDictionaryDTO);
}

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

@ -2,7 +2,7 @@ package com.storeroom.modules.dictionary.service;
import com.storeroom.modules.dictionary.service.dto.ArcDicSmallDTO;
import com.storeroom.modules.dictionary.service.dto.ArcTypeSmallDTO;
import com.storeroom.modules.dictionary.service.dto.ArchivesTypeDTO;
import java.util.List;
@ -42,7 +42,7 @@ public interface ArchivesTypeService {
/**
*
*/
void updateSort(Set<ArcDicSmallDTO> arcDicSmallDTO);
void updateSort(Set<ArcTypeSmallDTO> arcDicSmallDTO);
}

6
archives/src/main/java/com/storeroom/modules/dictionary/service/dto/ArcDicSmallDTO.java → archives/src/main/java/com/storeroom/modules/dictionary/service/dto/ArcTypeSmallDTO.java

@ -1,18 +1,16 @@
package com.storeroom.modules.dictionary.service.dto;
import com.storeroom.base.BaseDTO;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
@Getter
@Setter
public class ArcDicSmallDTO implements Serializable {
public class ArcTypeSmallDTO implements Serializable {
@NotNull
private String id;

7
archives/src/main/java/com/storeroom/modules/dictionary/service/dto/ArchivesTypeDTO.java

@ -12,7 +12,7 @@ import java.util.Objects;
@Getter
@Setter
public class ArchivesTypeDTO extends BaseDTO implements Serializable {
public class ArchivesTypeDTO extends BaseDTO implements Serializable, Comparable<ArchivesTypeDTO> {
private String id;
@ -33,6 +33,11 @@ public class ArchivesTypeDTO extends BaseDTO implements Serializable {
private String remark;
@Override
public int compareTo(ArchivesTypeDTO o) {
return this.getCategorySeq() + o.getCategorySeq();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;

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

@ -107,12 +107,15 @@ public class ArchivesDictionaryImpl implements ArchivesDictionaryService {
}
@Override
public ArchivesDictionaryDTO upSort(ArchivesDictionaryDTO archivesDictionaryDTO) {
ArchivesDictionary archivesDictionary = archivesDictionaryMapper.toEntity(archivesDictionaryDTO);
ArchivesDictionary archivesDictionary1 = archivesDictionaryRepository.findById(archivesDictionary.getId()).orElseGet(ArchivesDictionary::new);
archivesDictionary1.setIsSequence(archivesDictionary.getIsSequence());
archivesDictionaryRepository.save(archivesDictionary1);
return archivesDictionaryMapper.toDto(archivesDictionary1);
public List<ArchivesDictionaryDTO> upSort(List<ArchivesDictionaryDTO> archivesDictionaryDTO) {
List<ArchivesDictionary> list = new ArrayList<>();
for (ArchivesDictionaryDTO ar : archivesDictionaryDTO) {
ArchivesDictionary ad = archivesDictionaryRepository.findById(ar.getId()).orElseGet(ArchivesDictionary::new);
ad.setIsSequence(ar.getIsSequence());
list.add(ad);
}
archivesDictionaryRepository.saveAll(list);
return null;
}

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

@ -1,22 +1,19 @@
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.ArchivesType;
import com.storeroom.modules.dictionary.repository.ArchivesTypeRepository;
import com.storeroom.modules.dictionary.service.ArchivesTypeService;
import com.storeroom.modules.dictionary.service.DynamicTableService;
import com.storeroom.modules.dictionary.service.dto.ArcDicSmallDTO;
import com.storeroom.modules.dictionary.service.dto.ArcTypeSmallDTO;
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;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -35,13 +32,11 @@ public class ArchivesTypeServiceImpl implements ArchivesTypeService {
private final DynamicTableService dynamicTableService;
@Override
@Transactional(rollbackFor = Exception.class)
public void create(ArchivesTypeDTO archivesTypeDTO) {
//#生成表名称
String tableName="tb_";
String tableName = "tb_";
ArchivesType archivesType = archivesTypeMapper.toEntity(archivesTypeDTO);
List<ArchivesType> archivesType1 = archivesTypeRepository.findByCnName(archivesType.getCnName());
if (archivesType1.size() == 0) {
@ -77,10 +72,14 @@ public class ArchivesTypeServiceImpl implements ArchivesTypeService {
ids.add(at.getId());
}
}
if (archivesTypeDTO.getChildren() != null && archivesTypeDTO.getCategorySeq() != null) {
archivesTypeDTO.getChildren().sort(Comparator.reverseOrder());
}
}
if (trees.size() == 0) {
trees = archivesTypeDTOS.stream().filter(s -> !ids.contains(s.getId())).collect(Collectors.toList());
}
trees.sort(Comparator.reverseOrder());
return trees;
}
@ -111,9 +110,9 @@ public class ArchivesTypeServiceImpl implements ArchivesTypeService {
}
@Override
public void updateSort(Set<ArcDicSmallDTO> arcDicSmallDTO) {
public void updateSort(Set<ArcTypeSmallDTO> arcDicSmallDTO) {
List<ArchivesType> list = new ArrayList<>();
for (ArcDicSmallDTO id : arcDicSmallDTO) {
for (ArcTypeSmallDTO id : arcDicSmallDTO) {
ArchivesType ar = archivesTypeRepository.findById(id.getId()).orElseGet(ArchivesType::new);
ar.setCategorySeq(id.getSort());
list.add(ar);

Loading…
Cancel
Save