use of org.jeecg.modules.system.entity.SysCategory in project jeecg-boot by jeecgboot.
the class SysCategoryServiceImpl method updateSysCategory.
@Override
public void updateSysCategory(SysCategory sysCategory) {
if (oConvertUtils.isEmpty(sysCategory.getPid())) {
sysCategory.setPid(ISysCategoryService.ROOT_PID_VALUE);
} else {
// 如果当前节点父ID不为空 则设置父节点的hasChild 为1
SysCategory parent = baseMapper.selectById(sysCategory.getPid());
if (parent != null && !"1".equals(parent.getHasChild())) {
parent.setHasChild("1");
baseMapper.updateById(parent);
}
}
baseMapper.updateById(sysCategory);
}
use of org.jeecg.modules.system.entity.SysCategory 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.modules.system.entity.SysCategory in project jeecg-boot by jeecgboot.
the class SysCategoryController method delete.
/**
* 通过id删除
* @param id
* @return
*/
@DeleteMapping(value = "/delete")
public Result<SysCategory> delete(@RequestParam(name = "id", required = true) String id) {
Result<SysCategory> result = new Result<SysCategory>();
SysCategory sysCategory = sysCategoryService.getById(id);
if (sysCategory == null) {
result.error500("未找到对应实体");
} else {
this.sysCategoryService.deleteSysCategory(id);
result.success("删除成功!");
}
return result;
}
use of org.jeecg.modules.system.entity.SysCategory in project jeecg-boot by jeecgboot.
the class CategoryCodeRule method execute.
@Override
public Object execute(JSONObject params, JSONObject formData) {
log.info("系统自定义编码规则[category_code_rule],params:{} ,formData: {}", params, formData);
String categoryPid = ROOT_PID_VALUE;
String categoryCode = null;
if (formData != null && formData.size() > 0) {
Object obj = formData.get("pid");
if (oConvertUtils.isNotEmpty(obj))
categoryPid = obj.toString();
} else {
if (params != null) {
Object obj = params.get("pid");
if (oConvertUtils.isNotEmpty(obj))
categoryPid = obj.toString();
}
}
/*
* 分成三种情况
* 1.数据库无数据 调用YouBianCodeUtil.getNextYouBianCode(null);
* 2.添加子节点,无兄弟元素 YouBianCodeUtil.getSubYouBianCode(parentCode,null);
* 3.添加子节点有兄弟元素 YouBianCodeUtil.getNextYouBianCode(lastCode);
* */
// 找同类 确定上一个最大的code值
LambdaQueryWrapper<SysCategory> query = new LambdaQueryWrapper<SysCategory>().eq(SysCategory::getPid, categoryPid).isNotNull(SysCategory::getCode).orderByDesc(SysCategory::getCode);
SysCategoryMapper baseMapper = (SysCategoryMapper) SpringContextUtils.getBean("sysCategoryMapper");
List<SysCategory> list = baseMapper.selectList(query);
if (list == null || list.size() == 0) {
if (ROOT_PID_VALUE.equals(categoryPid)) {
// 情况1
categoryCode = YouBianCodeUtil.getNextYouBianCode(null);
} else {
// 情况2
SysCategory parent = (SysCategory) baseMapper.selectById(categoryPid);
categoryCode = YouBianCodeUtil.getSubYouBianCode(parent.getCode(), null);
}
} else {
// 情况3
categoryCode = YouBianCodeUtil.getNextYouBianCode(list.get(0).getCode());
}
return categoryCode;
}
use of org.jeecg.modules.system.entity.SysCategory in project kms by mahonelau.
the class SysCategoryServiceImpl method getTreeChildIds.
/**
* 递归 根据父id获取子节点id
* @param pidVal
* @param sb
* @return
*/
private StringBuffer getTreeChildIds(String pidVal, StringBuffer sb) {
LambdaQueryWrapper<SysCategory> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysCategory::getPid, pidVal);
List<SysCategory> dataList = baseMapper.selectList(queryWrapper);
if (dataList != null && dataList.size() > 0) {
for (SysCategory category : dataList) {
if (!sb.toString().contains(category.getId())) {
sb.append(",").append(category.getId());
}
this.getTreeChildIds(category.getId(), sb);
}
}
return sb;
}
Aggregations