feat: 数据字典相关接口提交
This commit is contained in:
@ -16,8 +16,8 @@ public class DictionaryItemController {
|
||||
|
||||
private final DictionaryItemService dictionaryItemService;
|
||||
|
||||
@GetMapping("/tree")
|
||||
public ApiResponse<List<DictionaryItemVO>> tree(DictionaryItemDTO record) {
|
||||
@PostMapping("/tree")
|
||||
public ApiResponse<List<DictionaryItemVO>> tree(@RequestBody DictionaryItemDTO record) {
|
||||
return ApiResponse.success(dictionaryItemService.tree(record.getDictionaryId()));
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,12 @@ public class DictionaryItemServiceImpl implements DictionaryItemService {
|
||||
@Override
|
||||
public List<DictionaryItemVO> tree(String dictionaryId) {
|
||||
List<DictionaryItem> records = dictionaryItemMapper.findAllByDictionaryId(dictionaryId);
|
||||
return list2tree(records);
|
||||
List<DictionaryItem> sortedRecords = records.stream().sorted((item1, item2) -> {
|
||||
int sort1 = item1.getSort() == null ? 0 : item1.getSort();
|
||||
int sort2 = item2.getSort() == null ? 0 : item2.getSort();
|
||||
return sort2 - sort1;
|
||||
}).toList();
|
||||
return list2tree(sortedRecords);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -47,10 +52,10 @@ public class DictionaryItemServiceImpl implements DictionaryItemService {
|
||||
}
|
||||
if (record.getSort() == null) {
|
||||
dictionaryItem.setSort(0);
|
||||
} else {
|
||||
dictionaryItem.setSort(record.getSort());
|
||||
}
|
||||
if (Strings.isNotBlank(record.getDescription())) {
|
||||
dictionaryItem.setDescription(record.getDescription());
|
||||
}
|
||||
dictionaryItem.setDescription(record.getDescription());
|
||||
dictionaryItem.setUpdateTime(Timestamp.from(Instant.now()));
|
||||
return dictionaryItemMapper.updateById(dictionaryItem) > 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user