Ver código fonte

Merge remote-tracking branch 'origin/dev' into dev

LT32820A 3 semanas atrás
pai
commit
dcec7eabc5

+ 1 - 0
jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java

@@ -92,6 +92,7 @@ public interface CommonConstant {
     public static String PREFIX_USER_SHIRO_CACHE  = "shiro:cache:org.jeecg.config.shiro.ShiroRealm.authorizationCache:";
     /** 登录用户Token令牌缓存KEY前缀 */
     String PREFIX_USER_TOKEN  = "prefix_user_token:";
+   	String PREFIX_JFLOWUSER_TOKEN  = "prefix_jflowuser_token:";
 //    /** Token缓存时间:3600秒即一小时 */
 //    int  TOKEN_EXPIRE_TIME  = 3600;
 

+ 2 - 1
jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/filters/JwtFilter.java

@@ -72,7 +72,8 @@ public class JwtFilter extends BasicHttpAuthenticationFilter {
         }
         if (token.equals("undefined")){
             // 连接到本地Redis服务
-            Jedis jedis = new Jedis("localhost", 6379);
+            Jedis jedis = new Jedis("10.200.1.115", 6379);
+          	jedis.auth("Lttc123!");
             String Token = httpServletRequest.getParameter("Token");
             token = jedis.get(CommonConstant.PREFIX_JFLOWUSER_TOKEN+Token);
             token = token.replaceAll("^\"|\"$", "");

+ 1 - 1
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/entity/AppmanageEntity/AppBaseInfo.java

@@ -39,7 +39,7 @@ public class AppBaseInfo {
     private String createBy;
     private String createTime;
     private String addType;
-    private int info_status;
+    private int infoStatus;
     @TableLogic
     private int delFlag;
     // 用于当前用户是否可以编辑该条信息

+ 16 - 6
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/AppCustomMapper.java

@@ -1,9 +1,6 @@
 package org.jeecg.modules.system.mapper;
 
-import org.apache.ibatis.annotations.Delete;
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.*;
 import org.jeecg.modules.system.entity.AppmanageEntity.AppBaseInfo;
 import org.jeecg.modules.system.entity.AppmanageEntity.AppUserInfo;
 import org.jeecg.modules.system.entity.SysPermission;
@@ -20,9 +17,9 @@ public interface AppCustomMapper {
             "WHERE role_id IN (",
             "    SELECT id",
             "    FROM sys_role",
-            "    WHERE role_name = #{roleName}  and app_id = 0)"
+            "    WHERE role_code = 'basisPlatform_appAdmin')"
     })
-    List<String> queryUseridByAppAdminRole(@Param("roleName") String roleName);
+    List<String> queryUseridByAppAdminRole();
 
     // 通过用户id查询用户账号
     @Select("SELECT username FROM sys_user WHERE id = #{userId}")
@@ -74,4 +71,17 @@ public interface AppCustomMapper {
     // 通过应用id获取该应用注册类型
     @Select("SELECT add_type FROM app_base_info WHERE id = #{appid}")
     String queryAppRegisterTypeByAppid(@Param("appid") String appid);
+
+    // 添加应用后同步数据给Jflow的角色表
+    @Insert("INSERT INTO port_stationtype(No, Name, Idx) VALUES(#{appid},#{name},0)")
+    void addRoleToPortstationtype(@Param("appid") String id, @Param("name") String Name);
+
+    // 删除应用后同步数据给Jflow的角色表
+    @Delete("delete from port_stationtype where No = #{id}")
+    void deleteRoleFromPortstationtype(@Param("id") String id);
+
+    // 修改应用后同步数据给Jflow的角色表
+    @Update("UPDATE port_stationtype SET Name = #{appName} WHERE No = #{id}")
+    void updateRoleToPortstationtype(@Param("id") String id, @Param("appName") String Name);
+
 }

+ 71 - 66
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/AppmanageServiceImpl.java

@@ -232,7 +232,9 @@ public class AppmanageServiceImpl implements AppmanageService {
                     System.out.println("删除应用下角色失败:"+e);
                 }
             }
+            customMapper.deleteRoleFromPortstationtype(id);
         }
+
         // 记录日志
         baseCommonService.addLog("删除应用信息:id"+Arrays.toString(ids), CommonConstant.LOG_TYPE_2, 3 );
         return true;
@@ -245,8 +247,8 @@ public class AppmanageServiceImpl implements AppmanageService {
      */
     @Override
     public Boolean editBaseInfo(AppBaseInfo baseInfo) {
-
         int i = baseInfoMapper.updateById(baseInfo);
+        customMapper.updateRoleToPortstationtype(baseInfo.getId(), baseInfo.getName());
         // 保存成功解除反审核状态
         if (i>0) uncheckLock("AppbaseInfo"+baseInfo.getId());
         return i>0;
@@ -607,7 +609,7 @@ public class AppmanageServiceImpl implements AppmanageService {
     public boolean isAppAdmin() {
         // 获取当前登录用户
         LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        List<String> userids = customMapper.queryUseridByAppAdminRole("应用管理员");
+        List<String> userids = customMapper.queryUseridByAppAdminRole();
         return userids.stream().anyMatch(userid -> userid.equals(loginUser.getId()));
     }
 
@@ -670,71 +672,74 @@ public class AppmanageServiceImpl implements AppmanageService {
 
     // 应用审核通过后续处理
     public <T> void afterAppCheckPass(String appid, T formData) {
-        AppBaseInfo appBaseInfo = baseInfoMapper.queryAppBaseInfoById(appid);
-        appManageUtil.CompareOldAppBaseInfoAndNewAppBaseInfo(appBaseInfo, formData);
-        // 以通过审批的应用信息为准更新应用信息
-        int i = baseInfoMapper.updateBaseInfo(appBaseInfo);
-        // 查询该应用信息
-
-        String toUser = baseInfoMapper.queryUsernameById(appBaseInfo.getCreateBy());
-        //给申请注册应用信息的用户发送系统消息
-        TemplateMessageDTO message = new TemplateMessageDTO();
-        message.setAppId("0");
-        message.setToUser(toUser);
-        // 设置消息模板编码
-        message.setTemplateCode("app_examineAndapprove");
-        Map<String, String> templateParam = new HashMap<>();
-        templateParam.put("resultText","应用"+appBaseInfo.getName()+"注册审核通过");
-        message.setTemplateParam(templateParam);
-        sysBaseApi.sendTemplateAnnouncement(message);
-
-
-        // 该信息为完整注册时,通过审核后添加默认角色、菜单权限、菜单信息
-        if (appBaseInfo.getAddType().equals("full")){
-            // 添加默认角色信息
-            SysRole role = new SysRole();
-            role.setAppId(appid);  // 设置角色所属应用信息
-            role.setRoleCode("default");  // 设置角色编码
-            role.setAppName(appBaseInfo.getName()) ;  // 设置角色的应用名称
-            role.setRoleName(appBaseInfo.getName()+"_默认用户角色");  // 设置角色名
-            role.setDescription(appBaseInfo.getName()+"默认角色");  // 设置备注
-            sysRoleService.save(role);  // 添加角色
-
-            // 获取角色编码
-            String roleid = role.getId();
-
-            // 查询应用用户id集合
-            QueryWrapper<AppUserInfo> appUserInfoQueryWrapper = new QueryWrapper<>();
-            appUserInfoQueryWrapper.select("userid").eq("appid", appid);
-            List<AppUserInfo> appUserInfos = userInfoMapper.selectList(appUserInfoQueryWrapper);
-            List<String> useridlist = appUserInfos.stream().map(AppUserInfo::getUserid).collect(Collectors.toList());
-
-            // 应用默认角色分配给应用用户
-            SysUserRoleVO sysUserRoleVO = new SysUserRoleVO();
-            sysUserRoleVO.setRoleId(roleid);
-            sysUserRoleVO.setUserIdList(useridlist);
-            sysUserController.addSysUserRole(sysUserRoleVO);
-
-            // 创建该应用的一级菜单
-            // 首先判断菜单是否已存在
-            SysPermission hassysPermission = customMapper.queryUrlByUrl(appBaseInfo.getMenuInfo());
-            if (hassysPermission == null){
-                SysPermission sysPermission = new SysPermission();
-                sysPermission.setName(appBaseInfo.getName());
-                sysPermission.setAppId(appid);
-                sysPermission.setUrl(appBaseInfo.getMenuInfo());
-                // 设置组件(即 菜单路径去掉第一个 "/")
-                String component = sysPermission.getUrl().replaceFirst("^/", "");
-                sysPermission.setComponent(component);
-                sysPermission.setMenuType(0);
-                sysPermission.setRoute(true);
-                sysPermissionService.addPermission(sysPermission);
-                // 授予应用默认角色访问一级菜单权限
-                sysRolePermissionService.saveRolePermission(roleid, sysPermission.getId(),"");
-            }else {
-                // 授予应用默认角色访问一级菜单权限
-                sysRolePermissionService.saveRolePermission(roleid, hassysPermission.getId(),"");
+
+        try {
+            AppBaseInfo appBaseInfo = baseInfoMapper.queryAppBaseInfoById(appid);
+            appManageUtil.CompareOldAppBaseInfoAndNewAppBaseInfo(appBaseInfo, formData);
+            // 以通过审批的应用信息为准更新应用信息
+            int i = baseInfoMapper.updateBaseInfo(appBaseInfo);
+            String toUser = baseInfoMapper.queryUsernameById(appBaseInfo.getCreateBy());
+            //给申请注册应用信息的用户发送系统消息
+            TemplateMessageDTO message = new TemplateMessageDTO();
+            message.setAppId("0");
+            message.setToUser(toUser);
+            // 设置消息模板编码
+            message.setTemplateCode("app_examineAndapprove");
+            Map<String, String> templateParam = new HashMap<>();
+            templateParam.put("resultText","应用"+appBaseInfo.getName()+"注册审核通过");
+            message.setTemplateParam(templateParam);
+            sysBaseApi.sendTemplateAnnouncement(message);
+
+            // 该信息为完整注册时,通过审核后添加默认角色、菜单权限、菜单信息
+            if (appBaseInfo.getAddType().equals("full")){
+                // 将通过完整注册的应用信息同步给JFlow的角色分类表
+                customMapper.addRoleToPortstationtype(appid, appBaseInfo.getName());
+                // 添加默认角色信息
+                SysRole role = new SysRole();
+                role.setAppId(appid);  // 设置角色所属应用信息
+                role.setRoleCode("default");  // 设置角色编码
+                role.setAppName(appBaseInfo.getName()) ;  // 设置角色的应用名称
+                role.setRoleName(appBaseInfo.getName()+"_默认用户角色");  // 设置角色名
+                role.setDescription(appBaseInfo.getName()+"默认角色");  // 设置备注
+                sysRoleService.save(role);  // 添加角色
+
+                // 获取角色编码
+                String roleid = role.getId();
+
+                // 查询应用用户id集合
+                QueryWrapper<AppUserInfo> appUserInfoQueryWrapper = new QueryWrapper<>();
+                appUserInfoQueryWrapper.select("userid").eq("appid", appid);
+                List<AppUserInfo> appUserInfos = userInfoMapper.selectList(appUserInfoQueryWrapper);
+                List<String> useridlist = appUserInfos.stream().map(AppUserInfo::getUserid).collect(Collectors.toList());
+
+                // 应用默认角色分配给应用用户
+                SysUserRoleVO sysUserRoleVO = new SysUserRoleVO();
+                sysUserRoleVO.setRoleId(roleid);
+                sysUserRoleVO.setUserIdList(useridlist);
+                sysUserController.addSysUserRole(sysUserRoleVO);
+
+                // 创建该应用的一级菜单
+                SysPermission hassysPermission = customMapper.queryUrlByUrl(appBaseInfo.getMenuInfo());
+                if (hassysPermission == null){
+                    SysPermission sysPermission = new SysPermission();
+                    sysPermission.setName(appBaseInfo.getName());
+                    sysPermission.setAppId(appid);
+                    sysPermission.setUrl(appBaseInfo.getMenuInfo());
+                    // 设置组件(即 菜单路径去掉第一个 "/")
+                    String component = sysPermission.getUrl().replaceFirst("^/", "");
+                    sysPermission.setComponent(component);
+                    sysPermission.setMenuType(0);
+                    sysPermission.setRoute(true);
+                    sysPermissionService.addPermission(sysPermission);
+                    // 授予应用默认角色访问一级菜单权限
+                    sysRolePermissionService.saveRolePermission(roleid, sysPermission.getId(),"");
+                }else {
+                    // 授予应用默认角色访问一级菜单权限
+                    sysRolePermissionService.saveRolePermission(roleid, hassysPermission.getId(),"");
+                }
             }
+        }catch (Exception e){
+            System.out.println("应用审核通过后续处理错误:"+e);
         }
     }
 

+ 1 - 1
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/util/AppManageUtil.java

@@ -196,6 +196,6 @@ public class AppManageUtil {
         }
         // 将删除标志位恢复为 0,信息状态位变更为 1:已审核状态
         appBaseInfo.setDelFlag(0);
-        appBaseInfo.setInfo_status(1);
+        appBaseInfo.setInfoStatus(1);
     }
 }

+ 2 - 2
jeecg-boot/jeecg-server-cloud/jflow-cloud-start/src/main/java/org/jeecg/config/DevelopAPI.java

@@ -108,13 +108,13 @@ public class DevelopAPI extends HttpHandlerBase {
         try {
             String Token = "";
             if (SystemConfig.getCCBPMRunModel() == CCBPMRunModel.SAAS) {
-                Dev2Interface.Port_Login(userNo, orgNo, null, jeecgToken);
+                Dev2Interface.Port_Login(userNo, orgNo, null);
                 Token = Dev2Interface.Port_GenerToken(userNo);
                 redisUtil.set("prefix_jflowuser_token:"+Token, jeecgToken, 3600 * 24 * 7);
             } else {
                 Token = Dev2Interface.Port_GenerToken(userNo);
                 redisUtil.set("prefix_jflowuser_token:"+Token, jeecgToken, 3600 * 24 * 7);
-                Dev2Interface.Port_Login(userNo, orgNo, null, jeecgToken);
+                Dev2Interface.Port_Login(userNo, orgNo, null);
             }
             Hashtable ht = new Hashtable();
             ht.put("No", WebUser.getNo());