use of org.jeecg.common.system.vo.DictModel in project jeecg-boot by jeecgboot.
the class OnlCgformDemoController method virtualDictData.
/**
* 模拟字典数据
*
* @return
*/
private List<DictModel> virtualDictData() {
List<DictModel> dict = new ArrayList<>();
dict.add(new DictModel("bj", "北京"));
dict.add(new DictModel("sd", "山东"));
dict.add(new DictModel("ah", "安徽"));
return dict;
}
use of org.jeecg.common.system.vo.DictModel in project jeecg-boot by jeecgboot.
the class OnlCgformDemoController method enhanceJavaListHttp.
/**
* Online表单 http 增强,list增强示例
* @param params
* @return
*/
@PostMapping("/enhanceJavaListHttp")
public Result<?> enhanceJavaListHttp(@RequestBody JSONObject params) {
log.info(" --- params:" + params.toJSONString());
JSONArray dataList = params.getJSONArray("dataList");
List<DictModel> dict = virtualDictData();
for (int i = 0; i < dataList.size(); i++) {
JSONObject record = dataList.getJSONObject(i);
String province = record.getString("province");
if (province == null) {
continue;
}
String text = dict.stream().filter(p -> province.equals(p.getValue())).map(DictModel::getText).findAny().orElse(province);
record.put("province", text);
}
Result<?> res = Result.OK(dataList);
res.setCode(1);
return res;
}
use of org.jeecg.common.system.vo.DictModel in project jeecg-boot by jeecgboot.
the class AutoPoiDictConfig method queryDict.
/**
* 通过字典查询easypoi,所需字典文本
*
* @Author:scott
* @since:2019-04-09
* @return
*/
@Override
public String[] queryDict(String dicTable, String dicCode, String dicText) {
List<String> dictReplaces = new ArrayList<String>();
List<DictModel> dictList = null;
// step.1 如果没有字典表则使用系统字典表
if (oConvertUtils.isEmpty(dicTable)) {
dictList = commonAPI.queryDictItemsByCode(dicCode);
} else {
try {
dicText = oConvertUtils.getString(dicText, dicCode);
dictList = commonAPI.queryTableDictItemsByCode(dicTable, dicText, dicCode);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
for (DictModel t : dictList) {
if (t != null) {
// update-begin---author:scott Date:20211220 for:[issues/I4MBB3]@Excel dicText字段的值有下划线时,导入功能不能正确解析---
if (t.getValue().contains(EXCEL_SPLIT_TAG)) {
String val = t.getValue().replace(EXCEL_SPLIT_TAG, TEMP_EXCEL_SPLIT_TAG);
dictReplaces.add(t.getText() + EXCEL_SPLIT_TAG + val);
} else {
dictReplaces.add(t.getText() + EXCEL_SPLIT_TAG + t.getValue());
}
// update-end---author:20211220 Date:20211220 for:[issues/I4MBB3]@Excel dicText字段的值有下划线时,导入功能不能正确解析---
}
}
if (dictReplaces != null && dictReplaces.size() != 0) {
log.info("---AutoPoi--Get_DB_Dict------" + dictReplaces.toString());
return dictReplaces.toArray(new String[dictReplaces.size()]);
}
return null;
}
use of org.jeecg.common.system.vo.DictModel in project jeecg-boot by jeecgboot.
the class SysCategoryController method loadAllData.
/**
* [列表页面]加载分类字典数据 用于值的替换
* @param code
* @return
*/
@RequestMapping(value = "/loadAllData", method = RequestMethod.GET)
public Result<List<DictModel>> loadAllData(@RequestParam(name = "code", required = true) String code) {
Result<List<DictModel>> result = new Result<List<DictModel>>();
LambdaQueryWrapper<SysCategory> query = new LambdaQueryWrapper<SysCategory>();
if (oConvertUtils.isNotEmpty(code) && !"0".equals(code)) {
query.likeRight(SysCategory::getCode, code);
}
List<SysCategory> list = this.sysCategoryService.list(query);
if (list == null || list.size() == 0) {
result.setMessage("无数据,参数有误.[code]");
result.setSuccess(false);
return result;
}
List<DictModel> rdList = new ArrayList<DictModel>();
for (SysCategory c : list) {
rdList.add(new DictModel(c.getId(), c.getName()));
}
result.setSuccess(true);
result.setResult(rdList);
return result;
}
use of org.jeecg.common.system.vo.DictModel in project jeecg-boot by jeecgboot.
the class SysDictController method loadDictOrderByValue.
/**
* 【接口签名验证】
* 【给表单设计器的表字典使用】下拉搜索模式,有值时动态拼接数据
* @param dictCode
* @param keyword 当前控件的值,可以逗号分割
* @param sign
* @param pageSize
* @return
*/
@RequestMapping(value = "/loadDictOrderByValue/{dictCode}", method = RequestMethod.GET)
public Result<List<DictModel>> loadDictOrderByValue(@PathVariable String dictCode, @RequestParam(name = "keyword") String keyword, @RequestParam(value = "sign", required = false) String sign, @RequestParam(value = "pageSize", required = false) Integer pageSize) {
// 首次查询查出来用户选中的值,并且不分页
Result<List<DictModel>> firstRes = this.loadDict(dictCode, keyword, sign, null);
if (!firstRes.isSuccess()) {
return firstRes;
}
// 然后再查询出第一页的数据
Result<List<DictModel>> result = this.loadDict(dictCode, "", sign, pageSize);
if (!result.isSuccess()) {
return result;
}
// 合并两次查询的数据
List<DictModel> firstList = firstRes.getResult();
List<DictModel> list = result.getResult();
for (DictModel firstItem : firstList) {
// anyMatch 表示:判断的条件里,任意一个元素匹配成功,返回true
// allMatch 表示:判断条件里的元素,所有的都匹配成功,返回true
// noneMatch 跟 allMatch 相反,表示:判断条件里的元素,所有的都匹配失败,返回true
boolean none = list.stream().noneMatch(item -> item.getValue().equals(firstItem.getValue()));
// 当元素不存在时,再添加到集合里
if (none) {
list.add(0, firstItem);
}
}
return result;
}
Aggregations