diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/entity/app/query/GetAppListQuery.java b/eiam-common/src/main/java/cn/topiam/employee/common/entity/app/query/GetAppListQuery.java index 7eec7900..59d59076 100644 --- a/eiam-common/src/main/java/cn/topiam/employee/common/entity/app/query/GetAppListQuery.java +++ b/eiam-common/src/main/java/cn/topiam/employee/common/entity/app/query/GetAppListQuery.java @@ -1,5 +1,5 @@ /* - * eiam-portal - Employee Identity and Access Management + * 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 @@ -20,11 +20,11 @@ package cn.topiam.employee.common.entity.app.query; import java.io.Serial; import java.io.Serializable; -import io.swagger.v3.oas.annotations.Parameter; import org.springdoc.core.annotations.ParameterObject; import lombok.Data; +import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; /** diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/impl/UserGroupMemberRepositoryCustomizedImpl.java b/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/impl/UserGroupMemberRepositoryCustomizedImpl.java index cd80a11a..b1d00381 100644 --- a/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/impl/UserGroupMemberRepositoryCustomizedImpl.java +++ b/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/impl/UserGroupMemberRepositoryCustomizedImpl.java @@ -18,6 +18,7 @@ package cn.topiam.employee.common.repository.account.impl; import java.util.List; +import java.util.Objects; import org.apache.commons.lang3.StringUtils; import org.springframework.data.domain.Page; @@ -105,7 +106,7 @@ public class UserGroupMemberRepositoryCustomizedImpl implements String countSql = "SELECT count(*) FROM (" + sql + ") user_"; //@formatter:on Integer count = jdbcTemplate.queryForObject(countSql, Integer.class); - return new PageImpl<>(list, pageable, count); + return new PageImpl<>(list, pageable, Objects.requireNonNull(count).longValue()); } private final JdbcTemplate jdbcTemplate; diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/impl/UserRepositoryCustomizedImpl.java b/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/impl/UserRepositoryCustomizedImpl.java index 00d7ff54..333eee86 100644 --- a/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/impl/UserRepositoryCustomizedImpl.java +++ b/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/impl/UserRepositoryCustomizedImpl.java @@ -129,7 +129,7 @@ public class UserRepositoryCustomizedImpl implements UserRepositoryCustomized { String countSql = "SELECT count(*) FROM (" + sql + ") user_"; //@formatter:on Integer count = jdbcTemplate.queryForObject(countSql, Integer.class); - return new PageImpl<>(list, pageable, count); + return new PageImpl<>(list, pageable, Objects.requireNonNull(count).longValue()); } /** @@ -203,7 +203,7 @@ public class UserRepositoryCustomizedImpl implements UserRepositoryCustomized { String countSql = "SELECT COUNT(*) FROM(" + sql + ") user_"; //@formatter:on Integer count = jdbcTemplate.queryForObject(countSql, Integer.class); - return new PageImpl<>(list, pageable, count); + return new PageImpl<>(list, pageable, Objects.requireNonNull(count).longValue()); } /** diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/AppRepositoryCustomized.java b/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/AppRepositoryCustomized.java index 6665bc28..3324b038 100644 --- a/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/AppRepositoryCustomized.java +++ b/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/AppRepositoryCustomized.java @@ -19,12 +19,12 @@ package cn.topiam.employee.common.repository.app; import java.util.List; -import cn.topiam.employee.common.entity.app.query.GetAppListQuery; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import cn.topiam.employee.common.entity.app.AppEntity; import cn.topiam.employee.common.entity.app.query.AppQuery; +import cn.topiam.employee.common.entity.app.query.GetAppListQuery; /** * 应用 Repository Customized diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/AppAccessPolicyRepositoryCustomizedImpl.java b/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/AppAccessPolicyRepositoryCustomizedImpl.java index aa5689e9..bfabe9d6 100644 --- a/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/AppAccessPolicyRepositoryCustomizedImpl.java +++ b/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/AppAccessPolicyRepositoryCustomizedImpl.java @@ -133,7 +133,7 @@ public class AppAccessPolicyRepositoryCustomizedImpl implements String countSql = "SELECT count(*) FROM (" + sql + ") app_access_policy_"; //@formatter:on Integer count = jdbcTemplate.queryForObject(countSql, Integer.class); - return new PageImpl<>(list, pageable, count); + return new PageImpl<>(list, pageable, Objects.requireNonNull(count).longValue()); } /** diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/AppAccountRepositoryCustomizedImpl.java b/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/AppAccountRepositoryCustomizedImpl.java index 43a8a450..6179da95 100644 --- a/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/AppAccountRepositoryCustomizedImpl.java +++ b/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/AppAccountRepositoryCustomizedImpl.java @@ -18,6 +18,7 @@ package cn.topiam.employee.common.repository.app.impl; import java.util.List; +import java.util.Objects; import org.apache.commons.lang3.StringUtils; import org.springframework.data.domain.Page; @@ -106,7 +107,7 @@ public class AppAccountRepositoryCustomizedImpl implements AppAccountRepositoryC String countSql = "SELECT count(*) FROM (" + sql + ") app_account_"; //@formatter:on Integer count = jdbcTemplate.queryForObject(countSql, Integer.class); - return new PageImpl<>(list, pageable, count); + return new PageImpl<>(list, pageable, Objects.requireNonNull(count).longValue()); } /** diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/AppGroupAssociationRepositoryCustomizedImpl.java b/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/AppGroupAssociationRepositoryCustomizedImpl.java index dd6e76ee..2aad95b1 100644 --- a/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/AppGroupAssociationRepositoryCustomizedImpl.java +++ b/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/AppGroupAssociationRepositoryCustomizedImpl.java @@ -18,6 +18,7 @@ package cn.topiam.employee.common.repository.app.impl; import java.util.List; +import java.util.Objects; import org.apache.commons.lang3.StringUtils; import org.springframework.data.domain.Page; @@ -77,7 +78,7 @@ public class AppGroupAssociationRepositoryCustomizedImpl implements String countSql = "SELECT count(*) FROM (" + sql + ") app_"; //@formatter:on Integer count = jdbcTemplate.queryForObject(countSql, Integer.class); - return new PageImpl<>(list, pageable, count); + return new PageImpl<>(list, pageable, Objects.requireNonNull(count).longValue()); } private final JdbcTemplate jdbcTemplate; 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 eba16a39..50e6161f 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 @@ -18,6 +18,7 @@ package cn.topiam.employee.common.repository.app.impl; import java.util.List; +import java.util.Objects; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -44,15 +45,38 @@ import lombok.AllArgsConstructor; public class AppGroupRepositoryCustomizedImpl implements AppGroupRepositoryCustomized { /** - * 获取应用组应用列表 + * 获取应用组应用列表(分页) * * @param query {@link UserGroupMemberListQuery} * @param pageable {@link Pageable} * @return {@link Page} */ - @SuppressWarnings("DuplicatedCode") @Override public Page getAppGroupList(AppGroupQuery query, Pageable pageable) { + StringBuilder builder = getBaseAppGroupListSql(query); + String sql = getBaseAppGroupListSql(query).toString(); + List list = jdbcTemplate.query( + builder.append(" LIMIT ").append(pageable.getPageNumber() * pageable.getPageSize()) + .append(",").append(pageable.getPageSize()).toString(), + new AppGroupPoMapper()); + //@formatter:off + String countSql = "SELECT count(*) FROM (" + sql + ") app_"; + //@formatter:on + Integer count = jdbcTemplate.queryForObject(countSql, Integer.class); + return new PageImpl<>(list, pageable, Objects.requireNonNull(count).longValue()); + } + + /** + * 查询应用组列表(不分页) + * + * @return {@link List} + */ + @Override + public List getAppGroupList(AppGroupQuery query) { + return jdbcTemplate.query(getBaseAppGroupListSql(query).toString(), new AppGroupPoMapper()); + } + + private StringBuilder getBaseAppGroupListSql(AppGroupQuery query) { //@formatter:off StringBuilder builder = new StringBuilder("SELECT `group`.id_, `group`.name_, `group`.code_, `group`.type_, `group`.create_time, `group`.remark_, IFNULL( ass.app_count, 0) AS app_count FROM app_group `group` LEFT JOIN(SELECT aga.group_id, COUNT(*) AS `app_count` FROM app_group_association aga INNER JOIN app ON aga.app_id = app.id_ AND app.is_deleted = 0 GROUP BY aga.group_id ) ass ON `group`.id_ = ass.group_id WHERE is_deleted = '0'"); //分组名称 @@ -69,43 +93,7 @@ public class AppGroupRepositoryCustomizedImpl implements AppGroupRepositoryCusto } builder.append(" ORDER BY `group`.create_time DESC"); //@formatter:on - String sql = builder.toString(); - List list = jdbcTemplate.query( - builder.append(" LIMIT ").append(pageable.getPageNumber() * pageable.getPageSize()) - .append(",").append(pageable.getPageSize()).toString(), - new AppGroupPoMapper()); - //@formatter:off - String countSql = "SELECT count(*) FROM (" + sql + ") app_"; - //@formatter:on - Integer count = jdbcTemplate.queryForObject(countSql, Integer.class); - return new PageImpl<>(list, pageable, count); - } - - /** - * 查询应用组列表 - * - * @return {@link List} - */ - @Override - public List getAppGroupList(AppGroupQuery query) { - //@formatter:off - StringBuilder builder = new StringBuilder("SELECT `group`.id_, `group`.name_, `group`.code_, `group`.type_, `group`.create_time, `group`.remark_, IFNULL( ass.app_count, 0) AS app_count FROM app_group `group` LEFT JOIN(SELECT aga.group_id, COUNT(*) AS `app_count` FROM app_group_association aga WHERE aga.is_deleted = '0' GROUP BY aga.group_id ) ass ON `group`.id_ = ass.group_id WHERE is_deleted = '0'"); - //分组名称 - if (StringUtils.isNoneBlank(query.getName())) { - builder.append(" AND `group`.name_ like '%").append(query.getName()).append("%'"); - } - //分组编码 - if (StringUtils.isNoneBlank(query.getCode())) { - builder.append(" AND `group`.code_ like '%").append(query.getCode()).append("%'"); - } - //分组类型 - if (ObjectUtils.isNotEmpty(query.getType())) { - builder.append(" AND `group`.type_ like '%").append(query.getType().getCode()).append("%'"); - } - builder.append(" ORDER BY `group`.create_time DESC"); - //@formatter:on - List list = jdbcTemplate.query(builder.toString(), new AppGroupPoMapper()); - return list; + return builder; } private final JdbcTemplate jdbcTemplate; diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/AppRepositoryCustomizedImpl.java b/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/AppRepositoryCustomizedImpl.java index 23dd7a63..21340470 100644 --- a/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/AppRepositoryCustomizedImpl.java +++ b/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/AppRepositoryCustomizedImpl.java @@ -22,7 +22,6 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import cn.topiam.employee.common.entity.app.query.GetAppListQuery; import org.apache.commons.lang3.StringUtils; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -37,12 +36,14 @@ import cn.topiam.employee.common.entity.account.OrganizationMemberEntity; import cn.topiam.employee.common.entity.account.UserGroupMemberEntity; import cn.topiam.employee.common.entity.app.AppEntity; import cn.topiam.employee.common.entity.app.query.AppQuery; +import cn.topiam.employee.common.entity.app.query.GetAppListQuery; import cn.topiam.employee.common.repository.account.OrganizationMemberRepository; import cn.topiam.employee.common.repository.account.UserGroupMemberRepository; import cn.topiam.employee.common.repository.app.AppRepositoryCustomized; import cn.topiam.employee.common.repository.app.impl.mapper.AppEntityMapper; import lombok.AllArgsConstructor; +import static cn.topiam.employee.common.enums.app.AuthorizationType.ALL_ACCESS; /** * App Repository Customized @@ -58,8 +59,8 @@ public class AppRepositoryCustomizedImpl implements AppRepositoryCustomized { * 获取我的应用列表 * * @param userId {@link Long} - * @param query {@link query} - * @param pageable {@link String} + * @param query {@link GetAppListQuery} + * @param pageable {@link Pageable} * @return {@link List} */ @Override @@ -77,18 +78,7 @@ public class AppRepositoryCustomizedImpl implements AppRepositoryCustomized { Map paramMap = new HashMap<>(16); paramMap.put("subjectIds", paramList); //@formatter:off - StringBuilder builder = new StringBuilder(""" - SELECT DISTINCT - app.* - FROM - app - LEFT JOIN app_access_policy app_acce ON app.id_ = app_acce.app_id AND app_acce.is_deleted = '0' - LEFT JOIN app_group_association ass ON app.id_ = ass.app_id AND ass.is_deleted = '0' - WHERE - app.is_enabled = 1 - AND app.is_deleted = '0' - AND (app_acce.subject_id IN (:subjectIds) OR app.authorization_type = 'all_access') - """); + StringBuilder builder = new StringBuilder("SELECT DISTINCT app.* FROM app LEFT JOIN app_access_policy app_acce ON app.id_ = app_acce.app_id AND app_acce.is_deleted = '0' LEFT JOIN app_group_association ass ON app.id_ = ass.app_id AND ass.is_deleted = '0' WHERE app.is_enabled = 1 AND app.is_deleted = '0' AND (app_acce.subject_id IN (:subjectIds) OR app.authorization_type = '"+ALL_ACCESS.getCode()+"')"); //用户名 if (StringUtils.isNoneBlank(query.getName())) { builder.append(" AND app.name_ like '%").append(query.getName()).append("%'"); @@ -108,7 +98,7 @@ public class AppRepositoryCustomizedImpl implements AppRepositoryCustomized { //@formatter:on Integer count = namedParameterJdbcTemplate.queryForObject(countSql, paramMap, Integer.class); - return new PageImpl<>(list, pageable, count); + return new PageImpl<>(list, pageable, Objects.requireNonNull(count).longValue()); } /** @@ -118,6 +108,7 @@ public class AppRepositoryCustomizedImpl implements AppRepositoryCustomized { * @param pageable {@link Pageable} * @return {@link List} */ + @Override public Page getAppList(AppQuery appQuery, Pageable pageable) { //@formatter:off StringBuilder builder = new StringBuilder("SELECT DISTINCT app.* FROM app LEFT JOIN app_group_association `group` ON app.id_ = `group`.app_id WHERE app.is_deleted =0"); @@ -145,7 +136,7 @@ public class AppRepositoryCustomizedImpl implements AppRepositoryCustomized { String countSql = "SELECT count(*) FROM (" + sql + ") app_account_"; //@formatter:on Integer count = jdbcTemplate.queryForObject(countSql, Integer.class); - return new PageImpl<>(list, pageable, count); + return new PageImpl<>(list, pageable, Objects.requireNonNull(count).longValue()); } /** diff --git a/eiam-console/src/main/console-fe/package.json b/eiam-console/src/main/console-fe/package.json index f4b96ecd..88147ade 100644 --- a/eiam-console/src/main/console-fe/package.json +++ b/eiam-console/src/main/console-fe/package.json @@ -49,7 +49,7 @@ "@ant-design/maps": "^1.0.7", "@ant-design/pro-components": "^2.6.24", "ahooks": "^3.7.8", - "antd": "^5.9.2", + "antd": "^5.9.3", "antd-img-crop": "^4.13.0", "antd-style": "^3.5.0", "classnames": "^2.3.2", diff --git a/eiam-portal/src/main/java/cn/topiam/employee/portal/service/impl/AppServiceImpl.java b/eiam-portal/src/main/java/cn/topiam/employee/portal/service/impl/AppServiceImpl.java index 5da76eb4..b0379584 100644 --- a/eiam-portal/src/main/java/cn/topiam/employee/portal/service/impl/AppServiceImpl.java +++ b/eiam-portal/src/main/java/cn/topiam/employee/portal/service/impl/AppServiceImpl.java @@ -25,11 +25,11 @@ import org.springframework.stereotype.Service; import cn.topiam.employee.common.entity.app.AppEntity; import cn.topiam.employee.common.entity.app.po.AppGroupPO; import cn.topiam.employee.common.entity.app.query.AppGroupQuery; +import cn.topiam.employee.common.entity.app.query.GetAppListQuery; import cn.topiam.employee.common.repository.app.AppGroupRepository; import cn.topiam.employee.common.repository.app.AppRepository; import cn.topiam.employee.portal.converter.AppConverter; import cn.topiam.employee.portal.converter.AppGroupConverter; -import cn.topiam.employee.common.entity.app.query.GetAppListQuery; import cn.topiam.employee.portal.pojo.result.AppGroupListResult; import cn.topiam.employee.portal.pojo.result.GetAppListResult; import cn.topiam.employee.portal.service.AppService; @@ -63,13 +63,12 @@ public class AppServiceImpl implements AppService { /** * 查询应用分组 * - * @param appGroupQuery {@link AppGroupQuery} + * @param query {@link AppGroupQuery} * @return {@link AppGroupListResult} */ @Override - public List getAppGroupList(AppGroupQuery appGroupQuery) { - //查询映射 - List list = appGroupRepository.getAppGroupList(appGroupQuery); + public List getAppGroupList(AppGroupQuery query) { + List list = appGroupRepository.getAppGroupList(query); return appGroupConverter.entityConvertToAppGroupListResult(list); } diff --git a/eiam-portal/src/main/portal-fe/package.json b/eiam-portal/src/main/portal-fe/package.json index a5676d4b..493ce1c5 100644 --- a/eiam-portal/src/main/portal-fe/package.json +++ b/eiam-portal/src/main/portal-fe/package.json @@ -50,7 +50,7 @@ "@ant-design/maps": "^1.0.7", "@ant-design/pro-components": "^2.6.24", "ahooks": "^3.7.8", - "antd": "^5.9.2", + "antd": "^5.9.3", "antd-img-crop": "^4.13.0", "antd-style": "^3.5.0", "classnames": "^2.3.2", diff --git a/eiam-portal/src/main/portal-fe/src/pages/Application/locales/zh-CN.ts b/eiam-portal/src/main/portal-fe/src/pages/Application/locales/zh-CN.ts index 94f0bf6e..1c0d1cd5 100644 --- a/eiam-portal/src/main/portal-fe/src/pages/Application/locales/zh-CN.ts +++ b/eiam-portal/src/main/portal-fe/src/pages/Application/locales/zh-CN.ts @@ -17,6 +17,7 @@ */ export default { 'pages.application.search.name': '应用名称', + 'pages.application.group_all': '全部', 'pages.application.tab.list': '应用列表', 'pages.application.tab.account': '应用账号', 'pages.application.init.warning': '仅允许应用发起',