|
@@ -2,12 +2,11 @@ package org.jeecg.modules.system.service.impl;
|
|
|
|
|
|
//import bp.wf.Dev2Interface;
|
|
|
import java.lang.reflect.Field;
|
|
|
-
|
|
|
-import bp.wf.Dev2Interface;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import org.apache.http.HttpRequest;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
+import org.jeecg.common.api.dto.message.TemplateMessageDTO;
|
|
|
import org.jeecg.common.config.mqtoken.UserTokenContext;
|
|
|
import org.jeecg.common.constant.CommonConstant;
|
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
@@ -39,6 +38,10 @@ import org.apache.commons.beanutils.BeanUtils;
|
|
|
@Service
|
|
|
public class AppmanageServiceImpl implements AppmanageService {
|
|
|
|
|
|
+ // 发送消息
|
|
|
+ @Autowired
|
|
|
+ private SysBaseApiImpl sysBaseApi;
|
|
|
+
|
|
|
// 简单查询用户信息
|
|
|
@Autowired
|
|
|
private ISysUserService sysUserService;
|
|
@@ -89,6 +92,9 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
@Autowired
|
|
|
private RedisUtil redisUtil;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AppManageUtil appManageUtil;
|
|
|
+
|
|
|
@Autowired
|
|
|
private WorkFlowClient workFlowClient;
|
|
|
|
|
@@ -458,7 +464,7 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
AppBaseInfo appBaseInfo = baseInfoMapper.selectById(queryParams.getAppid());
|
|
|
// 查询用户角色信息
|
|
|
appUserInfos.forEach(map -> {
|
|
|
- String roleNameInfo = baseInfoToUserInfoRoles(appBaseInfo, (String) map.get("id"));
|
|
|
+ String roleNameInfo = appManageUtil.baseInfoToUserInfoRoles(appBaseInfo, (String) map.get("id"));
|
|
|
List<String> roleIds = sysUserRoleService.listByAppId(queryParams.getAppid(), (String) map.get("id"));
|
|
|
|
|
|
if (!roleIds.isEmpty()){
|
|
@@ -607,42 +613,6 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private String baseInfoToUserInfoRoles(AppBaseInfo appBaseInfo, String userid){
|
|
|
- String roleNameInfo = "";
|
|
|
- if (appBaseInfo.getAdmin()!=null&&appBaseInfo.getAdmin().equals(userid)){
|
|
|
- roleNameInfo = "应用管理员";
|
|
|
- }
|
|
|
- if (appBaseInfo.getDevelopUser()!=null&&appBaseInfo.getDevelopUser().equals(userid)){
|
|
|
- if (roleNameInfo.isEmpty()){
|
|
|
- roleNameInfo = "开发负责人";
|
|
|
- }else {
|
|
|
- roleNameInfo = roleNameInfo+", "+"开发负责人";
|
|
|
- }
|
|
|
- }
|
|
|
- if (appBaseInfo.getOperationUser()!=null&&appBaseInfo.getOperationUser().equals(userid)){
|
|
|
- if (roleNameInfo.isEmpty()){
|
|
|
- roleNameInfo = "运维负责人";
|
|
|
- }else {
|
|
|
- roleNameInfo = roleNameInfo+","+"运维负责人";
|
|
|
- }
|
|
|
- }
|
|
|
- if(appBaseInfo.getBusinessUser()!=null&&appBaseInfo.getBusinessUser().equals(userid)){
|
|
|
- if (roleNameInfo.isEmpty()){
|
|
|
- roleNameInfo = "业务对接人";
|
|
|
- }else {
|
|
|
- roleNameInfo = roleNameInfo+","+"业务对接人";
|
|
|
- }
|
|
|
- }
|
|
|
- if(appBaseInfo.getRequirementUser()!=null&&appBaseInfo.getRequirementUser().equals(userid)){
|
|
|
- if (roleNameInfo.isEmpty()){
|
|
|
- roleNameInfo = "需求对接人";
|
|
|
- }else {
|
|
|
- roleNameInfo = roleNameInfo+","+"需求对接人";
|
|
|
- }
|
|
|
- }
|
|
|
- return roleNameInfo;
|
|
|
- }
|
|
|
-
|
|
|
// 加入流程
|
|
|
private <T> void sendCheckWordFlow(T object, String flowNo, String username) throws Exception {
|
|
|
Hashtable<String, String> hashtable = new Hashtable<>();
|
|
@@ -664,14 +634,9 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
throw new RuntimeException("Failed to access field: " + field.getName(), e);
|
|
|
}
|
|
|
}
|
|
|
-// 直接系统调用
|
|
|
-// Dev2Interface dev2Interface = new Dev2Interface();
|
|
|
-// long workID = dev2Interface.Node_CreateBlankWork(flowNo, username);
|
|
|
-// if (hashtable.size() > 0) {
|
|
|
-// dev2Interface.Node_SendWork(flowNo, workID, hashtable);
|
|
|
-// }
|
|
|
|
|
|
-// 微服务调用
|
|
|
+
|
|
|
+// 微服务调用 审核加入流程
|
|
|
workFlowClient.startFlow(flowNo, username, hashtable);
|
|
|
}
|
|
|
|
|
@@ -686,51 +651,65 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
return loginUser.getId().equals(baseInfo.getAdmin());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
// 应用审核通过后一系列创建应用一级菜单、默认角色、授权操作(完整注册时)
|
|
|
public void afterAppCheckPass(String appid) {
|
|
|
- AppBaseInfo appBaseInfo = baseInfoMapper.selectById(appid);
|
|
|
-
|
|
|
- // 添加默认角色信息
|
|
|
- SysRole role = new SysRole();
|
|
|
- role.setAppId(appid); // 设置角色所属应用信息
|
|
|
- role.setRoleCode("default"); // 设置角色编码
|
|
|
- role.setAppName(appBaseInfo.getName()) ; // 设置角色的应用名称
|
|
|
- role.setRoleName(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 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(),"");
|
|
|
+ System.out.println("审核完成后续处理:"+appid);
|
|
|
+ // 将基础信息删除标志位恢复
|
|
|
+ baseInfoMapper.recoverAppInfo(appid);
|
|
|
+ // 查询该应用信息
|
|
|
+ AppBaseInfo appBaseInfo = baseInfoMapper.selectById(appid);
|
|
|
+ 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","通过");
|
|
|
+ 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()+"_默认用户角色"); // 设置角色名
|
|
|
+ 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 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(),"");
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
-// // 根据用户id查询用户姓名,先从redis数据库中查询,若没有再从数据库中查询
|
|
|
-// private String queryUserNameByUserId(String userid){
|
|
|
-//
|
|
|
-// }
|
|
|
}
|