feat: 增加字典获取字典项接口
This commit is contained in:
parent
d040297adb
commit
5854c1b65b
@ -4,8 +4,10 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
import com.yfd.platform.annotation.Log;
|
import com.yfd.platform.annotation.Log;
|
||||||
import com.yfd.platform.config.ResponseResult;
|
import com.yfd.platform.config.ResponseResult;
|
||||||
import com.yfd.platform.system.domain.SysDictionary;
|
import com.yfd.platform.system.domain.SysDictionary;
|
||||||
|
import com.yfd.platform.system.domain.SysDictionaryItems;
|
||||||
import com.yfd.platform.system.mapper.SysDictionaryItemsMapper;
|
import com.yfd.platform.system.mapper.SysDictionaryItemsMapper;
|
||||||
import com.yfd.platform.system.service.ISysDictionaryService;
|
import com.yfd.platform.system.service.ISysDictionaryService;
|
||||||
|
import com.yfd.platform.system.service.ISysDictionaryItemsService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
@ -31,6 +33,9 @@ public class SysDictionaryController {
|
|||||||
@Resource
|
@Resource
|
||||||
private ISysDictionaryService sysDictionaryService;
|
private ISysDictionaryService sysDictionaryService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ISysDictionaryItemsService sysDictionaryItemsService;
|
||||||
|
|
||||||
/**********************************
|
/**********************************
|
||||||
* 用途说明: 获取数据字典列表
|
* 用途说明: 获取数据字典列表
|
||||||
* 参数说明 dictType 字典类型
|
* 参数说明 dictType 字典类型
|
||||||
@ -139,4 +144,18 @@ public class SysDictionaryController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getDictItemsByCode")
|
||||||
|
@Operation(summary = "根据字典编号查询字典项列表")
|
||||||
|
public ResponseResult getDictItemsByCode(@RequestParam String dictCode) {
|
||||||
|
if (StrUtil.isBlank(dictCode)) {
|
||||||
|
return ResponseResult.error("字典编号不能为空");
|
||||||
|
}
|
||||||
|
SysDictionary sysDictionary = sysDictionaryService.getByDictCode(dictCode);
|
||||||
|
if (sysDictionary == null) {
|
||||||
|
return ResponseResult.error("未找到对应的字典");
|
||||||
|
}
|
||||||
|
List<SysDictionaryItems> items = sysDictionaryItemsService.listByDictId(sysDictionary.getId());
|
||||||
|
return ResponseResult.successData(items);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,4 +44,11 @@ public interface ISysDictionaryItemsService extends IService<SysDictionaryItems>
|
|||||||
* 返回值说明: com.yfd.platform.config.ResponseResult 返回导出成功或失败
|
* 返回值说明: com.yfd.platform.config.ResponseResult 返回导出成功或失败
|
||||||
***********************************/
|
***********************************/
|
||||||
void exportExcel(List<SysDictionaryItems> records, HttpServletResponse response);
|
void exportExcel(List<SysDictionaryItems> records, HttpServletResponse response);
|
||||||
|
|
||||||
|
/**********************************
|
||||||
|
* 用途说明: 根据字典ID查询字典项列表
|
||||||
|
* 参数说明 dictId 字典ID
|
||||||
|
* 返回值说明: List<SysDictionaryItems> 字典项列表
|
||||||
|
***********************************/
|
||||||
|
List<SysDictionaryItems> listByDictId(String dictId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,4 +42,11 @@ public interface ISysDictionaryService extends IService<SysDictionary> {
|
|||||||
* 返回值说明: com.yfd.platform.config.ResponseResult 返回拖动成功或者失败
|
* 返回值说明: com.yfd.platform.config.ResponseResult 返回拖动成功或者失败
|
||||||
***********************************/
|
***********************************/
|
||||||
boolean changeDictOrder(String fromID, String toID);
|
boolean changeDictOrder(String fromID, String toID);
|
||||||
|
|
||||||
|
/**********************************
|
||||||
|
* 用途说明: 根据字典编号查询字典
|
||||||
|
* 参数说明 dictCode 字典编号
|
||||||
|
* 返回值说明: SysDictionary 字典对象
|
||||||
|
***********************************/
|
||||||
|
SysDictionary getByDictCode(String dictCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -120,4 +120,11 @@ public class SysDictionaryItemsServiceImpl extends ServiceImpl<SysDictionaryItem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysDictionaryItems> listByDictId(String dictId) {
|
||||||
|
LambdaQueryWrapper<SysDictionaryItems> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(SysDictionaryItems::getDictId, dictId).orderByAsc(SysDictionaryItems::getOrderNo);
|
||||||
|
return sysDictionaryItemsMapper.selectList(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -111,4 +111,11 @@ public class SysDictionaryServiceImpl extends ServiceImpl<SysDictionaryMapper
|
|||||||
return fromBool && toBool;
|
return fromBool && toBool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysDictionary getByDictCode(String dictCode) {
|
||||||
|
LambdaQueryWrapper<SysDictionary> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(SysDictionary::getDictCode, dictCode);
|
||||||
|
return sysDictionaryMapper.selectOne(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user