|
@@ -91,8 +91,6 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
@Autowired
|
|
|
private AppManageUtil appManageUtil;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
private final ReentrantLock lock = new ReentrantLock();
|
|
|
private final String UNCHECK_TAG_BASE_PATH = "AppInfouncheckTag:";
|
|
|
|
|
@@ -117,7 +115,7 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
appBaseInfo.setDelFlag(1);
|
|
|
baseInfoMapper.insert(appBaseInfo);
|
|
|
|
|
|
- // 提交至工作流的表单信息(将用户id换成用户账号,字典值换成字典文本)
|
|
|
+ // 提交至工作流的表单信息(将用户id换成用户账账号)
|
|
|
AppBaseInfo sendCheck_appBaseInfo = appBaseInfo;
|
|
|
sendCheck_appBaseInfo.setAdmin(customMapper.queryUsernameByUserId(appBaseInfo.getAdmin()));
|
|
|
if (appBaseInfo.getDevelopUser()!=null)
|
|
@@ -128,19 +126,17 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
sendCheck_appBaseInfo.setRequirementUser(customMapper.queryUsernameByUserId(appBaseInfo.getRequirementUser()));
|
|
|
if (appBaseInfo.getBusinessUser()!=null)
|
|
|
sendCheck_appBaseInfo.setBusinessUser(customMapper.queryUsernameByUserId(appBaseInfo.getBusinessUser()));
|
|
|
-// sendCheck_appBaseInfo.setType(sysDictService.queryDictTextByKey("app_type", appBaseInfo.getType()));
|
|
|
-// sendCheck_appBaseInfo.setStatus(sysDictService.queryDictTextByKey("app_status", appBaseInfo.getStatus()));
|
|
|
AppDocInfo appDocInfo = appInfo.getAppDocInfoDTO();
|
|
|
boolean hasEnvInfo = false;
|
|
|
if (appInfo.getAppEnvInfoDTO()!=null) hasEnvInfo = appInfo.getAppEnvInfoDTO().size()>0;
|
|
|
+ boolean tag; // 流程发送结果标志
|
|
|
+ String appid = appBaseInfo.getId();
|
|
|
// 简易注册模式下添加基础信息即可
|
|
|
if (appBaseInfo.getAddType().equals("easy")){
|
|
|
- boolean tag = appManageUtil.sendCheckWordFlow(sendCheck_appBaseInfo, "021", loginUser.getUsername(), "admin");
|
|
|
+ tag = appManageUtil.sendCheckWordFlow(sendCheck_appBaseInfo, "021", loginUser.getUsername(), "admin");
|
|
|
// 发起流程失败则删除数据库内数据
|
|
|
- if (tag){
|
|
|
- return "提交成功";
|
|
|
- } else {
|
|
|
- baseInfoMapper.deleteAppInfoNotLogic(appBaseInfo.getId());
|
|
|
+ if (!tag){
|
|
|
+ customMapper.deleteAppBaseInfoNotLogic(appid);
|
|
|
return "提交失败";
|
|
|
}
|
|
|
}else {
|
|
@@ -152,10 +148,16 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
AppManageUtil appManageUtil = new AppManageUtil();
|
|
|
appRegisterWorkFlowFormEntity = appManageUtil.TransitionEnvInfoToAppRegisterWorkFlowForm(appRegisterWorkFlowFormEntity, appInfo.getAppEnvInfoDTO());
|
|
|
}
|
|
|
- appManageUtil.sendCheckWordFlow(appRegisterWorkFlowFormEntity, "022",loginUser.getUsername(),"admin");
|
|
|
+ tag = appManageUtil.sendCheckWordFlow(appRegisterWorkFlowFormEntity, "022", loginUser.getUsername(), "admin");
|
|
|
+ // 发起流程失败则删除数据库内数据
|
|
|
+ if (!tag){
|
|
|
+ customMapper.deleteAppBaseInfoNotLogic(appid);
|
|
|
+ customMapper.deleteAppDocInfoNotLogic(appid);
|
|
|
+ customMapper.deleteAppEnvInfoNotLogic(appid);
|
|
|
+ customMapper.deleteAppUserInfoNotLogic(appid);
|
|
|
+ return "提交失败";
|
|
|
+ }
|
|
|
}
|
|
|
- String appid = appBaseInfo.getId();
|
|
|
-
|
|
|
// 添加应用用户信息
|
|
|
appInfo.getUserInfo().forEach(userid -> {
|
|
|
AppUserInfo userInfo = new AppUserInfo();
|
|
@@ -174,7 +176,6 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
// 添加应用文档信息
|
|
|
appDocInfo.setAppid(appid);
|
|
|
docInfoMapper.insert(appDocInfo);
|
|
|
-
|
|
|
return "提交成功";
|
|
|
}
|
|
|
|
|
@@ -183,6 +184,7 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
* @param ids 应用id集合
|
|
|
* @return
|
|
|
*/
|
|
|
+ @Transactional
|
|
|
@Override
|
|
|
public Boolean deleteAppInfo(String[] ids) {
|
|
|
// 需先判断用户是否拥有所删除的应用信息的权限(平台管理员-应用管理员)
|
|
@@ -238,7 +240,7 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public Boolean editBaseInfo(AppBaseInfo baseInfo) throws Exception {
|
|
|
+ public Boolean editBaseInfo(AppBaseInfo baseInfo) {
|
|
|
|
|
|
int i = baseInfoMapper.updateById(baseInfo);
|
|
|
// 保存成功解除反审核状态
|
|
@@ -246,6 +248,11 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
return i>0;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改应用环境信息
|
|
|
+ * @param editEnvInfoEntity
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public Boolean editEnvInfo(AppEditEnvInfoEntity editEnvInfoEntity) {
|
|
@@ -350,7 +357,7 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
* @param key 模糊查询关键字
|
|
|
* @param type 应用类型
|
|
|
* @param status 应用状态
|
|
|
- * @param userid 用户id
|
|
|
+ * @param userid 用户id (暂放)
|
|
|
* @return 应用基础信息集合
|
|
|
*/
|
|
|
|
|
@@ -372,7 +379,6 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
appBaseInfoS.add(baseInfo);
|
|
|
});
|
|
|
redisUtil.set("appManagerInfo", appManagerInfo, 60*60*24);
|
|
|
- // 使用 Collections.sort() 方法进行排序
|
|
|
|
|
|
return appBaseInfoS;
|
|
|
// if(userid!=null){
|
|
@@ -409,9 +415,10 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
*/
|
|
|
@Override
|
|
|
public List<AppEnvInfo> queryEnvInfoByAppId(String appid) {
|
|
|
+ // 该用户是否可以查看当前应用的应用信息
|
|
|
List<AppEnvInfo> envInfos = envInfoMapper.
|
|
|
- selectList(new QueryWrapper<AppEnvInfo>().eq("appid", appid));
|
|
|
- return envInfos;
|
|
|
+ selectList(new QueryWrapper<AppEnvInfo>().eq("appid", appid));
|
|
|
+ return envInfos;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -429,7 +436,6 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
* 应用用户查询功能
|
|
|
* @return
|
|
|
*/
|
|
|
-
|
|
|
@Override
|
|
|
public AppEditUserInfoEntity queryAppUser(AppUserInfoQueryParams queryParams) {
|
|
|
List<Map<String, Object>> appUserInfos = new ArrayList<>();
|
|
@@ -454,15 +460,15 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
|
|
|
// 判断当前用户是否可进行编辑操作
|
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
- String managerId = "";
|
|
|
- Map<String, String> appManagerInfo = new HashMap<>();
|
|
|
- appManagerInfo = (Map<String, String>) redisUtil.get("appManagerInfo");
|
|
|
+ String managerId;
|
|
|
+ Map<String, String> appManagerUserInfo; // 应用管理员信息
|
|
|
// 先从 redis 查询应用管理员信息,如果为空,则查询数据库
|
|
|
- if (appManagerInfo == null) {
|
|
|
+ appManagerUserInfo = (Map<String, String>) redisUtil.get("appManagerInfo");
|
|
|
+ if (appManagerUserInfo == null) {
|
|
|
AppBaseInfo baseInfoPO = baseInfoMapper.selectById(queryParams.getAppid());
|
|
|
managerId = baseInfoPO.getAdmin();
|
|
|
}else {
|
|
|
- managerId = appManagerInfo.get(queryParams.getAppid());
|
|
|
+ managerId = appManagerUserInfo.get(queryParams.getAppid());
|
|
|
}
|
|
|
editUserInfoEntity.setIsEdit(loginUser.getId().equals(managerId));
|
|
|
AppBaseInfo appBaseInfo = baseInfoMapper.selectById(queryParams.getAppid());
|
|
@@ -470,12 +476,12 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
appUserInfos.forEach(map -> {
|
|
|
String roleNameInfo = appManageUtil.baseInfoToUserInfoRoles(appBaseInfo, (String) map.get("id"));
|
|
|
List<String> roleIds = sysUserRoleService.listByAppId(queryParams.getAppid(), (String) map.get("id"));
|
|
|
-
|
|
|
+ // 查询角色名信息
|
|
|
if (!roleIds.isEmpty()){
|
|
|
- // 查询角色名信息
|
|
|
QueryWrapper<SysRole> sysRoleQueryWrapper = new QueryWrapper<>();
|
|
|
sysRoleQueryWrapper.select("role_name").in("id", roleIds);
|
|
|
List<SysRole> sysRoles = sysRoleMapper.selectList(sysRoleQueryWrapper);
|
|
|
+ // 角色信息拼接
|
|
|
if (!sysRoles.isEmpty()&&!roleNameInfo.isEmpty()){
|
|
|
roleNameInfo =roleNameInfo +", "+ sysRoles.stream()
|
|
|
.map(SysRole::getRoleName)
|
|
@@ -489,7 +495,7 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
map.put("roles", roleNameInfo);
|
|
|
});
|
|
|
}
|
|
|
- }else { // 作为添加表单时的查询(查询全部用户), 角色分配用户时亦使用
|
|
|
+ }else { // 作为添加表单时的查询(查询全部用户)
|
|
|
appUserInfos = sysUserService.userComplexCondition(queryParams.getUserids(),
|
|
|
queryParams.getUsername(),
|
|
|
queryParams.getRealname(),
|
|
@@ -497,7 +503,7 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
queryParams.getFilteruserids(),
|
|
|
queryParams.getPageNo());
|
|
|
}
|
|
|
- // 如果查询到的用户不为空,则取appUserInfos最后一个值为total值,并将appUserInfos最后一个值删除
|
|
|
+ // 如果查询到的用户不为空,则取appUserInfos最后一个值为total值(分页使用),并将appUserInfos最后一个值删除
|
|
|
if (!appUserInfos.isEmpty()){
|
|
|
editUserInfoEntity.setTotal((Integer) appUserInfos.get(appUserInfos.size()-1).get("total"));
|
|
|
appUserInfos.remove(appUserInfos.size()-1);
|
|
@@ -609,6 +615,8 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
public boolean isAppAdminOrDevOrOpe(String appid) {
|
|
|
// 获取当前登录用户
|
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ // 如果是平台管理员
|
|
|
+ if (loginUser.getUsername().equals("admin")) return true;
|
|
|
AppBaseInfo baseInfo = baseInfoMapper.selectById(appid);
|
|
|
if (baseInfo!=null){
|
|
|
if (baseInfo.getAdmin().equals(loginUser.getId())) return true;
|
|
@@ -619,10 +627,12 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- // 判断当前用户是否有编辑当前信息的权限
|
|
|
+ // 判断当前用户是否为当前应用的应用管理员
|
|
|
public boolean hasEditCurrentInfoPermission(String appid){
|
|
|
// 获取当前登录用户
|
|
|
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);
|
|
@@ -654,7 +664,7 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- // 应用审核通过后一系列创建应用一级菜单、默认角色、授权操作(完整注册时)
|
|
|
+ // 应用审核通过后续处理
|
|
|
public <T> void afterAppCheckPass(String appid, T formData) {
|
|
|
AppBaseInfo appBaseInfo = baseInfoMapper.queryAppBaseInfoById(appid);
|
|
|
appManageUtil.CompareOldAppBaseInfoAndNewAppBaseInfo(appBaseInfo, formData);
|
|
@@ -670,12 +680,12 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
// 设置消息模板编码
|
|
|
message.setTemplateCode("app_examineAndapprove");
|
|
|
Map<String, String> templateParam = new HashMap<>();
|
|
|
- templateParam.put("resultText","通过");
|
|
|
+ templateParam.put("resultText","应用"+appBaseInfo.getName()+"注册审核通过");
|
|
|
message.setTemplateParam(templateParam);
|
|
|
sysBaseApi.sendTemplateAnnouncement(message);
|
|
|
|
|
|
|
|
|
- // 判断该信息是否为完整注册
|
|
|
+ // 该信息为完整注册时,通过审核后添加默认角色、菜单权限、菜单信息
|
|
|
if (appBaseInfo.getAddType().equals("full")){
|
|
|
// 添加默认角色信息
|
|
|
SysRole role = new SysRole();
|
|
@@ -683,6 +693,7 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
role.setRoleCode("default"); // 设置角色编码
|
|
|
role.setAppName(appBaseInfo.getName()) ; // 设置角色的应用名称
|
|
|
role.setRoleName(appBaseInfo.getName()+"_默认用户角色"); // 设置角色名
|
|
|
+ role.setDescription(appBaseInfo.getName()+"默认角色"); // 设置备注
|
|
|
sysRoleService.save(role); // 添加角色
|
|
|
|
|
|
// 获取角色编码
|
|
@@ -701,19 +712,39 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
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(),"");
|
|
|
+ // 首先判断菜单是否已存在
|
|
|
+ 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(),"");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 应用注册 撤销后续处理(删除插入的数据)
|
|
|
+ @Override
|
|
|
+ public void afterUnsendAppRegisterFlow(long workID) {
|
|
|
+ // 通过workID获取应用id
|
|
|
+ String appid = customMapper.getAppidByWorkID(workID);
|
|
|
+ String addType = customMapper.queryAppRegisterTypeByAppid(appid);
|
|
|
+ customMapper.deleteAppBaseInfoNotLogic(appid);
|
|
|
+ if (addType.equals("full")){
|
|
|
+ customMapper.deleteAppDocInfoNotLogic(appid);
|
|
|
+ customMapper.deleteAppEnvInfoNotLogic(appid);
|
|
|
+ customMapper.deleteAppUserInfoNotLogic(appid);
|
|
|
}
|
|
|
}
|
|
|
}
|