Przeglądaj źródła

机构账号开通部分代码修改

hgw 3 lat temu
rodzic
commit
dbbe82403f

+ 7 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantInfoServiceImpl.java

@@ -253,7 +253,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
         RBucket<Object> bucket = redissonClient.getBucket(key);
         //原子操作 抢锁成功为true
         if (!bucket.trySet(tenantId, 3L, TimeUnit.MINUTES)) {
-            throw new BizException("机构正在开通中请勿频繁操作");
+            throw new BizException("机构正在开通中请勿频繁操作");
         }
         //获取产品信息得到服务id
         TenantProductInfo productInfo = tenantProductInfoService.getOne(new WrapperUtil<TenantProductInfo>()
@@ -269,7 +269,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
         //拆分菜单获取菜单ID
         List<Integer> collectMenuId = getMenuId(menuIdList);
         //建立角色
-        Integer roleId = createRole(tenantId);
+        Integer roleId = createRole(tenantInfo);
         //建立角色和菜单关系数据
         employeeService.batchInsertRoleMenu(roleId, collectMenuId);
         // 创建账号、用户信息、用户和角色关系
@@ -287,13 +287,15 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
     }
 
     //创建角色
-    private Integer createRole(Integer tenantId) {
+    private Integer createRole(TenantInfo tenantInfo) {
         SysRole sysRole = new SysRole();
         sysRole.setRoleName("管理员");
         sysRole.setRoleDesc("管理员");
         sysRole.setCreateTime(new Date());
         sysRole.setDelFlag("0");
-        sysRole.setTenantId(tenantId);
+        sysRole.setTenantId(tenantInfo.getId());
+        Organization organization = organizationDao.getByName(tenantInfo.getName(), tenantInfo.getId());
+        sysRole.setOrganId(organization.getId());
         employeeService.insertSysRole(sysRole);
         return sysRole.getId();
     }
@@ -306,6 +308,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
         e.setJobNature(JobNatureEnum.FULL_TIME);
         e.setEntryDate(LocalDate.now().toDate());
         e.setRoles(roles);
+        e.setRoleIds(roles);
         try {
             employeeService.add(e);
         } catch (Exception ex) {

+ 2 - 2
mec-biz/src/main/resources/config/mybatis/EmployeeMapper.xml

@@ -94,8 +94,8 @@
             useGeneratedKeys="true">
         INSERT INTO `sys_role` (`role_name_`, `role_code_`, `role_desc_`, `create_time_`,
                                 `update_time_`, `del_flag_`, `organ_id_`, `tenant_id_`)
-        VALUES (#{RoleName}, #{RoleCode}, #{RoleDesc}, #{CreateTime},
-                #{UpdateTime}, #{DelFlag}, #{OrganId}, #{TenantId});
+        VALUES (#{roleName}, #{roleCode}, #{roleDesc}, #{createTime},
+                #{updateTime}, #{delFlag}, #{organId}, #{tenantId});
     </insert>
 
     <select id="queryByPhone" resultMap="SysUser">