yangdamao 2 年之前
父节点
当前提交
14a06e9e6d
共有 27 个文件被更改,包括 388 次插入44 次删除
  1. 15 0
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/common/CommonController.java
  2. 3 0
      zhongzheng-common/src/main/java/com/zhongzheng/common/core/domain/entity/SysDictData.java
  3. 2 0
      zhongzheng-common/src/main/java/com/zhongzheng/common/core/domain/entity/SysDictType.java
  4. 6 0
      zhongzheng-common/src/main/java/com/zhongzheng/common/utils/DateUtils.java
  5. 2 0
      zhongzheng-framework/src/main/java/com/zhongzheng/framework/config/SecurityConfig.java
  6. 227 10
      zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/SysTenantServiceImpl.java
  7. 21 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/bo/SysTenantAdminOldBo.java
  8. 5 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/domain/SysRoleMenu.java
  9. 6 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysDictDataMapper.java
  10. 9 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysDictTypeMapper.java
  11. 8 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysMenuMapper.java
  12. 4 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysRoleMapper.java
  13. 6 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysRoleMenuMapper.java
  14. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysDictDataService.java
  15. 4 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysDictTypeService.java
  16. 6 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysMenuService.java
  17. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysRoleService.java
  18. 4 4
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysTenantService.java
  19. 5 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/impl/SysDictDataServiceImpl.java
  20. 10 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/impl/SysDictTypeServiceImpl.java
  21. 10 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/impl/SysMenuServiceImpl.java
  22. 5 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/impl/SysRoleServiceImpl.java
  23. 3 16
      zhongzheng-system/src/main/resources/mapper/modules/system/SysDictDataMapper.xml
  24. 7 10
      zhongzheng-system/src/main/resources/mapper/modules/system/SysDictTypeMapper.xml
  25. 8 0
      zhongzheng-system/src/main/resources/mapper/modules/system/SysMenuMapper.xml
  26. 4 0
      zhongzheng-system/src/main/resources/mapper/modules/system/SysRoleMapper.xml
  27. 4 4
      zhongzheng-system/src/main/resources/mapper/modules/system/SysRoleMenuMapper.xml

+ 15 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/common/CommonController.java

@@ -45,6 +45,7 @@ import com.zhongzheng.modules.order.domain.OrderGoods;
 import com.zhongzheng.modules.order.service.IOrderGoodsService;
 import com.zhongzheng.modules.order.service.IOrderService;
 import com.zhongzheng.modules.system.bo.SysTenantAdminBo;
+import com.zhongzheng.modules.system.bo.SysTenantAdminOldBo;
 import com.zhongzheng.modules.system.bo.SysTenantQueryBo;
 import com.zhongzheng.modules.system.domain.SysTenant;
 import com.zhongzheng.modules.system.service.ISysConfigService;
@@ -357,6 +358,20 @@ public class CommonController extends BaseController
         return AjaxResult.success();
     }
 
+    @ApiOperation("创建新机构后台(旧系统)")
+    @PostMapping("common/create/tenant/admin/old")
+    public AjaxResult createTenantAdminOld(@RequestBody SysTenantAdminOldBo bo) {
+        iSysTenantService.createTenantAdminOld(bo);
+        return AjaxResult.success();
+    }
+
+    @ApiOperation("同步其他机构角色菜单")
+    @PostMapping("common/update/role")
+    public AjaxResult updateRoleTenant(@RequestBody List<Long> tenantIds) {
+        iSysTenantService.updateRoleTenant(tenantIds);
+        return AjaxResult.success();
+    }
+
     @ApiOperation("获取企业列表")
     @GetMapping("common/tenant/list")
     public AjaxResult<List<SysTenantVo>> getTenantList() {

+ 3 - 0
zhongzheng-common/src/main/java/com/zhongzheng/common/core/domain/entity/SysDictData.java

@@ -70,6 +70,9 @@ public class SysDictData implements Serializable
     /** 表格字典样式 */
     private String listClass;
 
+    @TableField(value = "tenant_id")
+    private Long tenantId;
+
     /** 是否默认(Y是 N否) */
     @Excel(name = "是否默认", readConverterExp = "Y=是,N=否")
     private String isDefault;

+ 2 - 0
zhongzheng-common/src/main/java/com/zhongzheng/common/core/domain/entity/SysDictType.java

@@ -82,6 +82,8 @@ public class SysDictType implements Serializable
     @TableField(exist = false)
     private Map<String, Object> params = new HashMap<>();
 
+    @TableField(value = "tenant_id")
+    private Long tenantId;
 
     /** 分页大小 */
     @ApiModelProperty("分页大小")

+ 6 - 0
zhongzheng-common/src/main/java/com/zhongzheng/common/utils/DateUtils.java

@@ -224,6 +224,12 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
         return cal.getTimeInMillis() / 1000;  //今天凌晨
     }
 
+    public static String formatDate(Date time,String str)
+    {
+       SimpleDateFormat sdf = new SimpleDateFormat(str);
+        return sdf.format(time);
+    }
+
     /**
      * 获取明天凌晨时间戳
      */

+ 2 - 0
zhongzheng-framework/src/main/java/com/zhongzheng/framework/config/SecurityConfig.java

@@ -137,6 +137,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 .antMatchers("/common/get/goods").anonymous()
                 .antMatchers("/common/get/goods/studyUrl").anonymous()
                 .antMatchers("/common/create/tenant/admin").anonymous()
+                .antMatchers("/common/create/tenant/admin/old").anonymous()
+                .antMatchers("/common/update/role").anonymous()
                 .antMatchers("/common/free/**").anonymous()
                 .antMatchers("/common/download**").anonymous()
                 .antMatchers("/common/download/resource**").anonymous()

+ 227 - 10
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/SysTenantServiceImpl.java

@@ -6,25 +6,22 @@ import cn.hutool.core.util.StrUtil;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.Page;
-import com.zhongzheng.common.core.domain.entity.SysMenu;
-import com.zhongzheng.common.core.domain.entity.SysUser;
+import com.zhongzheng.common.core.domain.entity.*;
 import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.SecurityUtils;
 import com.zhongzheng.common.utils.ServletUtils;
-import com.zhongzheng.modules.system.bo.SysTenantAddBo;
-import com.zhongzheng.modules.system.bo.SysTenantAdminBo;
-import com.zhongzheng.modules.system.bo.SysTenantEditBo;
-import com.zhongzheng.modules.system.bo.SysTenantQueryBo;
+import com.zhongzheng.modules.system.bo.*;
+import com.zhongzheng.modules.system.domain.SysConfig;
+import com.zhongzheng.modules.system.domain.SysRoleMenu;
 import com.zhongzheng.modules.system.domain.SysTenant;
+import com.zhongzheng.modules.system.mapper.SysRoleMenuMapper;
 import com.zhongzheng.modules.system.mapper.SysTenantMapper;
-import com.zhongzheng.modules.system.service.ISysMenuService;
-import com.zhongzheng.modules.system.service.ISysTenantService;
-import com.zhongzheng.modules.system.service.ISysUserService;
-import com.zhongzheng.modules.system.service.ISysWebService;
+import com.zhongzheng.modules.system.service.*;
 import com.zhongzheng.modules.system.vo.SysTenantVo;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -32,6 +29,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -52,9 +50,24 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
     @Autowired
     private ISysMenuService menuService;
 
+    @Autowired
+    private ISysRoleService roleService;
+
+    @Autowired
+    private SysRoleMenuMapper sysRoleMenuMapper;
+
     @Autowired
     private ISysWebService iSysWebService;
 
+    @Autowired
+    private ISysConfigService iSysConfigService;
+
+    @Autowired
+    private ISysDictDataService iSysDictDataService;
+
+    @Autowired
+    private ISysDictTypeService iSysDictTypeService;
+
     @Override
     public SysTenantVo queryById(Long tenantId){
         SysTenant db = this.baseMapper.selectById(tenantId);
@@ -192,6 +205,12 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
         newMenus.forEach(item -> {
             menuService.updateParentById(item);
         });
+
+        //新增分销角色
+        initRoles(newTenantId,tenantId);
+
+        //初始化配置和字典
+        initConfigAndDict(newTenantId,tenantId);
         return newTenantId;
 
     }
@@ -248,4 +267,202 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
         return list(new LambdaQueryWrapper<SysTenant>().eq(SysTenant::getStatus, 1));
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void createTenantAdminOld(SysTenantAdminOldBo bo) {
+        if(Validator.isEmpty(bo.getTenantName())){
+            throw new CustomException("没有企业名称");
+        }
+        //中正后台企业ID
+        Long tenantId = 867735392558919680L;
+        //设置新机构
+        SysTenant sysTenant = getById(tenantId);
+        sysTenant.setTenantName(bo.getTenantName());
+        //生成tenantId
+//        Long newTenantId = createTenantId();
+        Long newTenantId = bo.getTenantId();
+        sysTenant.setTenantId(newTenantId);
+        if (!save(sysTenant)){
+            throw new CustomException("创建企业失败");
+        }
+        //创建账号
+        SysUser admin = userService.selectUserByTenant("admin",tenantId);
+        admin.setTenantId(newTenantId);
+        admin.setUserId(null);
+
+        if (!userService.save(admin)){
+            throw new CustomException("创建后台账号失败");
+        }
+        //创建菜单
+        List<SysMenu> list = menuService.listSysMenuByTenant(tenantId);
+        if (CollectionUtils.isEmpty(list)){
+            return;
+        }
+        List<SysMenu> oldMenus = list.stream().map(item -> BeanUtil.toBean(item, SysMenu.class)).collect(Collectors.toList());
+        list.forEach(item -> {
+            item.setMenuId(null);
+            item.setTenantId(newTenantId);
+        });
+        if (!menuService.saveBatch(list)){
+            throw new CustomException("添加菜单失败");
+        }
+        //新菜单
+        List<SysMenu> newMenus = menuService.listSysMenuByTenant(newTenantId);
+        //匹配parent_id
+        for (SysMenu newMenu : newMenus) {
+            if (newMenu.getParentId() == 0){
+                continue;
+            }
+            List<SysMenu> collect = oldMenus.stream().filter(x -> x.getMenuName().equals(newMenu.getMenuName())
+                    && x.getCreateTime().equals(newMenu.getCreateTime()) && x.getOrderNum().equals(newMenu.getOrderNum())).collect(Collectors.toList());
+            if (CollectionUtils.isEmpty(collect) || collect.size() > 1){
+                throw new CustomException("菜单匹配失败:"+newMenu.getMenuName());
+            }
+            SysMenu sysMenu = collect.stream().findFirst().orElse(null);
+            SysMenu parentMenu = oldMenus.stream().filter(x -> x.getMenuId().equals(sysMenu.getParentId())).findFirst().orElse(null);
+            List<SysMenu> collect2 = newMenus.stream().filter(x -> x.getMenuName().equals(parentMenu.getMenuName())
+                    && x.getCreateTime().equals(parentMenu.getCreateTime()) && x.getOrderNum().equals(parentMenu.getOrderNum())).collect(Collectors.toList());
+            if (CollectionUtils.isEmpty(collect2) || collect2.size() > 1){
+                throw new CustomException("菜单匹配失败:"+newMenu.getMenuName());
+            }
+            newMenu.setParentId(collect2.get(0).getMenuId());
+        }
+        //修改父ID
+//        menuService.updateBatchById(newMenus);
+        newMenus.forEach(item -> {
+            menuService.updateParentById(item);
+        });
+
+        //新增分销角色
+        initRoles(newTenantId,tenantId);
+
+        //初始化配置和字典
+        initConfigAndDict(newTenantId,tenantId);
+    }
+
+    private void initConfigAndDict(Long newTenantId, Long tenantId) {
+        SysConfig config = iSysConfigService.getSysConfigByKeyTenant("home.header", newTenantId);
+        if (ObjectUtils.isNull(config)){
+            SysConfig sysConfigByKeyTenant = iSysConfigService.getSysConfigByKeyTenant("home.header", tenantId);
+            sysConfigByKeyTenant.setTenantId(newTenantId);
+            sysConfigByKeyTenant.setConfigId(null);
+            iSysConfigService.save(sysConfigByKeyTenant);
+        }
+        //字典
+        List<SysDictType> dictTypes = iSysDictTypeService.getListByTenant(tenantId);
+        if (CollectionUtils.isEmpty(dictTypes)){
+            return;
+        }
+        List<SysDictType> dictTypeList = dictTypes.stream().map(item -> {
+            item.setDictId(null);
+            item.setTenantId(newTenantId);
+            return item;
+        }).collect(Collectors.toList());
+        iSysDictTypeService.saveBatch(dictTypeList);
+        List<SysDictData> dictDatas = iSysDictDataService.getListByTenant(tenantId);
+        if (CollectionUtils.isEmpty(dictDatas)){
+            return;
+        }
+        for (SysDictData dictData : dictDatas) {
+            SysDictType dictType = iSysDictTypeService.getByIdTenant(dictData.getDictTypeId(),tenantId);
+            if (ObjectUtils.isNull(dictType)){
+                continue;
+            }
+            SysDictType dictType1 = dictTypeList.stream().filter(item -> item.getDictType().equals(dictType.getDictType())).findFirst().orElse(null);
+            if (ObjectUtils.isNull(dictType1)){
+                continue;
+            }
+            dictData.setDictCode(null);
+            dictData.setDictTypeId(dictType1.getDictId());
+            dictData.setTenantId(newTenantId);
+        }
+        iSysDictDataService.saveBatch(dictDatas);
+    }
+
+    @Override
+    public void updateRoleTenant(List<Long> tenantIds) {
+        Long oldTenantId = 867735392558919680L;
+        for (Long tenantId : tenantIds) {
+            initRoles(tenantId,oldTenantId);
+        }
+    }
+
+    private void initRoles(Long newTenantId,Long tenantId) {
+        List<String> roleKey = new ArrayList<>();
+        roleKey.add("seller");
+        roleKey.add("seller_admin");
+        roleKey.add("supervisory");
+        roleKey.add("cashier");
+        roleKey.add("accounting");
+        roleKey.add("boss");
+        roleKey.add("edu");
+        roleKey.forEach(key -> {
+            SysRole tenantRole  = roleService.getRoleByTenantKey(key,newTenantId);
+            if (ObjectUtils.isNull(tenantRole)){
+                //新增
+                SysRole role = roleService.getRoleByTenantKey(key, tenantId);
+                if (ObjectUtils.isNull(role)){
+                    return;
+                }
+                role.setRoleId(null);
+                role.setTenantId(newTenantId.toString());
+                roleService.save(role);
+                tenantRole  = role;
+            }
+            //角色菜单
+            SysRole oldRole = roleService.getRoleByTenantKey(tenantRole.getRoleKey(), tenantId);
+            List<SysRoleMenu> sysRoleMenus = sysRoleMenuMapper.listByTenant(oldRole.getRoleId(),tenantId);
+            if (CollectionUtils.isNotEmpty(sysRoleMenus)){
+                List<SysRoleMenu> roleMenus = new ArrayList<>();
+                for (SysRoleMenu menu : sysRoleMenus) {
+                    SysMenu oldSysMenu = menuService.getMenuById(menu.getMenuId(),tenantId);
+                    if (ObjectUtils.isNull(oldSysMenu)){
+                        continue;
+                    }
+                    Long menuId = menuService.getMenuByTenant(oldSysMenu.getMenuName(),oldSysMenu.getOrderNum(),DateUtils.formatDate(oldSysMenu.getCreateTime(),"yyyy-MM-dd HH:mm:ss"),newTenantId);
+                    if (ObjectUtils.isNull(menuId)){
+                        oldSysMenu.setMenuId(null);
+                        oldSysMenu.setTenantId(newTenantId);
+                        //查询父ID
+                        Long parentId = getParentId(oldSysMenu,tenantId,newTenantId);
+                        oldSysMenu.setParentId(parentId);
+                        menuService.save(oldSysMenu);
+                        menuId = oldSysMenu.getMenuId();
+                    }
+                    SysRoleMenu sysRoleMenu = new SysRoleMenu();
+                    sysRoleMenu.setRoleId(tenantRole.getRoleId());
+                    sysRoleMenu.setMenuId(menuId);
+                    sysRoleMenu.setTenantId(newTenantId.toString());
+                    roleMenus.add(sysRoleMenu);
+                }
+                if (CollectionUtils.isNotEmpty(roleMenus)){
+                    roleMenus.forEach(item -> {
+                        sysRoleMenuMapper.insert(item);
+                    });
+                }
+            }
+        });
+    }
+
+    private Long getParentId(SysMenu oldSysMenu, Long tenantId, Long newTenantId) {
+        if (oldSysMenu.getParentId() == 0){
+            return 0L;
+        }
+        SysMenu sysMenu = menuService.getMenuById(oldSysMenu.getParentId(),tenantId);
+        if (ObjectUtils.isNull(oldSysMenu)){
+            return 0L;
+        }
+        Long menuId = menuService.getMenuByTenant(sysMenu.getMenuName(),sysMenu.getOrderNum(),DateUtils.formatDate(sysMenu.getCreateTime(),"yyyy-MM-dd HH:mm:ss"),newTenantId);
+        if (ObjectUtils.isNull(menuId)){
+            oldSysMenu.setMenuId(null);
+            oldSysMenu.setTenantId(newTenantId);
+            //查询父ID
+            Long parentId = getParentId(sysMenu,tenantId,newTenantId);
+            oldSysMenu.setParentId(parentId);
+            menuService.save(oldSysMenu);
+            menuId = oldSysMenu.getMenuId();
+        }
+        return menuId;
+    }
+
 }

+ 21 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/bo/SysTenantAdminOldBo.java

@@ -0,0 +1,21 @@
+package com.zhongzheng.modules.system.bo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author yangdamao
+ * @date 2022年12月27日 9:44
+ */
+@Data
+public class SysTenantAdminOldBo implements Serializable {
+
+    @ApiModelProperty("机构名称")
+    private String tenantName;
+
+    @ApiModelProperty("机构ID")
+    private Long tenantId;
+
+}

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/domain/SysRoleMenu.java

@@ -25,4 +25,9 @@ public class SysRoleMenu {
      */
     private Long menuId;
 
+    /**
+     * 菜单ID
+     */
+    private String tenantId;
+
 }

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysDictDataMapper.java

@@ -1,7 +1,11 @@
 package com.zhongzheng.modules.system.mapper;
 
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zhongzheng.common.core.domain.entity.SysDictData;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 字典表 数据层
@@ -10,4 +14,6 @@ import com.zhongzheng.common.core.domain.entity.SysDictData;
  */
 public interface SysDictDataMapper extends BaseMapper<SysDictData> {
 
+    @InterceptorIgnore(tenantLine = "true")
+    List<SysDictData> getListByTenant(@Param("tenantId") Long tenantId);
 }

+ 9 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysDictTypeMapper.java

@@ -1,7 +1,11 @@
 package com.zhongzheng.modules.system.mapper;
 
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zhongzheng.common.core.domain.entity.SysDictType;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 字典表 数据层
@@ -10,4 +14,9 @@ import com.zhongzheng.common.core.domain.entity.SysDictType;
  */
 public interface SysDictTypeMapper extends BaseMapper<SysDictType> {
 
+    @InterceptorIgnore(tenantLine = "true")
+    List<SysDictType> getListByTenant(@Param("tenantId") Long tenantId);
+
+    @InterceptorIgnore(tenantLine = "true")
+    SysDictType getByIdTenant(@Param("dictId") Long dictId,@Param("tenantId") Long tenantId);
 }

+ 8 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysMenuMapper.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zhongzheng.common.core.domain.entity.SysMenu;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -66,4 +67,11 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
 
     @InterceptorIgnore(tenantLine = "true")
     Integer updateParentById(@Param("newMenus") SysMenu newMenus);
+
+    @InterceptorIgnore(tenantLine = "true")
+    SysMenu getMenuById(@Param("menuId") Long menuId,@Param("tenantId")  Long tenantId);
+
+    @InterceptorIgnore(tenantLine = "true")
+    Long getMenuByTenant(@Param("menuName")String menuName, @Param("orderNum") String orderNum, @Param("createTime") String createTime, @Param("newTenantId") Long newTenantId);
+
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysRoleMapper.java

@@ -1,7 +1,9 @@
 package com.zhongzheng.modules.system.mapper;
 
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zhongzheng.common.core.domain.entity.SysRole;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -38,4 +40,6 @@ public interface SysRoleMapper extends BaseMapper<SysRole> {
      */
     public List<SysRole> selectRolesByUserName(String userName);
 
+    @InterceptorIgnore(tenantLine = "true")
+    SysRole getRoleByTenantKey(@Param("key") String key,@Param("newTenantId") Long newTenantId);
 }

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysRoleMenuMapper.java

@@ -1,7 +1,11 @@
 package com.zhongzheng.modules.system.mapper;
 
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zhongzheng.modules.system.domain.SysRoleMenu;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 角色与菜单关联表 数据层
@@ -10,4 +14,6 @@ import com.zhongzheng.modules.system.domain.SysRoleMenu;
  */
 public interface SysRoleMenuMapper extends BaseMapper<SysRoleMenu> {
 
+    @InterceptorIgnore(tenantLine = "true")
+    List<SysRoleMenu> listByTenant(@Param("roleId") Long roleId,@Param("tenantId") Long tenantId);
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysDictDataService.java

@@ -61,4 +61,6 @@ public interface ISysDictDataService extends IService<SysDictData> {
     public int updateDictData(SysDictData dictData);
 
     Long selectDictLabelType(String company_type, String toString);
+
+    List<SysDictData> getListByTenant(Long tenantId);
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysDictTypeService.java

@@ -87,4 +87,8 @@ public interface ISysDictTypeService extends IService<SysDictType> {
      * @return 结果
      */
     public String checkDictTypeUnique(SysDictType dictType);
+
+    List<SysDictType> getListByTenant(Long tenantId);
+
+    SysDictType getByIdTenant(Long dictId, Long tenantId);
 }

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysMenuService.java

@@ -5,6 +5,7 @@ import com.zhongzheng.common.core.domain.TreeSelect;
 import com.zhongzheng.common.core.domain.entity.SysMenu;
 import com.zhongzheng.modules.system.domain.vo.RouterVo;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Set;
 
@@ -138,4 +139,9 @@ public interface ISysMenuService extends IService<SysMenu> {
     List<SysMenu> listSysMenuByTenant(Long tenantId);
 
     Integer updateParentById(SysMenu newMenus);
+
+    SysMenu getMenuById(Long menuId, Long tenantId);
+
+    Long getMenuByTenant(String menuName, String orderNum, String createTime, Long newTenantId);
+
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysRoleService.java

@@ -131,4 +131,6 @@ public interface ISysRoleService extends IService<SysRole> {
     public int deleteRoleByIds(Long[] roleIds);
 
     SysRole getOneSysRole(String sellerAdmin, Long id);
+
+    SysRole getRoleByTenantKey(String key, Long newTenantId);
 }

+ 4 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysTenantService.java

@@ -2,10 +2,7 @@ package com.zhongzheng.modules.system.service;
 
 
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.zhongzheng.modules.system.bo.SysTenantAddBo;
-import com.zhongzheng.modules.system.bo.SysTenantAdminBo;
-import com.zhongzheng.modules.system.bo.SysTenantEditBo;
-import com.zhongzheng.modules.system.bo.SysTenantQueryBo;
+import com.zhongzheng.modules.system.bo.*;
 import com.zhongzheng.modules.system.domain.SysTenant;
 import com.zhongzheng.modules.system.vo.SysTenantVo;
 
@@ -58,4 +55,7 @@ public interface ISysTenantService extends IService<SysTenant> {
 
     List<SysTenant> getListSysTenant();
 
+    void createTenantAdminOld(SysTenantAdminOldBo bo);
+
+    void updateRoleTenant(List<Long> tenantIds);
 }

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/impl/SysDictDataServiceImpl.java

@@ -127,6 +127,11 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
                 .getDictCode();
     }
 
+    @Override
+    public List<SysDictData> getListByTenant(Long tenantId) {
+        return baseMapper.getListByTenant(tenantId);
+    }
+
     /**
      * 保存前的数据校验
      *

+ 10 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/impl/SysDictTypeServiceImpl.java

@@ -209,4 +209,14 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
         }
         return UserConstants.UNIQUE;
     }
+
+    @Override
+    public List<SysDictType> getListByTenant(Long tenantId) {
+        return baseMapper.getListByTenant(tenantId);
+    }
+
+    @Override
+    public SysDictType getByIdTenant(Long dictId, Long tenantId) {
+        return baseMapper.getByIdTenant(dictId, tenantId);
+    }
 }

+ 10 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/impl/SysMenuServiceImpl.java

@@ -299,6 +299,16 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
         return baseMapper.updateParentById(newMenus);
     }
 
+    @Override
+    public SysMenu getMenuById(Long menuId, Long tenantId) {
+        return baseMapper.getMenuById(menuId, tenantId);
+    }
+
+    @Override
+    public Long getMenuByTenant(String menuName, String orderNum,String createTime, Long newTenantId) {
+        return baseMapper.getMenuByTenant(menuName, orderNum,createTime, newTenantId);
+    }
+
     /**
      * 获取路由名称
      *

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/impl/SysRoleServiceImpl.java

@@ -368,4 +368,9 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
                 .eq(SysRole::getTenantId,id)
                 .eq(SysRole::getStatus, 1).last("limit 1"));
     }
+
+    @Override
+    public SysRole getRoleByTenantKey(String key, Long newTenantId) {
+        return baseMapper.getRoleByTenantKey(key, newTenantId);
+    }
 }

+ 3 - 16
zhongzheng-system/src/main/resources/mapper/modules/system/SysDictDataMapper.xml

@@ -4,21 +4,8 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.zhongzheng.modules.system.mapper.SysDictDataMapper">
 
-    <resultMap type="SysDictData" id="SysDictDataResult">
-        <id property="dictCode" column="dict_code"/>
-        <result property="dictSort" column="dict_sort"/>
-        <result property="dictLabel" column="dict_label"/>
-        <result property="dictValue" column="dict_value"/>
-        <result property="dictType" column="dict_type"/>
-        <result property="cssClass" column="css_class"/>
-        <result property="listClass" column="list_class"/>
-        <result property="isDefault" column="is_default"/>
-        <result property="status" column="status"/>
-        <result property="createBy" column="create_by"/>
-        <result property="createTime" column="create_time"/>
-        <result property="updateBy" column="update_by"/>
-        <result property="updateTime" column="update_time"/>
-        <result property="dictTypeId" column="dict_type_id"/>
-    </resultMap>
+    <select id="getListByTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.common.core.domain.entity.SysDictData">
+        SELECT * FROM sys_dict_data WHERE tenant_id = #{tenantId}
+    </select>
 
 </mapper>

+ 7 - 10
zhongzheng-system/src/main/resources/mapper/modules/system/SysDictTypeMapper.xml

@@ -4,15 +4,12 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.zhongzheng.modules.system.mapper.SysDictTypeMapper">
 
-    <resultMap type="SysDictType" id="SysDictTypeResult">
-        <id property="dictId" column="dict_id"/>
-        <result property="dictName" column="dict_name"/>
-        <result property="dictType" column="dict_type"/>
-        <result property="status" column="status"/>
-        <result property="createBy" column="create_by"/>
-        <result property="createTime" column="create_time"/>
-        <result property="updateBy" column="update_by"/>
-        <result property="updateTime" column="update_time"/>
-    </resultMap>
+    <select id="getListByTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.common.core.domain.entity.SysDictType">
+        SELECT * FROM sys_dict_type WHERE tenant_id = #{tenantId}
+    </select>
+
+    <select id="getByIdTenant" parameterType="map" resultType="com.zhongzheng.common.core.domain.entity.SysDictType">
+        SELECT * FROM sys_dict_type WHERE dict_id = #{dictId} and tenant_id = #{tenantId}
+    </select>
 
 </mapper>

+ 8 - 0
zhongzheng-system/src/main/resources/mapper/modules/system/SysMenuMapper.xml

@@ -155,4 +155,12 @@
           and ur.user_id = #{userId}
     </select>
 
+    <select id="getMenuById" parameterType="map" resultType="com.zhongzheng.common.core.domain.entity.SysMenu">
+        SELECT * FROM sys_menu WHERE menu_id = #{menuId} AND tenant_id = #{tenantId}
+    </select>
+
+    <select id="getMenuByTenant" parameterType="map" resultType="java.lang.Long">
+        SELECT menu_id FROM sys_menu WHERE menu_name = #{menuName} AND `order_num` = #{orderNum} AND create_time = #{createTime} AND tenant_id = #{newTenantId} limit 1
+    </select>
+
 </mapper>

+ 4 - 0
zhongzheng-system/src/main/resources/mapper/modules/system/SysRoleMapper.xml

@@ -57,4 +57,8 @@
         WHERE r.del_flag = '0' and u.user_name = #{userName}
     </select>
 
+    <select id="getRoleByTenantKey" parameterType="map" resultType="com.zhongzheng.common.core.domain.entity.SysRole">
+        SELECT * FROM sys_role WHERE role_key = #{key} AND tenant_id =#{newTenantId}
+    </select>
+
 </mapper>

+ 4 - 4
zhongzheng-system/src/main/resources/mapper/modules/system/SysRoleMenuMapper.xml

@@ -4,9 +4,9 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.zhongzheng.modules.system.mapper.SysRoleMenuMapper">
 
-    <resultMap type="SysRoleMenu" id="SysRoleMenuResult">
-        <result property="roleId" column="role_id"/>
-        <result property="menuId" column="menu_id"/>
-    </resultMap>
+    <select id="listByTenant" parameterType="map" resultType="com.zhongzheng.modules.system.domain.SysRoleMenu">
+        SELECT * FROM sys_role_menu WHERE role_id = #{roleId} AND tenant_id = #{tenantId}
+    </select>
+
 
 </mapper>