From 6cb2c043ccc38c42fbe4bfbd898c79fe9cdd75fe Mon Sep 17 00:00:00 2001 From: shao1121353141 <> Date: Wed, 13 Sep 2023 21:52:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=94=E7=94=A8=E8=AF=A6=E6=83=85=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=BA=94=E7=94=A8=E7=BB=84ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/AppGroupAssociationRepository.java | 13 +++++++++++++ .../console/converter/app/AppConverter.java | 4 +++- .../console/pojo/result/app/AppGetResult.java | 8 ++++++++ .../console/service/app/impl/AppServiceImpl.java | 3 ++- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/AppGroupAssociationRepository.java b/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/AppGroupAssociationRepository.java index f2cecfa7..0f8613b7 100644 --- a/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/AppGroupAssociationRepository.java +++ b/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/AppGroupAssociationRepository.java @@ -26,6 +26,9 @@ import org.springframework.transaction.annotation.Transactional; import cn.topiam.employee.common.entity.app.AppGroupAssociationEntity; import cn.topiam.employee.support.repository.LogicDeleteRepository; + +import java.util.List; + import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOFT_DELETE_SET; /** @@ -73,4 +76,14 @@ public interface AppGroupAssociationRepository extends * @param appId {@link Long} */ void deleteByAppId(Long appId); + + + /** + * 根据应用ID 查询关联信息 + * + * @param appId {@link Long} + * @return {@link List} + */ + @Query(value = "SELECT group_id FROM `app_group_association` WHERE app_id = :appId AND is_deleted = '0'", nativeQuery = true) + List findGroupIdByAppId(Long appId); } diff --git a/eiam-console/src/main/java/cn/topiam/employee/console/converter/app/AppConverter.java b/eiam-console/src/main/java/cn/topiam/employee/console/converter/app/AppConverter.java index fd00b4d2..44547323 100644 --- a/eiam-console/src/main/java/cn/topiam/employee/console/converter/app/AppConverter.java +++ b/eiam-console/src/main/java/cn/topiam/employee/console/converter/app/AppConverter.java @@ -135,9 +135,10 @@ public interface AppConverter { * 实体转应用返回 * * @param entity {@link AppEntity} + * @param groupIds {@link List} * @return {@link AppGetResult} */ - default AppGetResult entityConvertToAppResult(AppEntity entity) { + default AppGetResult entityConvertToAppResult(AppEntity entity,List groupIds) { if (entity == null) { return null; } @@ -150,6 +151,7 @@ public interface AppConverter { appGetResult.setClientId(entity.getClientId()); appGetResult.setClientSecret(entity.getClientSecret()); appGetResult.setType(entity.getType()); + appGetResult.setGroupIds(groupIds); //图标未配置,所以先从模版中拿 if (StringUtils.isBlank(entity.getIcon())) { ApplicationService applicationService = getApplicationServiceLoader() diff --git a/eiam-console/src/main/java/cn/topiam/employee/console/pojo/result/app/AppGetResult.java b/eiam-console/src/main/java/cn/topiam/employee/console/pojo/result/app/AppGetResult.java index aeb20e53..9916f7a9 100644 --- a/eiam-console/src/main/java/cn/topiam/employee/console/pojo/result/app/AppGetResult.java +++ b/eiam-console/src/main/java/cn/topiam/employee/console/pojo/result/app/AppGetResult.java @@ -19,6 +19,7 @@ package cn.topiam.employee.console.pojo.result.app; import java.io.Serializable; import java.time.LocalDateTime; +import java.util.List; import cn.topiam.employee.common.enums.app.AppProtocol; import cn.topiam.employee.common.enums.app.AppType; @@ -104,4 +105,11 @@ public class AppGetResult implements Serializable { */ @Parameter(description = "备注") private String remark; + + + /** + * 应用组ID集合 + */ + @Parameter(description = "应用组ID集合") + private List groupIds; } diff --git a/eiam-console/src/main/java/cn/topiam/employee/console/service/app/impl/AppServiceImpl.java b/eiam-console/src/main/java/cn/topiam/employee/console/service/app/impl/AppServiceImpl.java index 14fdfc46..b4ee356e 100644 --- a/eiam-console/src/main/java/cn/topiam/employee/console/service/app/impl/AppServiceImpl.java +++ b/eiam-console/src/main/java/cn/topiam/employee/console/service/app/impl/AppServiceImpl.java @@ -154,7 +154,8 @@ public class AppServiceImpl implements AppService { Optional optional = appRepository.findById(id); if (optional.isPresent()) { AppEntity entity = optional.get(); - return appConverter.entityConvertToAppResult(entity); + List groupIds = appGroupAssociationRepository.findGroupIdByAppId(id); + return appConverter.entityConvertToAppResult(entity,groupIds); } return null;