mirror of https://gitee.com/topiam/eiam
				
				
				
			应用分组优化
							parent
							
								
									7b9e8058f7
								
							
						
					
					
						commit
						17cfd7fe1c
					
				| 
						 | 
				
			
			@ -53,17 +53,11 @@ public class AppGroupEntity extends LogicDeleteEntity<Long> {
 | 
			
		|||
     * 分组名称
 | 
			
		||||
     */
 | 
			
		||||
    @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;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
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;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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 <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
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;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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<AppGroupEntity, Long>,
 | 
			
		||||
                                    QuerydslPredicateExecutor<AppGroupEntity> {
 | 
			
		||||
                                    QuerydslPredicateExecutor<AppGroupEntity>,
 | 
			
		||||
                                    AppGroupRepositoryCustomized {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * save
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
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<AppGroupPO> getAppGroupList(AppGroupQuery query, Pageable pageable);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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 <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
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<AppGroupPO> 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<AppGroupPO> 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;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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 <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
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<AppGroupPO> {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -35,7 +35,6 @@
 | 
			
		|||
            <column name="code_" remarks="分组编码" type="VARCHAR(64)">
 | 
			
		||||
                <constraints nullable="false"/>
 | 
			
		||||
            </column>
 | 
			
		||||
            <column name="is_enabled" remarks="是否启用" type="TINYINT(1)" defaultValueNumeric="0"/>
 | 
			
		||||
            <column name="create_by" remarks="创建者" type="VARCHAR(64)">
 | 
			
		||||
                <constraints nullable="false"/>
 | 
			
		||||
            </column>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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<AppGroupListResult> entityConvertToAppGroupListResult(org.springframework.data.domain.Page<AppGroupEntity> entityPage) {
 | 
			
		||||
    default Page<AppGroupListResult> entityConvertToAppGroupListResult(org.springframework.data.domain.Page<AppGroupPO> appGroupPoPage) {
 | 
			
		||||
        Page<AppGroupListResult> page = new Page<>();
 | 
			
		||||
        List<AppGroupListResult> 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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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<AppGroupListResult> getAppGroupList(PageModel pageModel, AppGroupQuery query) {
 | 
			
		||||
        //查询条件
 | 
			
		||||
        Predicate predicate = appGroupConverter.queryAppGroupListParamConvertToPredicate(query);
 | 
			
		||||
        OrderSpecifier<LocalDateTime> desc = QAppGroupEntity.appGroupEntity.updateTime.desc();
 | 
			
		||||
        //分页条件
 | 
			
		||||
        QPageRequest request = QPageRequest.of(pageModel.getCurrent(), pageModel.getPageSize(),
 | 
			
		||||
            desc);
 | 
			
		||||
        //查询映射
 | 
			
		||||
        org.springframework.data.domain.Page<AppGroupEntity> list = appGroupRepository
 | 
			
		||||
            .findAll(predicate, request);
 | 
			
		||||
        org.springframework.data.domain.Page<AppGroupPO> list = appGroupRepository
 | 
			
		||||
                .getAppGroupList(query, PageRequest.of(pageModel.getCurrent(), pageModel.getPageSize()));
 | 
			
		||||
        return appGroupConverter.entityConvertToAppGroupListResult(list);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue