From 17cfd7fe1cbc89794ab7d24ab02c26a4040ed821 Mon Sep 17 00:00:00 2001 From: shao1121353141 <> Date: Fri, 8 Sep 2023 22:45:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=88=86=E7=BB=84=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/entity/app/AppGroupEntity.java | 10 +- .../common/entity/app/po/AppGroupPO.java | 38 ++++++++ .../entity/app/query}/AppGroupQuery.java | 14 +-- .../repository/app/AppGroupRepository.java | 3 +- .../app/AppGroupRepositoryCustomized.java | 41 ++++++++ .../AppGroupRepositoryCustomizedImpl.java | 94 +++++++++++++++++++ .../app/impl/mapper/AppGroupPoMapper.java | 57 +++++++++++ .../src/main/resources/db/1.1.0-changelog.xml | 1 - .../controller/app/AppGroupController.java | 2 +- .../converter/app/AppGroupConverter.java | 45 ++------- .../console/service/app/AppGroupService.java | 2 +- .../service/app/impl/AppGroupServiceImpl.java | 18 +--- .../portal/converter/AppGroupConverter.java | 5 +- 13 files changed, 255 insertions(+), 75 deletions(-) create mode 100644 eiam-common/src/main/java/cn/topiam/employee/common/entity/app/po/AppGroupPO.java rename {eiam-console/src/main/java/cn/topiam/employee/console/pojo/query/app => eiam-common/src/main/java/cn/topiam/employee/common/entity/app/query}/AppGroupQuery.java (82%) create mode 100644 eiam-common/src/main/java/cn/topiam/employee/common/repository/app/AppGroupRepositoryCustomized.java create mode 100644 eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/AppGroupRepositoryCustomizedImpl.java create mode 100644 eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/mapper/AppGroupPoMapper.java 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 25c14a51..95576907 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 @@ -53,17 +53,11 @@ public class AppGroupEntity extends LogicDeleteEntity { * 分组名称 */ @Column(name = "name_") - private String name; + private String name; /** * 分组编码 */ @Column(name = "code_") - private String code; - - /** - * 是否启用 - */ - @Column(name = "is_enabled") - private Boolean enabled; + private String code; } diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/entity/app/po/AppGroupPO.java b/eiam-common/src/main/java/cn/topiam/employee/common/entity/app/po/AppGroupPO.java new file mode 100644 index 00000000..9acb15f9 --- /dev/null +++ b/eiam-common/src/main/java/cn/topiam/employee/common/entity/app/po/AppGroupPO.java @@ -0,0 +1,38 @@ +/* + * 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.entity.app.po; + +import cn.topiam.employee.common.entity.app.AppGroupEntity; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * + * @author TopIAM + * Created by support@topiam.cn on 2022/12/13 23:45 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class AppGroupPO extends AppGroupEntity { + + /** + * 应用数量 + */ + private Integer appCount; +} diff --git a/eiam-console/src/main/java/cn/topiam/employee/console/pojo/query/app/AppGroupQuery.java b/eiam-common/src/main/java/cn/topiam/employee/common/entity/app/query/AppGroupQuery.java similarity index 82% rename from eiam-console/src/main/java/cn/topiam/employee/console/pojo/query/app/AppGroupQuery.java rename to eiam-common/src/main/java/cn/topiam/employee/common/entity/app/query/AppGroupQuery.java index cfd8169e..74435300 100644 --- a/eiam-console/src/main/java/cn/topiam/employee/console/pojo/query/app/AppGroupQuery.java +++ b/eiam-common/src/main/java/cn/topiam/employee/common/entity/app/query/AppGroupQuery.java @@ -1,5 +1,5 @@ /* - * eiam-console - 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 @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package cn.topiam.employee.console.pojo.query.app; +package cn.topiam.employee.common.entity.app.query; import java.io.Serializable; @@ -41,18 +41,12 @@ public class AppGroupQuery implements Serializable { * 分组名称 */ @Parameter(description = "分组名称") - private String name; - - /** - * 分组是否启用 - */ - @Parameter(description = "分组是否启用") - private Boolean enabled; + private String name; /** * 分组编码 */ @Parameter(description = "分组编码") - private String code; + private String code; } 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 11f08f16..07007087 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 @@ -41,7 +41,8 @@ import static cn.topiam.employee.common.constant.AppGroupConstants.APP_GROUP_CAC @Repository @CacheConfig(cacheNames = { APP_GROUP_CACHE_NAME }) public interface AppGroupRepository extends LogicDeleteRepository, - QuerydslPredicateExecutor { + QuerydslPredicateExecutor, + AppGroupRepositoryCustomized { /** * save diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/AppGroupRepositoryCustomized.java b/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/AppGroupRepositoryCustomized.java new file mode 100644 index 00000000..2317facd --- /dev/null +++ b/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/AppGroupRepositoryCustomized.java @@ -0,0 +1,41 @@ +/* + * 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.repository.app; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +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; + +/** + * @author TopIAM + * Created by support@topiam.cn on 2023/9/8 19:20 + */ +public interface AppGroupRepositoryCustomized { + + /** + * 获取应用组应用列表 + * + * @param query {@link AppGroupAssociationListQuery} + * @param pageable {@link Pageable} + * @return {@link Page} + */ + Page getAppGroupList(AppGroupQuery query, Pageable pageable); +} 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 new file mode 100644 index 00000000..a88b647c --- /dev/null +++ b/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/AppGroupRepositoryCustomizedImpl.java @@ -0,0 +1,94 @@ +/* + * 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.repository.app.impl; + +import java.util.List; + +import org.apache.commons.lang3.StringUtils; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Repository; + +import cn.topiam.employee.common.entity.account.query.UserGroupMemberListQuery; +import cn.topiam.employee.common.entity.app.po.AppGroupPO; +import cn.topiam.employee.common.entity.app.query.AppGroupQuery; +import cn.topiam.employee.common.repository.app.AppGroupRepositoryCustomized; +import cn.topiam.employee.common.repository.app.impl.mapper.AppGroupPoMapper; + +import lombok.AllArgsConstructor; + +/** + * @author TopIAM + * Created by support@topiam.cn on 2023/9/8 19:20 + */ +@Repository +@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) { + //@formatter:off + StringBuilder builder = new StringBuilder(""" + SELECT + `group`.id_, + `group`.name_, + `group`.code_, + `group`.create_time, + `group`.remark_, + IFNULL( ass.app_count, 0 ) AS app_count + FROM + app_group `group` + LEFT JOIN ( SELECT group_id, count(*) AS `app_count` FROM app_group_association GROUP BY 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("%'"); + } + + 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); + } + + private final JdbcTemplate jdbcTemplate; +} 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 new file mode 100644 index 00000000..fa06687a --- /dev/null +++ b/eiam-common/src/main/java/cn/topiam/employee/common/repository/app/impl/mapper/AppGroupPoMapper.java @@ -0,0 +1,57 @@ +/* + * 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.repository.app.impl.mapper; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.time.LocalDateTime; + +import org.springframework.jdbc.core.RowMapper; + +import cn.topiam.employee.common.entity.app.po.AppGroupPO; + +/** + * @author TopIAM + * Created by support@topiam.cn on 2022/2/13 22:25 + */ +public class AppGroupPoMapper implements RowMapper { + + /** + * Implementations must implement this method to map each row of data + * in the ResultSet. This method should not call {@code next()} on + * the ResultSet; it is only supposed to map values of the current row. + * + * @param rs the ResultSet to map (pre-initialized for the current row) + * @param rowNum the number of the current row + * @return the result object for the current row (may be {@code null}) + * @throws SQLException if an SQLException is encountered getting + * column values (that is, there's no need to catch SQLException) + */ + @SuppressWarnings("DuplicatedCode") + @Override + 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.setRemark(rs.getString("remark_")); + appGroup.setAppCount(rs.getInt("app_count")); + appGroup.setCreateTime(rs.getObject("create_time", LocalDateTime.class)); + return appGroup; + } +} 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 3bf2e8ce..9bdb8ac3 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,7 +35,6 @@ - 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 a99ec1fb..a82533b1 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 @@ -28,7 +28,7 @@ import cn.topiam.employee.audit.annotation.Audit; import cn.topiam.employee.audit.event.type.EventType; import cn.topiam.employee.common.entity.account.query.UserGroupMemberListQuery; import cn.topiam.employee.common.entity.app.query.AppGroupAssociationListQuery; -import cn.topiam.employee.console.pojo.query.app.AppGroupQuery; +import cn.topiam.employee.common.entity.app.query.AppGroupQuery; import cn.topiam.employee.console.pojo.result.app.AppGroupGetResult; import cn.topiam.employee.console.pojo.result.app.AppGroupListResult; import cn.topiam.employee.console.pojo.result.app.AppListResult; diff --git a/eiam-console/src/main/java/cn/topiam/employee/console/converter/app/AppGroupConverter.java b/eiam-console/src/main/java/cn/topiam/employee/console/converter/app/AppGroupConverter.java index 3b3f1ee8..7385c535 100644 --- a/eiam-console/src/main/java/cn/topiam/employee/console/converter/app/AppGroupConverter.java +++ b/eiam-console/src/main/java/cn/topiam/employee/console/converter/app/AppGroupConverter.java @@ -18,20 +18,15 @@ package cn.topiam.employee.console.converter.app; import java.util.List; -import java.util.Objects; -import org.apache.commons.lang3.StringUtils; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import com.google.common.collect.Lists; -import com.querydsl.core.types.ExpressionUtils; -import com.querydsl.core.types.Predicate; import cn.topiam.employee.common.entity.app.AppAccountEntity; import cn.topiam.employee.common.entity.app.AppGroupEntity; -import cn.topiam.employee.common.entity.app.QAppGroupEntity; -import cn.topiam.employee.console.pojo.query.app.AppGroupQuery; +import cn.topiam.employee.common.entity.app.po.AppGroupPO; import cn.topiam.employee.console.pojo.result.app.AppGroupGetResult; import cn.topiam.employee.console.pojo.result.app.AppGroupListResult; import cn.topiam.employee.console.pojo.save.app.AppAccountCreateParam; @@ -48,43 +43,25 @@ import cn.topiam.employee.support.repository.page.domain.Page; @Mapper(componentModel = "spring") public interface AppGroupConverter { - /** - * 查询分组列表参数转换为 Querydsl Predicate - * - * @param query {@link AppGroupQuery} query - * @return {@link Predicate} - */ - default Predicate queryAppGroupListParamConvertToPredicate(AppGroupQuery query) { - QAppGroupEntity appGroup = QAppGroupEntity.appGroupEntity; - Predicate predicate = ExpressionUtils.and(appGroup.isNotNull(), - appGroup.deleted.eq(Boolean.FALSE)); - //查询条件 - //@formatter:off - predicate = StringUtils.isBlank(query.getName()) ? predicate : ExpressionUtils.and(predicate, appGroup.name.like("%" + query.getName() + "%")); - predicate = Objects.isNull(query.getEnabled()) ? predicate : ExpressionUtils.and(predicate, appGroup.enabled.eq(query.getEnabled())); - //@formatter:on - return predicate; - } - /** * 实体转换为分组列表结果 * - * @param entityPage {@link List} + * @param appGroupPoPage {@link List} * @return {@link List} */ - default Page entityConvertToAppGroupListResult(org.springframework.data.domain.Page entityPage) { + default Page entityConvertToAppGroupListResult(org.springframework.data.domain.Page appGroupPoPage) { Page page = new Page<>(); List list = Lists.newArrayList(); - for (AppGroupEntity entity : entityPage.getContent()) { - AppGroupListResult result = entityConvertToAppGroupListResult(entity); + for (AppGroupPO po : appGroupPoPage.getContent()) { + AppGroupListResult result = entityConvertToAppGroupListResult(po); list.add(result); } page.setList(list); //@formatter:off page.setPagination(Page.Pagination.builder() - .total(entityPage.getTotalElements()) - .totalPages(entityPage.getTotalPages()) - .current(entityPage.getPageable().getPageNumber() + 1) + .total(appGroupPoPage.getTotalElements()) + .totalPages(appGroupPoPage.getTotalPages()) + .current(appGroupPoPage.getPageable().getPageNumber() + 1) .build()); //@formatter:on return page; @@ -93,10 +70,10 @@ public interface AppGroupConverter { /** * 实体转分组管理列表 * - * @param entity {@link AppGroupEntity} + * @param appGroupPo {@link AppGroupPO} * @return {@link AppGroupListResult} */ - AppGroupListResult entityConvertToAppGroupListResult(AppGroupEntity entity); + AppGroupListResult entityConvertToAppGroupListResult(AppGroupPO appGroupPo); /** * 实体转分组返回 @@ -112,7 +89,6 @@ public interface AppGroupConverter { * @param param {@link AppGroupUpdateParam} * @return {@link AppGroupEntity} */ - @Mapping(target = "enabled", ignore = true) @Mapping(target = "deleted", ignore = true) @Mapping(target = "updateTime", ignore = true) @Mapping(target = "updateBy", ignore = true) @@ -126,7 +102,6 @@ public interface AppGroupConverter { * @param param {@link AppAccountCreateParam} * @return {@link AppAccountEntity} */ - @Mapping(target = "enabled", expression = "java(Boolean.TRUE)") @Mapping(target = "deleted", ignore = true) @Mapping(target = "id", ignore = true) @Mapping(target = "updateTime", ignore = true) 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 27c268cb..2e9ce2a7 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 @@ -20,7 +20,7 @@ package cn.topiam.employee.console.service.app; import java.util.List; import cn.topiam.employee.common.entity.app.query.AppGroupAssociationListQuery; -import cn.topiam.employee.console.pojo.query.app.AppGroupQuery; +import cn.topiam.employee.common.entity.app.query.AppGroupQuery; import cn.topiam.employee.console.pojo.result.app.AppGroupGetResult; import cn.topiam.employee.console.pojo.result.app.AppGroupListResult; import cn.topiam.employee.console.pojo.result.app.AppListResult; 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 6c71d341..338be68b 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 @@ -17,20 +17,16 @@ */ package cn.topiam.employee.console.service.app.impl; -import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Optional; import org.springframework.data.domain.PageRequest; -import org.springframework.data.querydsl.QPageRequest; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.google.common.collect.Lists; -import com.querydsl.core.types.OrderSpecifier; -import com.querydsl.core.types.Predicate; import cn.topiam.employee.audit.context.AuditContext; import cn.topiam.employee.audit.entity.Target; @@ -38,13 +34,13 @@ 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.QAppGroupEntity; +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.repository.app.AppGroupAssociationRepository; import cn.topiam.employee.common.repository.app.AppGroupRepository; import cn.topiam.employee.console.converter.app.AppConverter; import cn.topiam.employee.console.converter.app.AppGroupConverter; -import cn.topiam.employee.console.pojo.query.app.AppGroupQuery; import cn.topiam.employee.console.pojo.result.app.AppGroupGetResult; import cn.topiam.employee.console.pojo.result.app.AppGroupListResult; import cn.topiam.employee.console.pojo.result.app.AppListResult; @@ -81,15 +77,9 @@ public class AppGroupServiceImpl implements AppGroupService { */ @Override public Page getAppGroupList(PageModel pageModel, AppGroupQuery query) { - //查询条件 - Predicate predicate = appGroupConverter.queryAppGroupListParamConvertToPredicate(query); - OrderSpecifier desc = QAppGroupEntity.appGroupEntity.updateTime.desc(); - //分页条件 - QPageRequest request = QPageRequest.of(pageModel.getCurrent(), pageModel.getPageSize(), - desc); //查询映射 - org.springframework.data.domain.Page list = appGroupRepository - .findAll(predicate, request); + org.springframework.data.domain.Page list = appGroupRepository + .getAppGroupList(query, PageRequest.of(pageModel.getCurrent(), pageModel.getPageSize())); return appGroupConverter.entityConvertToAppGroupListResult(list); } diff --git a/eiam-portal/src/main/java/cn/topiam/employee/portal/converter/AppGroupConverter.java b/eiam-portal/src/main/java/cn/topiam/employee/portal/converter/AppGroupConverter.java index 73a3881a..08428eba 100644 --- a/eiam-portal/src/main/java/cn/topiam/employee/portal/converter/AppGroupConverter.java +++ b/eiam-portal/src/main/java/cn/topiam/employee/portal/converter/AppGroupConverter.java @@ -21,8 +21,8 @@ import java.util.ArrayList; import java.util.List; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; -import com.querydsl.core.types.ExpressionUtils; import com.querydsl.core.types.Predicate; import cn.topiam.employee.common.entity.app.AppGroupAssociationEntity; @@ -30,7 +30,6 @@ import cn.topiam.employee.common.entity.app.AppGroupEntity; import cn.topiam.employee.common.entity.app.QAppGroupAssociationEntity; import cn.topiam.employee.common.entity.app.QAppGroupEntity; import cn.topiam.employee.portal.pojo.result.AppGroupListResult; -import org.mapstruct.Mapping; /** * 分组映射 @@ -49,8 +48,6 @@ public interface AppGroupConverter { default Predicate queryPredicate() { QAppGroupEntity appGroup = QAppGroupEntity.appGroupEntity; Predicate predicate = appGroup.deleted.eq(Boolean.FALSE); - //@formatter:off - predicate = ExpressionUtils.and(predicate, appGroup.enabled.eq(Boolean.TRUE)); //@formatter:on return predicate; }