|
@@ -3,6 +3,7 @@ package org.jeecg.modules.system.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
+import org.checkerframework.checker.units.qual.A;
|
|
|
import org.jeecg.common.api.dto.message.TemplateMessageDTO;
|
|
|
import org.jeecg.common.constant.CommonConstant;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
@@ -10,6 +11,7 @@ import org.jeecg.common.system.vo.LoginUser;
|
|
|
import org.jeecg.common.util.RedisUtil;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecg.modules.base.service.BaseCommonService;
|
|
|
+import org.jeecg.modules.jmreport.common.util.DateUtils;
|
|
|
import org.jeecg.modules.system.controller.SysUserController;
|
|
|
import org.jeecg.modules.system.entity.*;
|
|
|
import org.jeecg.modules.system.entity.AppmanageEntity.*;
|
|
@@ -53,6 +55,10 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
@Autowired
|
|
|
private ISysRolePermissionService sysRolePermissionService;
|
|
|
|
|
|
+ // 给用户授权用
|
|
|
+ @Autowired
|
|
|
+ private ISysUserPermissionService sysUserPermissionService;
|
|
|
+
|
|
|
// 添加菜单用
|
|
|
@Autowired
|
|
|
private ISysPermissionService sysPermissionService;
|
|
@@ -112,20 +118,9 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
appBaseInfo.setCreateBy(loginUser.getId());
|
|
|
appBaseInfo.setAddType(appInfo.getAddType());
|
|
|
- appBaseInfo.setDelFlag(1);
|
|
|
+ appBaseInfo.setDelFlag(0);
|
|
|
baseInfoMapper.insert(appBaseInfo);
|
|
|
|
|
|
- // 提交至工作流的表单信息(将用户id换成用户账账号)
|
|
|
- AppBaseInfo sendCheck_appBaseInfo = appBaseInfo;
|
|
|
- sendCheck_appBaseInfo.setAdmin(customMapper.queryUsernameByUserId(appBaseInfo.getAdmin()));
|
|
|
- if (appBaseInfo.getDevelopUser()!=null)
|
|
|
- sendCheck_appBaseInfo.setDevelopUser(customMapper.queryUsernameByUserId(appBaseInfo.getDevelopUser()));
|
|
|
- if (appBaseInfo.getOperationUser()!=null)
|
|
|
- sendCheck_appBaseInfo.setOperationUser(customMapper.queryUsernameByUserId(appBaseInfo.getOperationUser()));
|
|
|
- if (appBaseInfo.getRequirementUser()!=null)
|
|
|
- sendCheck_appBaseInfo.setRequirementUser(customMapper.queryUsernameByUserId(appBaseInfo.getRequirementUser()));
|
|
|
- if (appBaseInfo.getBusinessUser()!=null)
|
|
|
- sendCheck_appBaseInfo.setBusinessUser(customMapper.queryUsernameByUserId(appBaseInfo.getBusinessUser()));
|
|
|
AppDocInfo appDocInfo = appInfo.getAppDocInfoDTO();
|
|
|
boolean hasEnvInfo = false;
|
|
|
if (appInfo.getAppEnvInfoDTO()!=null) hasEnvInfo = appInfo.getAppEnvInfoDTO().size()>0;
|
|
@@ -133,7 +128,7 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
String appid = appBaseInfo.getId();
|
|
|
// 简易注册模式下添加基础信息即可
|
|
|
if (appBaseInfo.getAddType().equals("easy")){
|
|
|
- tag = appManageUtil.sendCheckWordFlow(sendCheck_appBaseInfo, "021", loginUser.getUsername(), "admin");
|
|
|
+ tag = appManageUtil.sendCheckWordFlow(appBaseInfo, "021", loginUser.getUsername(), "admin");
|
|
|
// 发起流程失败则删除数据库内数据
|
|
|
if (!tag){
|
|
|
customMapper.deleteAppBaseInfoNotLogic(appid);
|
|
@@ -143,7 +138,7 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
APP_Register_workFlow_FormEntity appRegisterWorkFlowFormEntity = new APP_Register_workFlow_FormEntity();
|
|
|
BeanUtils.copyProperties(appRegisterWorkFlowFormEntity, appDocInfo);
|
|
|
// 基础信息最后一个复制,避免id为null
|
|
|
- BeanUtils.copyProperties(appRegisterWorkFlowFormEntity, sendCheck_appBaseInfo);
|
|
|
+ BeanUtils.copyProperties(appRegisterWorkFlowFormEntity, appBaseInfo);
|
|
|
if (hasEnvInfo){
|
|
|
AppManageUtil appManageUtil = new AppManageUtil();
|
|
|
appRegisterWorkFlowFormEntity = appManageUtil.TransitionEnvInfoToAppRegisterWorkFlowForm(appRegisterWorkFlowFormEntity, appInfo.getAppEnvInfoDTO());
|
|
@@ -191,14 +186,14 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public Boolean deleteAppInfo(String[] ids) {
|
|
|
- // 需先判断用户是否拥有所删除的应用信息的权限(平台管理员-应用管理员)
|
|
|
+ // 需先判断用户是否拥有所删除的应用信息的权限(平台管理员-该应用的应用管理员)
|
|
|
// 获取当前登录用户信息
|
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
|
|
|
- // 查询当前应用的应用管理员信息
|
|
|
for (String id : ids) {
|
|
|
// 不能删除基础平台的应用信息
|
|
|
if (id.equals("0")) return false;
|
|
|
+
|
|
|
AppBaseInfo appBaseInfo = baseInfoMapper.selectById(id);
|
|
|
if (!loginUser.getUsername().equals("admin")){
|
|
|
if (!(appBaseInfo.getAdmin().equals(loginUser.getId()))) return false;
|
|
@@ -248,7 +243,7 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
@Override
|
|
|
public Boolean editBaseInfo(AppBaseInfo baseInfo) {
|
|
|
int i = baseInfoMapper.updateById(baseInfo);
|
|
|
- customMapper.updateRoleToPortstationtype(baseInfo.getId(), baseInfo.getName());
|
|
|
+ if (baseInfo.getAddType().equals("full")) customMapper.updateRoleToPortstationtype(baseInfo.getId(), baseInfo.getName());
|
|
|
// 保存成功解除反审核状态
|
|
|
if (i>0) uncheckLock("AppbaseInfo"+baseInfo.getId());
|
|
|
return i>0;
|
|
@@ -301,14 +296,10 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
@Transactional
|
|
|
public Boolean editUserInfo(AppUpdataUserInfo updataUserInfo) {
|
|
|
String appid = updataUserInfo.getAppid();
|
|
|
- // 移除应用用户时,将去角色收回
|
|
|
+ // 移除应用用户时,将默认角色收回
|
|
|
if (updataUserInfo.getDelUserids()!=null&&!updataUserInfo.getDelUserids().isEmpty()){
|
|
|
updataUserInfo.getDelUserids().forEach(userid -> {
|
|
|
System.out.println("删除用户:"+userid);
|
|
|
- // 获取要移除的用户的信息
|
|
|
- QueryWrapper<AppUserInfo> userInfoPOQueryWrapper = new QueryWrapper<>();
|
|
|
- userInfoPOQueryWrapper.eq("appid",appid).eq("userid",userid);
|
|
|
- AppUserInfo userInfo = userInfoMapper.selectOne(userInfoPOQueryWrapper);
|
|
|
// 获取该用户在该应用下的角色信息
|
|
|
List<String> roleIds = sysUserRoleService.listByAppId(appid, userid);
|
|
|
// 删除该用户在该应用下的角色信息
|
|
@@ -357,7 +348,6 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 组合条件查询应用基础信息
|
|
|
* @param key 模糊查询关键字
|
|
@@ -411,7 +401,7 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
// 获取当前登录用户
|
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
// 当前登录用户与当前应用的基础信息的应用管理员id是否一致
|
|
|
- appBaseInfo.setIsEdit(appBaseInfo.getAdmin().equals(loginUser.getId()));
|
|
|
+ appBaseInfo.setIsEdit(hasEditCurrentInfoPermission(id));
|
|
|
return appBaseInfo;
|
|
|
}
|
|
|
|
|
@@ -464,19 +454,6 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
queryParams.getFilteruserids(),
|
|
|
queryParams.getPageNo());
|
|
|
|
|
|
- // 判断当前用户是否可进行编辑操作
|
|
|
- LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
- String managerId;
|
|
|
- Map<String, String> appManagerUserInfo; // 应用管理员信息
|
|
|
- // 先从 redis 查询应用管理员信息,如果为空,则查询数据库
|
|
|
- appManagerUserInfo = (Map<String, String>) redisUtil.get("appManagerInfo");
|
|
|
- if (appManagerUserInfo == null) {
|
|
|
- AppBaseInfo baseInfoPO = baseInfoMapper.selectById(queryParams.getAppid());
|
|
|
- managerId = baseInfoPO.getAdmin();
|
|
|
- }else {
|
|
|
- managerId = appManagerUserInfo.get(queryParams.getAppid());
|
|
|
- }
|
|
|
- editUserInfoEntity.setIsEdit(loginUser.getId().equals(managerId));
|
|
|
AppBaseInfo appBaseInfo = baseInfoMapper.selectById(queryParams.getAppid());
|
|
|
// 查询用户角色信息
|
|
|
appUserInfos.forEach(map -> {
|
|
@@ -595,16 +572,6 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- // 是否为信息部用户
|
|
|
- @Override
|
|
|
- public boolean isInfoUser() {
|
|
|
- String deptId = customMapper.queryDepartIdByDepartName("信息部");
|
|
|
- // 获取当前登录用户id
|
|
|
- LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
- String udeptId = customMapper.queryDepartIdByUserId(loginUser.getId());
|
|
|
- return deptId.equals(udeptId);
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public boolean isAppAdmin() {
|
|
|
// 获取当前登录用户
|
|
@@ -639,10 +606,8 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
// 如果是平台管理员
|
|
|
if (loginUser.getUsername().equals("admin")) return true;
|
|
|
- // 查询基础信息的应用管理员id,比较是否和当前登录用户一致
|
|
|
- QueryWrapper<AppBaseInfo> baseInfoPOQueryWrapper = new QueryWrapper<>();
|
|
|
- baseInfoPOQueryWrapper.select("admin").eq("id", appid);
|
|
|
- AppBaseInfo baseInfo = baseInfoMapper.selectOne(baseInfoPOQueryWrapper);
|
|
|
+ // 查询应用管理员id,比较是否和当前登录用户一致
|
|
|
+ AppBaseInfo baseInfo = baseInfoMapper.selectById(appid);
|
|
|
return loginUser.getId().equals(baseInfo.getAdmin());
|
|
|
}
|
|
|
|
|
@@ -671,36 +636,31 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
|
|
|
|
|
|
// 应用审核通过后续处理
|
|
|
- public <T> void afterAppCheckPass(String appid, T formData) {
|
|
|
-
|
|
|
+ @Transactional
|
|
|
+ public void afterAppCheckPass(Long workid) {
|
|
|
+ String appid = null;
|
|
|
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")){
|
|
|
+ AppBaseInfo baseInfoInFlow = customMapper.queryEasyFlowFormData(workid);
|
|
|
+ if (baseInfoInFlow == null){ // 完整注册需执行的操作
|
|
|
+ APP_Register_workFlow_FormEntity appRegisterWorkFlowForm = customMapper.queryFullFlowFormData(workid);
|
|
|
+ appid = appRegisterWorkFlowForm.getId();
|
|
|
+ baseInfoInFlow = appManageUtil.AppRegisterWorkFlowFormEntityToBaseInfo(appRegisterWorkFlowForm);
|
|
|
+ // 更新应用文档信息
|
|
|
+ AppDocInfo appDocInfo = appManageUtil.AppRegisterWorkFlowFormEntityToDocInfo(appRegisterWorkFlowForm);
|
|
|
+ editDocInfo(appDocInfo);
|
|
|
+ // 更新应用环境信息
|
|
|
+ AppEditEnvInfoEntity appEnvInfoList = appManageUtil.AppRegisterWorkFlowFormEntityToEnvInfo(appRegisterWorkFlowForm);
|
|
|
+ editEnvInfo(appEnvInfoList);
|
|
|
// 将通过完整注册的应用信息同步给JFlow的角色分类表
|
|
|
- customMapper.addRoleToPortstationtype(appid, appBaseInfo.getName());
|
|
|
+ customMapper.addRoleToPortstationtype(appid, baseInfoInFlow.getName());
|
|
|
+
|
|
|
// 添加默认角色信息
|
|
|
SysRole role = new SysRole();
|
|
|
role.setAppId(appid); // 设置角色所属应用信息
|
|
|
role.setRoleCode("default"); // 设置角色编码
|
|
|
- role.setAppName(appBaseInfo.getName()) ; // 设置角色的应用名称
|
|
|
- role.setRoleName(appBaseInfo.getName()+"_默认用户角色"); // 设置角色名
|
|
|
- role.setDescription(appBaseInfo.getName()+"默认角色"); // 设置备注
|
|
|
+ role.setAppName(baseInfoInFlow.getName()) ; // 设置角色的应用名称
|
|
|
+ role.setRoleName(baseInfoInFlow.getName()+"_默认用户角色"); // 设置角色名
|
|
|
+ role.setDescription(baseInfoInFlow.getName()+"默认角色"); // 设置备注
|
|
|
sysRoleService.save(role); // 添加角色
|
|
|
|
|
|
// 获取角色编码
|
|
@@ -710,39 +670,82 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
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);
|
|
|
+ if (!appUserInfos.isEmpty()){
|
|
|
+ List<String> useridlist = appUserInfos.stream().map(AppUserInfo::getUserid).collect(Collectors.toList());
|
|
|
+ // 应用默认角色分配给应用用户
|
|
|
+ useridlist.forEach(userid -> {
|
|
|
+ SysUserRole sysUserRole = new SysUserRole();
|
|
|
+ sysUserRole.setRoleId(roleid);
|
|
|
+ sysUserRole.setUserId(userid);
|
|
|
+ sysUserRoleService.save(sysUserRole);
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
// 创建该应用的一级菜单
|
|
|
- SysPermission hassysPermission = customMapper.queryUrlByUrl(appBaseInfo.getMenuInfo());
|
|
|
+ SysPermission hassysPermission = customMapper.queryUrlByUrl(baseInfoInFlow.getMenuInfo());
|
|
|
if (hassysPermission == null){
|
|
|
SysPermission sysPermission = new SysPermission();
|
|
|
- sysPermission.setName(appBaseInfo.getName());
|
|
|
+ sysPermission.setName(baseInfoInFlow.getName());
|
|
|
sysPermission.setAppId(appid);
|
|
|
- sysPermission.setUrl(appBaseInfo.getMenuInfo());
|
|
|
+ sysPermission.setUrl(baseInfoInFlow.getMenuInfo());
|
|
|
// 设置组件(即 菜单路径去掉第一个 "/")
|
|
|
String component = sysPermission.getUrl().replaceFirst("^/", "");
|
|
|
sysPermission.setComponent(component);
|
|
|
sysPermission.setMenuType(0);
|
|
|
sysPermission.setRoute(true);
|
|
|
sysPermissionService.addPermission(sysPermission);
|
|
|
- // 授予应用默认角色访问一级菜单权限
|
|
|
- sysRolePermissionService.saveRolePermission(roleid, sysPermission.getId(),"");
|
|
|
+ AfterCheckSaveUserPermission(baseInfoInFlow, sysPermission.getId());
|
|
|
+// sysRolePermissionService.saveRolePermission(roleid, sysPermission.getId());
|
|
|
}else {
|
|
|
- // 授予应用默认角色访问一级菜单权限
|
|
|
- sysRolePermissionService.saveRolePermission(roleid, hassysPermission.getId(),"");
|
|
|
+ AfterCheckSaveUserPermission(baseInfoInFlow, hassysPermission.getId());
|
|
|
+// sysRolePermissionService.saveRolePermission(roleid, hassysPermission.getId());
|
|
|
}
|
|
|
+ }else { // 简易注册需执行的操作
|
|
|
+ appid = baseInfoInFlow.getId();
|
|
|
}
|
|
|
+ AfterCheckPublicOperation(appid,baseInfoInFlow);
|
|
|
}catch (Exception e){
|
|
|
System.out.println("应用审核通过后续处理错误:"+e);
|
|
|
+ baseCommonService.addLog("应用审核后续处理错误:"+workid+"__异常信息:"+e, CommonConstant.LOG_TYPE_4, 3 );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void AfterCheckPublicOperation(String appid, AppBaseInfo baseInfo){
|
|
|
+ // 更新应用基础信息
|
|
|
+ baseInfo.setInfoStatus(1);
|
|
|
+ baseInfo.setCheckUser("admin");
|
|
|
+ baseInfo.setCheckTime(String.valueOf(DateUtils.getTimestamp()));
|
|
|
+ baseInfoMapper.updateBaseInfo(baseInfo);
|
|
|
+
|
|
|
+ // 给申请注册应用信息的用户发送系统消息
|
|
|
+ AppBaseInfo appBaseInfo = baseInfoMapper.queryAppBaseInfoById(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","应用"+appBaseInfo.getName()+"注册审核通过");
|
|
|
+ message.setTemplateParam(templateParam);
|
|
|
+ sysBaseApi.sendTemplateAnnouncement(message);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 授予应用相关用户(管理员 开发负责人 运维负责人等)访问应用一级菜单权限
|
|
|
+ private void AfterCheckSaveUserPermission(AppBaseInfo appBaseInfo, String permissionid){
|
|
|
+ sysUserPermissionService.save(getSysUserPermission(appBaseInfo.getAdmin(), permissionid));
|
|
|
+ if (!Objects.equals(appBaseInfo.getBusinessUser(), "")){} sysUserPermissionService.save(getSysUserPermission(appBaseInfo.getBusinessUser(), permissionid));
|
|
|
+ if (!Objects.equals(appBaseInfo.getDevelopUser(), "")) sysUserPermissionService.save(getSysUserPermission(appBaseInfo.getDevelopUser(), permissionid));
|
|
|
+ if (!Objects.equals(appBaseInfo.getRequirementUser(), "")) sysUserPermissionService.save(getSysUserPermission(appBaseInfo.getBusinessUser(), permissionid));
|
|
|
+ }
|
|
|
+
|
|
|
+ private SysUserPermission getSysUserPermission(String username, String permissionId) {
|
|
|
+ String userId = customMapper.queryUserIdByUsername(username);
|
|
|
+ SysUserPermission sysUserPermission = new SysUserPermission();
|
|
|
+ sysUserPermission.setUserId(userId);
|
|
|
+ sysUserPermission.setPermissionId(permissionId);
|
|
|
+ return sysUserPermission;
|
|
|
+ }
|
|
|
+
|
|
|
// 应用注册 撤销后续处理(删除插入的数据)
|
|
|
@Override
|
|
|
public void afterUnsendAppRegisterFlow(long workID) {
|
|
@@ -756,4 +759,10 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
customMapper.deleteAppUserInfoNotLogic(appid);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean AppNameIsExist(String appName) {
|
|
|
+ Integer i = customMapper.checkAppNameIsExist(appName);
|
|
|
+ return i!= null;
|
|
|
+ }
|
|
|
}
|