mirror of https://github.com/jeecgboot/jeecg-boot
开启saas多租户功能后,租户管理员在添加分类字典时,报错 #4846
parent
e273008b37
commit
9dd8b05fd7
|
@ -1,14 +1,15 @@
|
||||||
package org.jeecg.modules.system.mapper;
|
package org.jeecg.modules.system.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||||
import java.util.Map;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
import org.jeecg.modules.system.entity.SysCategory;
|
import org.jeecg.modules.system.entity.SysCategory;
|
||||||
import org.jeecg.modules.system.model.TreeSelectModel;
|
import org.jeecg.modules.system.model.TreeSelectModel;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 分类字典
|
* @Description: 分类字典
|
||||||
|
@ -34,5 +35,16 @@ public interface SysCategoryMapper extends BaseMapper<SysCategory> {
|
||||||
@Select("SELECT ID FROM sys_category WHERE CODE = #{code,jdbcType=VARCHAR}")
|
@Select("SELECT ID FROM sys_category WHERE CODE = #{code,jdbcType=VARCHAR}")
|
||||||
public String queryIdByCode(@Param("code") String code);
|
public String queryIdByCode(@Param("code") String code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取分类字典最大的code
|
||||||
|
* @param page
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@InterceptorIgnore(tenantLine = "true")
|
||||||
|
@Select("SELECT code FROM sys_category WHERE code IS NOT NULL AND pid=#{categoryPid} ORDER BY code DESC")
|
||||||
|
List<SysCategory> getMaxCategoryCodeByPage(@Param("page") Page<SysCategory> page, @Param("categoryPid") String categoryPid);
|
||||||
|
|
||||||
|
@InterceptorIgnore(tenantLine = "true")
|
||||||
|
@Select("SELECT code FROM sys_category WHERE ID = #{id}")
|
||||||
|
SysCategory selectSysCategoryById(@Param("id") String id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.jeecg.modules.system.rule;
|
package org.jeecg.modules.system.rule;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jeecg.common.handler.IFillRuleHandler;
|
import org.jeecg.common.handler.IFillRuleHandler;
|
||||||
import org.jeecg.common.util.SpringContextUtils;
|
import org.jeecg.common.util.SpringContextUtils;
|
||||||
|
@ -50,16 +50,20 @@ public class CategoryCodeRule implements IFillRuleHandler {
|
||||||
* 3.添加子节点有兄弟元素 YouBianCodeUtil.getNextYouBianCode(lastCode);
|
* 3.添加子节点有兄弟元素 YouBianCodeUtil.getNextYouBianCode(lastCode);
|
||||||
* */
|
* */
|
||||||
//找同类 确定上一个最大的code值
|
//找同类 确定上一个最大的code值
|
||||||
LambdaQueryWrapper<SysCategory> query = new LambdaQueryWrapper<SysCategory>().eq(SysCategory::getPid, categoryPid).isNotNull(SysCategory::getCode).orderByDesc(SysCategory::getCode);
|
|
||||||
SysCategoryMapper baseMapper = (SysCategoryMapper) SpringContextUtils.getBean("sysCategoryMapper");
|
SysCategoryMapper baseMapper = (SysCategoryMapper) SpringContextUtils.getBean("sysCategoryMapper");
|
||||||
List<SysCategory> list = baseMapper.selectList(query);
|
//update-begin---author:wangshuai ---date:20230424 for:【issues/4846】开启saas多租户功能后,租户管理员在添加分类字典时,报错------------
|
||||||
|
Page<SysCategory> page = new Page<>(1,1);
|
||||||
|
List<SysCategory> list = baseMapper.getMaxCategoryCodeByPage(page,categoryPid);
|
||||||
|
//update-end---author:wangshuai ---date:20230424 for:【issues/4846】开启saas多租户功能后,租户管理员在添加分类字典时,报错------------
|
||||||
if (list == null || list.size() == 0) {
|
if (list == null || list.size() == 0) {
|
||||||
if (ROOT_PID_VALUE.equals(categoryPid)) {
|
if (ROOT_PID_VALUE.equals(categoryPid)) {
|
||||||
//情况1
|
//情况1
|
||||||
categoryCode = YouBianCodeUtil.getNextYouBianCode(null);
|
categoryCode = YouBianCodeUtil.getNextYouBianCode(null);
|
||||||
} else {
|
} else {
|
||||||
//情况2
|
//情况2
|
||||||
SysCategory parent = (SysCategory) baseMapper.selectById(categoryPid);
|
//update-begin---author:wangshuai ---date:20230424 for:【issues/4846】开启saas多租户功能后,租户管理员在添加分类字典时,报错------------
|
||||||
|
SysCategory parent = (SysCategory) baseMapper.selectSysCategoryById(categoryPid);
|
||||||
|
//update-end---author:wangshuai ---date:20230424 for:【issues/4846】开启saas多租户功能后,租户管理员在添加分类字典时,报错------------
|
||||||
categoryCode = YouBianCodeUtil.getSubYouBianCode(parent.getCode(), null);
|
categoryCode = YouBianCodeUtil.getSubYouBianCode(parent.getCode(), null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue