|
|
@ -219,30 +219,48 @@ public class DictDataController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 查询 字典数据 |
|
|
|
|
|
* @param site 工厂编码 |
|
|
|
|
|
* @param dictType 字典类型 |
|
|
|
|
|
* author zelian_wu |
|
|
|
|
|
* date 2024-1-4 |
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
|
* 查询字典数据(列表,供下拉等使用) |
|
|
|
|
|
* <p>优先按请求中的 {@code site} 查询;若无数据且 {@code site} 不是 {@code *},再查 {@code site=*} 的全工厂默认字典; |
|
|
|
|
|
* 仍无则返回空列表。</p> |
|
|
|
|
|
* <p>未传 {@code status} 时默认只查在用(Y)。</p> |
|
|
*/ |
|
|
*/ |
|
|
@PostMapping("/list") |
|
|
@PostMapping("/list") |
|
|
public R selectDictDataList(@RequestBody DictDataVo dictDataVo){ |
|
|
public R selectDictDataList(@RequestBody DictDataVo dictDataVo){ |
|
|
if (!StringUtils.hasText(dictDataVo.getSite())){ |
|
|
if (!StringUtils.hasText(dictDataVo.getSite())){ |
|
|
throw new RuntimeException("工厂编码为空!"); |
|
|
throw new RuntimeException("工厂编码为空!"); |
|
|
} |
|
|
} |
|
|
if (!StringUtils.hasText(dictDataVo.getDictType()) && dictDataVo.getDictTypeList().isEmpty()){ |
|
|
|
|
|
|
|
|
boolean typeBlank = !StringUtils.hasText(dictDataVo.getDictType()); |
|
|
|
|
|
List<String> dictTypeList = dictDataVo.getDictTypeList(); |
|
|
|
|
|
if (typeBlank && (dictTypeList == null || dictTypeList.isEmpty())){ |
|
|
throw new RuntimeException("字典类型为空!"); |
|
|
throw new RuntimeException("字典类型为空!"); |
|
|
} |
|
|
} |
|
|
|
|
|
String currentSite = dictDataVo.getSite().trim(); |
|
|
|
|
|
List<DictData> rows = dictDataService.list(buildDictDataListWrapper(dictDataVo, currentSite)); |
|
|
|
|
|
if (rows.isEmpty() && !"*".equals(currentSite)) { |
|
|
|
|
|
rows = dictDataService.list(buildDictDataListWrapper(dictDataVo, "*")); |
|
|
|
|
|
} |
|
|
|
|
|
return R.ok().put("rows", rows); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 按指定 site 构造字典列表查询(不含 site 回落逻辑) |
|
|
|
|
|
*/ |
|
|
|
|
|
private LambdaQueryWrapper<DictData> buildDictDataListWrapper(DictDataVo dictDataVo, String site) { |
|
|
LambdaQueryWrapper<DictData> wrapper = new LambdaQueryWrapper<>(); |
|
|
LambdaQueryWrapper<DictData> wrapper = new LambdaQueryWrapper<>(); |
|
|
wrapper.eq(DictData::getSite,dictDataVo.getSite()); |
|
|
|
|
|
|
|
|
wrapper.eq(DictData::getSite, site); |
|
|
if (StringUtils.hasText(dictDataVo.getDictType())){ |
|
|
if (StringUtils.hasText(dictDataVo.getDictType())){ |
|
|
wrapper.eq(DictData::getDictType,dictDataVo.getDictType()); |
|
|
|
|
|
|
|
|
wrapper.eq(DictData::getDictType, dictDataVo.getDictType()); |
|
|
|
|
|
} |
|
|
|
|
|
List<String> dictTypeList = dictDataVo.getDictTypeList(); |
|
|
|
|
|
if (dictTypeList != null && !dictTypeList.isEmpty()){ |
|
|
|
|
|
wrapper.in(DictData::getDictType, dictTypeList); |
|
|
} |
|
|
} |
|
|
if (!dictDataVo.getDictTypeList().isEmpty()){ |
|
|
|
|
|
wrapper.in(DictData::getDictType,dictDataVo.getDictTypeList()); |
|
|
|
|
|
|
|
|
if (StringUtils.hasText(dictDataVo.getStatus())) { |
|
|
|
|
|
wrapper.eq(DictData::getStatus, dictDataVo.getStatus()); |
|
|
|
|
|
} else { |
|
|
|
|
|
wrapper.eq(DictData::getStatus, "Y"); |
|
|
} |
|
|
} |
|
|
wrapper.orderByAsc(DictData::getDictSort); |
|
|
wrapper.orderByAsc(DictData::getDictSort); |
|
|
return R.ok().put("rows",dictDataService.list(wrapper)); |
|
|
|
|
|
|
|
|
return wrapper; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |