应用详情返回应用组ID

pull/48/head
shao1121353141 2023-09-13 21:52:59 +08:00
parent 00447e2ede
commit 6cb2c043cc
4 changed files with 26 additions and 2 deletions

View File

@ -26,6 +26,9 @@ import org.springframework.transaction.annotation.Transactional;
import cn.topiam.employee.common.entity.app.AppGroupAssociationEntity; import cn.topiam.employee.common.entity.app.AppGroupAssociationEntity;
import cn.topiam.employee.support.repository.LogicDeleteRepository; import cn.topiam.employee.support.repository.LogicDeleteRepository;
import java.util.List;
import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOFT_DELETE_SET; import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOFT_DELETE_SET;
/** /**
@ -73,4 +76,14 @@ public interface AppGroupAssociationRepository extends
* @param appId {@link Long} * @param appId {@link Long}
*/ */
void deleteByAppId(Long appId); 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<Long> findGroupIdByAppId(Long appId);
} }

View File

@ -135,9 +135,10 @@ public interface AppConverter {
* *
* *
* @param entity {@link AppEntity} * @param entity {@link AppEntity}
* @param groupIds {@link List}
* @return {@link AppGetResult} * @return {@link AppGetResult}
*/ */
default AppGetResult entityConvertToAppResult(AppEntity entity) { default AppGetResult entityConvertToAppResult(AppEntity entity,List<Long> groupIds) {
if (entity == null) { if (entity == null) {
return null; return null;
} }
@ -150,6 +151,7 @@ public interface AppConverter {
appGetResult.setClientId(entity.getClientId()); appGetResult.setClientId(entity.getClientId());
appGetResult.setClientSecret(entity.getClientSecret()); appGetResult.setClientSecret(entity.getClientSecret());
appGetResult.setType(entity.getType()); appGetResult.setType(entity.getType());
appGetResult.setGroupIds(groupIds);
//图标未配置,所以先从模版中拿 //图标未配置,所以先从模版中拿
if (StringUtils.isBlank(entity.getIcon())) { if (StringUtils.isBlank(entity.getIcon())) {
ApplicationService applicationService = getApplicationServiceLoader() ApplicationService applicationService = getApplicationServiceLoader()

View File

@ -19,6 +19,7 @@ package cn.topiam.employee.console.pojo.result.app;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
import cn.topiam.employee.common.enums.app.AppProtocol; import cn.topiam.employee.common.enums.app.AppProtocol;
import cn.topiam.employee.common.enums.app.AppType; import cn.topiam.employee.common.enums.app.AppType;
@ -104,4 +105,11 @@ public class AppGetResult implements Serializable {
*/ */
@Parameter(description = "备注") @Parameter(description = "备注")
private String remark; private String remark;
/**
* ID
*/
@Parameter(description = "应用组ID集合")
private List<Long> groupIds;
} }

View File

@ -154,7 +154,8 @@ public class AppServiceImpl implements AppService {
Optional<AppEntity> optional = appRepository.findById(id); Optional<AppEntity> optional = appRepository.findById(id);
if (optional.isPresent()) { if (optional.isPresent()) {
AppEntity entity = optional.get(); AppEntity entity = optional.get();
return appConverter.entityConvertToAppResult(entity); List<Long> groupIds = appGroupAssociationRepository.findGroupIdByAppId(id);
return appConverter.entityConvertToAppResult(entity,groupIds);
} }
return null; return null;