| | |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.node.ForestNodeMerger; |
| | | import org.springblade.core.tool.utils.Func; |
| | |
| | | Dict parentDict = DictCache.getById(parentId); |
| | | List<Dict> list = this.list(Condition.getQueryWrapper(dict, Dict.class).lambda().ne(Dict::getId, parentId).eq(Dict::getCode, parentDict.getCode()).orderByAsc(Dict::getSort)); |
| | | return DictWrapper.build().listNodeVO(list); |
| | | } |
| | | |
| | | @Override |
| | | public R checkOrInsert(Dict dict) { |
| | | LambdaQueryWrapper<Dict> lqw = Wrappers.<Dict>query().lambda().eq(Dict::getCode, dict.getCode()).eq(Dict::getDictKey, dict.getDictKey()); |
| | | Long cnt = baseMapper.selectCount((Func.isEmpty(dict.getId())) ? lqw : lqw.notIn(Dict::getId, dict.getId())); |
| | | if (cnt > 0L) { |
| | | R.fail("字典已经存在!"); |
| | | } |
| | | if (Func.isEmpty(dict.getParentId())) { |
| | | dict.setParentId(BladeConstant.TOP_PARENT_ID); |
| | | } |
| | | dict.setIsDeleted(BladeConstant.DB_NOT_DELETED); |
| | | CacheUtil.clear(DICT_CACHE, Boolean.FALSE); |
| | | if(saveOrUpdate(dict) == true){ |
| | | return R.success("操作成功!"); |
| | | } |
| | | return R.fail("操作失败!"); |
| | | } |
| | | } |