|
@@ -102,11 +102,16 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
// 先行添加应用基础信息。获得appid
|
|
// 先行添加应用基础信息。获得appid
|
|
AppBaseInfo appBaseInfo = appInfo.getAppBaseInfoDTO();
|
|
AppBaseInfo appBaseInfo = appInfo.getAppBaseInfoDTO();
|
|
|
|
+ // 查询有无相同的应用名
|
|
|
|
+ QueryWrapper<AppBaseInfo> appBaseInfoQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ appBaseInfoQueryWrapper.eq("name", appBaseInfo.getName());
|
|
|
|
+ if (baseInfoMapper.selectOne(appBaseInfoQueryWrapper) != null) return "应用名称已存在";
|
|
|
|
+
|
|
appBaseInfo.setCreateBy(loginUser.getId());
|
|
appBaseInfo.setCreateBy(loginUser.getId());
|
|
appBaseInfo.setAddType(appInfo.getAddType());
|
|
appBaseInfo.setAddType(appInfo.getAddType());
|
|
baseInfoMapper.insert(appBaseInfo);
|
|
baseInfoMapper.insert(appBaseInfo);
|
|
// 简易注册模式下添加基础信息即可
|
|
// 简易注册模式下添加基础信息即可
|
|
- if (appBaseInfo.getAddType().equals("easy")) return "添加成功";
|
|
|
|
|
|
+ if (appBaseInfo.getAddType().equals("easy")) return "提交成功";
|
|
String appid = appBaseInfo.getId();
|
|
String appid = appBaseInfo.getId();
|
|
|
|
|
|
// 添加默认角色信息
|
|
// 添加默认角色信息
|
|
@@ -119,7 +124,6 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
|
|
|
|
// 获取角色编码
|
|
// 获取角色编码
|
|
String roleid = role.getId();
|
|
String roleid = role.getId();
|
|
-
|
|
|
|
ArrayList<String> useridlist = new ArrayList<>();
|
|
ArrayList<String> useridlist = new ArrayList<>();
|
|
// 添加应用用户信息
|
|
// 添加应用用户信息
|
|
appInfo.getUserInfo().forEach(userid -> {
|
|
appInfo.getUserInfo().forEach(userid -> {
|
|
@@ -175,12 +179,12 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
AppDocInfo appDocInfo = appInfo.getAppDocInfoDTO();
|
|
AppDocInfo appDocInfo = appInfo.getAppDocInfoDTO();
|
|
appDocInfo.setAppid(appid);
|
|
appDocInfo.setAppid(appid);
|
|
docInfoMapper.insert(appDocInfo);
|
|
docInfoMapper.insert(appDocInfo);
|
|
- return "添加成功";
|
|
|
|
|
|
+ return "提交成功";
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 删除应用信息
|
|
* 删除应用信息
|
|
- * @param ids
|
|
|
|
|
|
+ * @param ids 应用id集合
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@@ -194,14 +198,30 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
baseInfoPOQueryWrapper.select("admin").in("id", ids[0]);
|
|
baseInfoPOQueryWrapper.select("admin").in("id", ids[0]);
|
|
AppBaseInfo appBaseInfo = baseInfoMapper.selectOne(baseInfoPOQueryWrapper);
|
|
AppBaseInfo appBaseInfo = baseInfoMapper.selectOne(baseInfoPOQueryWrapper);
|
|
if (!appBaseInfo.getAdmin().equals(loginUser.getId())) return false;
|
|
if (!appBaseInfo.getAdmin().equals(loginUser.getId())) return false;
|
|
- }else {
|
|
|
|
|
|
+ }else { // 批量删除应用信息时,如果有一个应用不是当前登录用户所创建,则返回false
|
|
for (String id : ids) {
|
|
for (String id : ids) {
|
|
AppBaseInfo appBaseInfo = baseInfoMapper.selectById(id);
|
|
AppBaseInfo appBaseInfo = baseInfoMapper.selectById(id);
|
|
if (!appBaseInfo.getAdmin().equals(loginUser.getId())) return false;
|
|
if (!appBaseInfo.getAdmin().equals(loginUser.getId())) return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for (String id : ids) {
|
|
for (String id : ids) {
|
|
|
|
+ // 不能删除基础平台的应用信息
|
|
|
|
+ if (id.equals("0")) return false;
|
|
|
|
+
|
|
|
|
+ // 删除所属该应用的基础信息、环境信息、文档信息、用户信息
|
|
baseInfoMapper.deleteById(id);
|
|
baseInfoMapper.deleteById(id);
|
|
|
|
+ envInfoMapper.delete(new QueryWrapper<AppEnvInfo>().eq("appid", id));
|
|
|
|
+ docInfoMapper.delete(new QueryWrapper<AppDocInfo>().eq("appid", id));
|
|
|
|
+ userInfoMapper.delete(new QueryWrapper<AppUserInfo>().eq("appid", id));
|
|
|
|
+
|
|
|
|
+ // 删除该应用下所创建的菜单
|
|
|
|
+// List<SysPermission> sysPermissions = sysPermissionService(loginUser.getUsername());
|
|
|
|
+// String permissionsid = sysPermissions.stream().filter(permission -> permission.getAppId().equals(id)).findFirst().get().getId();
|
|
|
|
+// sysPermissionService.deletePermission(permissionsid);
|
|
|
|
+
|
|
|
|
+ // 删除该应用下所创建的角色信息
|
|
|
|
+// sysRoleService.listRoleIdsByAppId()
|
|
|
|
+
|
|
}
|
|
}
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -323,11 +343,13 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
Map<String, String> appManagerInfo = new HashMap<>();
|
|
Map<String, String> appManagerInfo = new HashMap<>();
|
|
baseInfos.forEach(baseInfo -> {
|
|
baseInfos.forEach(baseInfo -> {
|
|
appManagerInfo.put(baseInfo.getId(), baseInfo.getAdminid());
|
|
appManagerInfo.put(baseInfo.getId(), baseInfo.getAdminid());
|
|
|
|
+
|
|
// 查询字典
|
|
// 查询字典
|
|
String typeText = sysDictService.queryDictTextByKey("app_type", baseInfo.getType());
|
|
String typeText = sysDictService.queryDictTextByKey("app_type", baseInfo.getType());
|
|
String statusText = sysDictService.queryDictTextByKey("app_status", baseInfo.getStatus());
|
|
String statusText = sysDictService.queryDictTextByKey("app_status", baseInfo.getStatus());
|
|
baseInfo.setType(typeText);
|
|
baseInfo.setType(typeText);
|
|
baseInfo.setStatus(statusText);
|
|
baseInfo.setStatus(statusText);
|
|
|
|
+ baseInfo.setKey(baseInfo.getId());
|
|
appBaseInfoS.add(baseInfo);
|
|
appBaseInfoS.add(baseInfo);
|
|
});
|
|
});
|
|
redisUtil.set("appManagerInfo", appManagerInfo, 60*60*24);
|
|
redisUtil.set("appManagerInfo", appManagerInfo, 60*60*24);
|
|
@@ -425,27 +447,31 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
managerId = appManagerInfo.get(queryParams.getAppid());
|
|
managerId = appManagerInfo.get(queryParams.getAppid());
|
|
}
|
|
}
|
|
editUserInfoEntity.setIsEdit(loginUser.getId().equals(managerId));
|
|
editUserInfoEntity.setIsEdit(loginUser.getId().equals(managerId));
|
|
-
|
|
|
|
|
|
+ AppBaseInfo appBaseInfo = baseInfoMapper.selectById(queryParams.getAppid());
|
|
// 查询用户角色信息
|
|
// 查询用户角色信息
|
|
appUserInfos.forEach(map -> {
|
|
appUserInfos.forEach(map -> {
|
|
QueryWrapper<AppUserInfo> appUserInfoQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<AppUserInfo> appUserInfoQueryWrapper = new QueryWrapper<>();
|
|
appUserInfoQueryWrapper.select("roles")
|
|
appUserInfoQueryWrapper.select("roles")
|
|
.eq("userid", map.get("id")).eq("appid", queryParams.getAppid());
|
|
.eq("userid", map.get("id")).eq("appid", queryParams.getAppid());
|
|
AppUserInfo roleInfo = userInfoMapper.selectOne(appUserInfoQueryWrapper);
|
|
AppUserInfo roleInfo = userInfoMapper.selectOne(appUserInfoQueryWrapper);
|
|
|
|
+ // 查询应用基础信息的相关用户信息
|
|
|
|
+ String roleNameInfo = baseInfoToUserInfoRoles(appBaseInfo, (String) map.get("id"));
|
|
// 使用 Stream API 将字符串转换为 List
|
|
// 使用 Stream API 将字符串转换为 List
|
|
if (roleInfo!=null){
|
|
if (roleInfo!=null){
|
|
|
|
+ // 将应用用户表中存的的角色信息字符串转换为List
|
|
List<String> list = Arrays.stream(roleInfo.getRoles().split(","))
|
|
List<String> list = Arrays.stream(roleInfo.getRoles().split(","))
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
QueryWrapper<SysRole> sysRoleQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<SysRole> sysRoleQueryWrapper = new QueryWrapper<>();
|
|
sysRoleQueryWrapper.select("role_name").in("id", list);
|
|
sysRoleQueryWrapper.select("role_name").in("id", list);
|
|
|
|
+ // 查询角色名信息
|
|
List<SysRole> sysRoles = sysRoleMapper.selectList(sysRoleQueryWrapper);
|
|
List<SysRole> sysRoles = sysRoleMapper.selectList(sysRoleQueryWrapper);
|
|
- String roleNameInfo = sysRoles.stream()
|
|
|
|
- .map(SysRole::getRoleName)
|
|
|
|
- .collect(Collectors.joining(","));
|
|
|
|
- map.put("roles", roleNameInfo);
|
|
|
|
- }else {
|
|
|
|
- map.put("roles", "");
|
|
|
|
|
|
+ if (!sysRoles.isEmpty()&&!roleNameInfo.isEmpty()){
|
|
|
|
+ roleNameInfo =roleNameInfo +", "+ sysRoles.stream()
|
|
|
|
+ .map(SysRole::getRoleName)
|
|
|
|
+ .collect(Collectors.joining(", "));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ map.put("roles", roleNameInfo);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}else { // 作为添加表单时的查询(查询全部用户), 角色分配用户时亦使用
|
|
}else { // 作为添加表单时的查询(查询全部用户), 角色分配用户时亦使用
|
|
@@ -464,6 +490,8 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
editUserInfoEntity.setUserinfos(appUserInfos);
|
|
editUserInfoEntity.setUserinfos(appUserInfos);
|
|
return editUserInfoEntity;
|
|
return editUserInfoEntity;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 根据appid查询应用详情信息
|
|
* 根据appid查询应用详情信息
|
|
* @param appid
|
|
* @param appid
|
|
@@ -593,4 +621,40 @@ public class AppmanageServiceImpl implements AppmanageService {
|
|
int i = userInfoMapper.updateById(appUserInfo);
|
|
int i = userInfoMapper.updateById(appUserInfo);
|
|
return i>0;
|
|
return i>0;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
}
|
|
}
|