From 5dbd4cbc8ecabc7d705ad780b440e03951087616 Mon Sep 17 00:00:00 2001 From: Friday <1121353141@qq.com> Date: Sun, 10 Sep 2023 03:14:38 +0000 Subject: [PATCH] =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=88=86=E7=BB=84=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractApplicationService.java | 10 +-- ...AbstractCertificateApplicationService.java | 2 +- .../FormStandardApplicationServiceImpl.java | 2 +- .../common/entity/app/AppGroupEntity.java | 11 ++- .../common/enums/app/AppGroupType.java | 76 +++++++++++++++++++ .../app/converter/AppGroupTypeConverter.java | 67 ++++++++++++++++ .../repository/app/AppGroupRepository.java | 16 ---- .../AppGroupRepositoryCustomizedImpl.java | 1 + .../app/impl/mapper/AppGroupPoMapper.java | 4 +- .../src/main/resources/db/1.1.0-changelog.xml | 3 + .../controller/app/AppGroupController.java | 36 +-------- .../pojo/result/app/AppGroupListResult.java | 8 ++ .../pojo/save/app/AppGroupCreateParam.java | 1 - .../console/service/app/AppGroupService.java | 25 ------ .../service/app/impl/AppGroupServiceImpl.java | 66 +--------------- 15 files changed, 177 insertions(+), 151 deletions(-) create mode 100644 eiam-common/src/main/java/cn/topiam/employee/common/enums/app/AppGroupType.java create mode 100644 eiam-common/src/main/java/cn/topiam/employee/common/enums/app/converter/AppGroupTypeConverter.java diff --git a/eiam-application/eiam-application-core/src/main/java/cn/topiam/employee/application/AbstractApplicationService.java b/eiam-application/eiam-application-core/src/main/java/cn/topiam/employee/application/AbstractApplicationService.java index d3fb16df..8924f4d1 100644 --- a/eiam-application/eiam-application-core/src/main/java/cn/topiam/employee/application/AbstractApplicationService.java +++ b/eiam-application/eiam-application-core/src/main/java/cn/topiam/employee/application/AbstractApplicationService.java @@ -17,8 +17,9 @@ */ package cn.topiam.employee.application; -import cn.topiam.employee.common.entity.app.AppGroupAssociationEntity; -import cn.topiam.employee.common.repository.app.AppGroupAssociationRepository; +import java.util.ArrayList; +import java.util.List; + import org.apache.commons.lang3.RandomStringUtils; import org.springframework.util.AlternativeJdkIdGenerator; import org.springframework.util.IdGenerator; @@ -27,17 +28,16 @@ import com.fasterxml.jackson.databind.ObjectMapper; import cn.topiam.employee.common.entity.app.AppAccountEntity; import cn.topiam.employee.common.entity.app.AppEntity; +import cn.topiam.employee.common.entity.app.AppGroupAssociationEntity; import cn.topiam.employee.common.enums.app.AuthorizationType; import cn.topiam.employee.common.enums.app.InitLoginType; import cn.topiam.employee.common.exception.app.AppAccountNotExistException; import cn.topiam.employee.common.repository.app.AppAccountRepository; +import cn.topiam.employee.common.repository.app.AppGroupAssociationRepository; import cn.topiam.employee.common.repository.app.AppRepository; import lombok.extern.slf4j.Slf4j; -import java.util.ArrayList; -import java.util.List; - /** * AbstractApplicationService * diff --git a/eiam-application/eiam-application-core/src/main/java/cn/topiam/employee/application/AbstractCertificateApplicationService.java b/eiam-application/eiam-application-core/src/main/java/cn/topiam/employee/application/AbstractCertificateApplicationService.java index 6014acdb..4fe7510e 100644 --- a/eiam-application/eiam-application-core/src/main/java/cn/topiam/employee/application/AbstractCertificateApplicationService.java +++ b/eiam-application/eiam-application-core/src/main/java/cn/topiam/employee/application/AbstractCertificateApplicationService.java @@ -22,7 +22,6 @@ import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Date; -import cn.topiam.employee.common.repository.app.*; import org.bouncycastle.asn1.x500.X500Name; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,6 +32,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import cn.topiam.employee.common.entity.app.AppCertEntity; import cn.topiam.employee.common.enums.app.AppCertUsingType; +import cn.topiam.employee.common.repository.app.*; import cn.topiam.employee.support.exception.TopIamException; import cn.topiam.employee.support.util.CertUtils; import cn.topiam.employee.support.util.RsaUtils; diff --git a/eiam-application/eiam-application-form/src/main/java/cn/topiam/employee/application/form/FormStandardApplicationServiceImpl.java b/eiam-application/eiam-application-form/src/main/java/cn/topiam/employee/application/form/FormStandardApplicationServiceImpl.java index d291e4d3..ff797f54 100644 --- a/eiam-application/eiam-application-form/src/main/java/cn/topiam/employee/application/form/FormStandardApplicationServiceImpl.java +++ b/eiam-application/eiam-application-form/src/main/java/cn/topiam/employee/application/form/FormStandardApplicationServiceImpl.java @@ -21,7 +21,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import cn.topiam.employee.common.repository.app.AppGroupAssociationRepository; import org.springframework.stereotype.Component; import com.fasterxml.jackson.databind.ObjectMapper; @@ -36,6 +35,7 @@ import cn.topiam.employee.common.entity.app.po.AppFormConfigPO; import cn.topiam.employee.common.enums.app.*; import cn.topiam.employee.common.repository.app.AppAccountRepository; import cn.topiam.employee.common.repository.app.AppFormConfigRepository; +import cn.topiam.employee.common.repository.app.AppGroupAssociationRepository; import cn.topiam.employee.common.repository.app.AppRepository; import cn.topiam.employee.support.exception.TopIamException; import cn.topiam.employee.support.validation.ValidationUtils; diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/entity/app/AppGroupEntity.java b/eiam-common/src/main/java/cn/topiam/employee/common/entity/app/AppGroupEntity.java index 95576907..17f60583 100644 --- a/eiam-common/src/main/java/cn/topiam/employee/common/entity/app/AppGroupEntity.java +++ b/eiam-common/src/main/java/cn/topiam/employee/common/entity/app/AppGroupEntity.java @@ -20,6 +20,7 @@ package cn.topiam.employee.common.entity.app; import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.Where; +import cn.topiam.employee.common.enums.app.AppGroupType; import cn.topiam.employee.support.repository.domain.LogicDeleteEntity; import lombok.Getter; @@ -53,11 +54,17 @@ public class AppGroupEntity extends LogicDeleteEntity { * 分组名称 */ @Column(name = "name_") - private String name; + private String name; /** * 分组编码 */ @Column(name = "code_") - private String code; + private String code; + + /** + * 分组类型 + */ + @Column(name = "type_") + private AppGroupType type; } diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/enums/app/AppGroupType.java b/eiam-common/src/main/java/cn/topiam/employee/common/enums/app/AppGroupType.java new file mode 100644 index 00000000..2bb4a120 --- /dev/null +++ b/eiam-common/src/main/java/cn/topiam/employee/common/enums/app/AppGroupType.java @@ -0,0 +1,76 @@ +/* + * eiam-common - Employee Identity and Access Management + * Copyright © 2022-Present Jinan Yuanchuang Network Technology Co., Ltd. (support@topiam.cn) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package cn.topiam.employee.common.enums.app; + +import com.fasterxml.jackson.annotation.JsonValue; + +import cn.topiam.employee.support.enums.BaseEnum; +import cn.topiam.employee.support.web.converter.EnumConvert; + +/** + * 应用分组类型 + * + * @author TopIAM + * Created by support@topiam.cn on 2023/9/9 16:22 + */ +public enum AppGroupType implements BaseEnum { + /** + * 默认分组 + */ + DEFAULT("default", "默认分组"), + /** + * 自定义分组 + */ + CUSTOM("custom", "自定义分组"); + + @JsonValue + private final String code; + private final String desc; + + AppGroupType(String code, String desc) { + this.code = code; + this.desc = desc; + } + + @Override + public String getCode() { + return code; + } + + @Override + public String getDesc() { + return desc; + } + + /** + * 获取类型 + * + * @param code {@link String} + * @return {@link AppGroupType} + */ + @EnumConvert + public static AppGroupType getType(String code) { + AppGroupType[] values = values(); + for (AppGroupType status : values) { + if (String.valueOf(status.getCode()).equals(code)) { + return status; + } + } + return null; + } +} diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/enums/app/converter/AppGroupTypeConverter.java b/eiam-common/src/main/java/cn/topiam/employee/common/enums/app/converter/AppGroupTypeConverter.java new file mode 100644 index 00000000..bf2ed40c --- /dev/null +++ b/eiam-common/src/main/java/cn/topiam/employee/common/enums/app/converter/AppGroupTypeConverter.java @@ -0,0 +1,67 @@ +/* + * eiam-common - Employee Identity and Access Management + * Copyright © 2022-Present Jinan Yuanchuang Network Technology Co., Ltd. (support@topiam.cn) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package cn.topiam.employee.common.enums.app.converter; + +import java.util.Objects; + +import cn.topiam.employee.common.enums.app.AppGroupType; + +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Converter; + +/** + * @author TopIAM + * Created by support@topiam.cn on 2023/9/9 16:23 + */ +@Converter(autoApply = true) +public class AppGroupTypeConverter implements AttributeConverter { + + /** + * Converts the value stored in the entity attribute into the + * data representation to be stored in the database. + * + * @param attribute the entity attribute value to be converted + * @return the converted data to be stored in the database + * column + */ + @Override + public String convertToDatabaseColumn(AppGroupType attribute) { + if (!Objects.isNull(attribute)) { + return attribute.getCode(); + } + return null; + } + + /** + * Converts the data stored in the database column into the + * value to be stored in the entity attribute. + * Note that it is the responsibility of the converter writer to + * specify the correct dbData type for the corresponding + * column for use by the JDBC driver: i.e., persistence providers are + * not expected to do such type conversion. + * + * @param dbData the data from the database column to be + * converted + * @return the converted value to be stored in the entity + * attribute + */ + @Override + public AppGroupType convertToEntityAttribute(String dbData) { + return AppGroupType.getType(dbData); + } +} diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/AppGroupRepository.java b/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/AppGroupRepository.java index 07007087..91090f5f 100644 --- a/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/AppGroupRepository.java +++ b/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/AppGroupRepository.java @@ -24,12 +24,10 @@ import org.jetbrains.annotations.NotNull; import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; -import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.querydsl.QuerydslPredicateExecutor; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; -import org.springframework.transaction.annotation.Transactional; import cn.topiam.employee.common.entity.app.AppGroupEntity; import cn.topiam.employee.support.repository.LogicDeleteRepository; @@ -56,20 +54,6 @@ public interface AppGroupRepository extends LogicDeleteRepository S save(@NotNull S entity); - /** - * 更新应用分组状态 - * - * @param id {@link Long} - * @param enabled {@link Boolean} - * @return {@link Boolean} - */ - @Modifying - @CacheEvict(allEntries = true) - @Transactional(rollbackFor = Exception.class) - @Query(value = "UPDATE app_group SET is_enabled = :enabled WHERE id_ = :id", nativeQuery = true) - Integer updateAppGroupStatus(@Param(value = "id") Long id, - @Param(value = "enabled") Boolean enabled); - /** * delete * diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/AppGroupRepositoryCustomizedImpl.java b/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/AppGroupRepositoryCustomizedImpl.java index a88b647c..8de124b1 100644 --- a/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/AppGroupRepositoryCustomizedImpl.java +++ b/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/AppGroupRepositoryCustomizedImpl.java @@ -58,6 +58,7 @@ public class AppGroupRepositoryCustomizedImpl implements AppGroupRepositoryCusto `group`.id_, `group`.name_, `group`.code_, + `group`.type_, `group`.create_time, `group`.remark_, IFNULL( ass.app_count, 0 ) AS app_count diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/mapper/AppGroupPoMapper.java b/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/mapper/AppGroupPoMapper.java index fa06687a..371661f7 100644 --- a/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/mapper/AppGroupPoMapper.java +++ b/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/mapper/AppGroupPoMapper.java @@ -24,6 +24,7 @@ import java.time.LocalDateTime; import org.springframework.jdbc.core.RowMapper; import cn.topiam.employee.common.entity.app.po.AppGroupPO; +import cn.topiam.employee.common.enums.app.AppGroupType; /** * @author TopIAM @@ -47,8 +48,9 @@ public class AppGroupPoMapper implements RowMapper { public AppGroupPO mapRow(ResultSet rs, int rowNum) throws SQLException { AppGroupPO appGroup = new AppGroupPO(); appGroup.setId(rs.getLong("id_")); - appGroup.setCode(rs.getString("code_")); appGroup.setName(rs.getString("name_")); + appGroup.setCode(rs.getString("code_")); + appGroup.setType(AppGroupType.getType(rs.getString("type_"))); appGroup.setRemark(rs.getString("remark_")); appGroup.setAppCount(rs.getInt("app_count")); appGroup.setCreateTime(rs.getObject("create_time", LocalDateTime.class)); diff --git a/eiam-common/src/main/resources/db/1.1.0-changelog.xml b/eiam-common/src/main/resources/db/1.1.0-changelog.xml index 9bdb8ac3..ceb1a98d 100644 --- a/eiam-common/src/main/resources/db/1.1.0-changelog.xml +++ b/eiam-common/src/main/resources/db/1.1.0-changelog.xml @@ -35,6 +35,9 @@ + + + diff --git a/eiam-console/src/main/java/cn/topiam/employee/console/controller/app/AppGroupController.java b/eiam-console/src/main/java/cn/topiam/employee/console/controller/app/AppGroupController.java index 4969c3fd..49d3993a 100644 --- a/eiam-console/src/main/java/cn/topiam/employee/console/controller/app/AppGroupController.java +++ b/eiam-console/src/main/java/cn/topiam/employee/console/controller/app/AppGroupController.java @@ -143,41 +143,7 @@ public class AppGroupController { } /** - * 启用应用分组 - * - * @param id {@link String} - * @return {@link Boolean} - */ - @Lock - @Preview - @Operation(summary = "启用应用分组") - @Audit(type = EventType.ENABLE_APP_GROUP) - @PutMapping(value = "/enable/{id}") - @PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)") - public ApiRestResult enableAppGroup(@PathVariable(value = "id") String id) { - boolean result = appGroupService.enableAppGroup(id); - return ApiRestResult. builder().result(result).build(); - } - - /** - * 禁用应用分组 - * - * @param id {@link String} - * @return {@link Boolean} - */ - @Lock - @Preview - @Operation(summary = "禁用应用分组") - @Audit(type = EventType.DISABLE_APP_GROUP) - @PutMapping(value = "/disable/{id}") - @PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)") - public ApiRestResult disableAppGroup(@PathVariable(value = "id") String id) { - boolean result = appGroupService.disableAppGroup(id); - return ApiRestResult. builder().result(result).build(); - } - - /** - * 移除分组用户 + * 移除应用组关联 * * @param id {@link String} * @return {@link Boolean} diff --git a/eiam-console/src/main/java/cn/topiam/employee/console/pojo/result/app/AppGroupListResult.java b/eiam-console/src/main/java/cn/topiam/employee/console/pojo/result/app/AppGroupListResult.java index cc845b88..3471caef 100644 --- a/eiam-console/src/main/java/cn/topiam/employee/console/pojo/result/app/AppGroupListResult.java +++ b/eiam-console/src/main/java/cn/topiam/employee/console/pojo/result/app/AppGroupListResult.java @@ -20,6 +20,8 @@ package cn.topiam.employee.console.pojo.result.app; import java.io.Serializable; import java.time.LocalDateTime; +import cn.topiam.employee.common.enums.app.AppGroupType; + import lombok.Data; import io.swagger.v3.oas.annotations.Parameter; @@ -53,6 +55,12 @@ public class AppGroupListResult implements Serializable { @Parameter(description = "分组编码") private String code; + /** + * 分组类型 + */ + @Parameter(description = "分组类型") + private AppGroupType type; + /** * 创建时间 */ diff --git a/eiam-console/src/main/java/cn/topiam/employee/console/pojo/save/app/AppGroupCreateParam.java b/eiam-console/src/main/java/cn/topiam/employee/console/pojo/save/app/AppGroupCreateParam.java index 4982a1cd..cccc97fa 100644 --- a/eiam-console/src/main/java/cn/topiam/employee/console/pojo/save/app/AppGroupCreateParam.java +++ b/eiam-console/src/main/java/cn/topiam/employee/console/pojo/save/app/AppGroupCreateParam.java @@ -21,7 +21,6 @@ import java.io.Serializable; import lombok.Data; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; diff --git a/eiam-console/src/main/java/cn/topiam/employee/console/service/app/AppGroupService.java b/eiam-console/src/main/java/cn/topiam/employee/console/service/app/AppGroupService.java index 2e9ce2a7..cb2bbccb 100644 --- a/eiam-console/src/main/java/cn/topiam/employee/console/service/app/AppGroupService.java +++ b/eiam-console/src/main/java/cn/topiam/employee/console/service/app/AppGroupService.java @@ -80,31 +80,6 @@ public interface AppGroupService { */ AppGroupGetResult getAppGroup(Long id); - /** - * 启用应用分组 - * - * @param id {@link String} - * @return {@link Boolean} - */ - Boolean enableAppGroup(String id); - - /** - * 禁用应用分组 - * - * @param id {@link String} - * @return {@link Boolean} - */ - Boolean disableAppGroup(String id); - - /** - * 添加应用 - * - * @param appIds {@link String} - * @param groupId {@link String} - * @return {@link Boolean} - */ - Boolean addAssociation(String groupId, String[] appIds); - /** * 批量移除应用 * diff --git a/eiam-console/src/main/java/cn/topiam/employee/console/service/app/impl/AppGroupServiceImpl.java b/eiam-console/src/main/java/cn/topiam/employee/console/service/app/impl/AppGroupServiceImpl.java index 585e584b..0cfacb38 100644 --- a/eiam-console/src/main/java/cn/topiam/employee/console/service/app/impl/AppGroupServiceImpl.java +++ b/eiam-console/src/main/java/cn/topiam/employee/console/service/app/impl/AppGroupServiceImpl.java @@ -18,7 +18,6 @@ package cn.topiam.employee.console.service.app.impl; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Optional; @@ -26,17 +25,15 @@ import org.springframework.data.domain.PageRequest; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.google.common.collect.Lists; - import cn.topiam.employee.audit.context.AuditContext; import cn.topiam.employee.audit.entity.Target; import cn.topiam.employee.audit.enums.TargetType; import cn.topiam.employee.common.entity.app.AppEntity; -import cn.topiam.employee.common.entity.app.AppGroupAssociationEntity; import cn.topiam.employee.common.entity.app.AppGroupEntity; import cn.topiam.employee.common.entity.app.po.AppGroupPO; import cn.topiam.employee.common.entity.app.query.AppGroupAssociationListQuery; import cn.topiam.employee.common.entity.app.query.AppGroupQuery; +import cn.topiam.employee.common.enums.app.AppGroupType; import cn.topiam.employee.common.repository.app.AppGroupAssociationRepository; import cn.topiam.employee.common.repository.app.AppGroupRepository; import cn.topiam.employee.console.converter.app.AppConverter; @@ -93,6 +90,7 @@ public class AppGroupServiceImpl implements AppGroupService { @Transactional(rollbackFor = Exception.class) public Boolean createAppGroup(AppGroupCreateParam param) { AppGroupEntity entity = appGroupConverter.appGroupCreateParamConvertToEntity(param); + entity.setType(AppGroupType.CUSTOM); appGroupRepository.save(entity); AuditContext.setTarget( Target.builder().id(String.valueOf(entity.getId())).type(TargetType.APP_GROUP).build()); @@ -149,34 +147,6 @@ public class AppGroupServiceImpl implements AppGroupService { } - /** - * 启用应用分组 - * - * @param id {@link String} - * @return {@link Boolean} - */ - @Override - public Boolean enableAppGroup(String id) { - appGroupRequireNonNull(Long.valueOf(id)); - Integer count = appGroupRepository.updateAppGroupStatus(Long.valueOf(id), Boolean.TRUE); - AuditContext.setTarget(Target.builder().id(id).type(TargetType.APP_GROUP).build()); - return count > 0; - } - - /** - * 禁用应用分组 - * - * @param id {@link String} - * @return {@link Boolean} - */ - @Override - public Boolean disableAppGroup(String id) { - appGroupRequireNonNull(Long.valueOf(id)); - Integer count = appGroupRepository.updateAppGroupStatus(Long.valueOf(id), Boolean.FALSE); - AuditContext.setTarget(Target.builder().id(id).type(TargetType.APP_GROUP).build()); - return count > 0; - } - /** * 查询并检查分组是否为空,非空返回 * @@ -193,38 +163,6 @@ public class AppGroupServiceImpl implements AppGroupService { return optional.get(); } - /** - * 添加应用 - * - * @param appIds {@link String} - * @param groupId {@link String} - * @return {@link Boolean} - */ - @Override - public Boolean addAssociation(String groupId, String[] appIds) { - Optional optional = appGroupRepository.findById(Long.valueOf(groupId)); - //用户组不存在 - if (optional.isEmpty()) { - AuditContext.setContent("操作失败,应用组不存在"); - log.warn(AuditContext.getContent()); - throw new TopIamException(AuditContext.getContent()); - } - List list = new ArrayList<>(); - Lists.newArrayList(appIds).forEach(id -> { - AppGroupAssociationEntity member = new AppGroupAssociationEntity(); - member.setGroupId(Long.valueOf(groupId)); - member.setAppId(Long.valueOf(id)); - list.add(member); - }); - //添加 - appGroupAssociationRepository.saveAll(list); - List targets = new ArrayList<>(Arrays.stream(appIds) - .map(i -> Target.builder().id(i).type(TargetType.APPLICATION).build()).toList()); - targets.add(Target.builder().id(groupId).type(TargetType.APP_GROUP).build()); - AuditContext.setTarget(targets); - return true; - } - /** * 批量移除应用 *