mirror of https://gitee.com/topiam/eiam
Merge remote-tracking branch 'origin/master'
commit
438e3037a6
|
@ -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)
|
* Copyright © 2022-Present Jinan Yuanchuang Network Technology Co., Ltd. (support@topiam.cn)
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
|
||||||
import org.springdoc.core.annotations.ParameterObject;
|
import org.springdoc.core.annotations.ParameterObject;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package cn.topiam.employee.common.repository.account.impl;
|
package cn.topiam.employee.common.repository.account.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
|
@ -105,7 +106,7 @@ public class UserGroupMemberRepositoryCustomizedImpl implements
|
||||||
String countSql = "SELECT count(*) FROM (" + sql + ") user_";
|
String countSql = "SELECT count(*) FROM (" + sql + ") user_";
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
Integer count = jdbcTemplate.queryForObject(countSql, Integer.class);
|
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;
|
private final JdbcTemplate jdbcTemplate;
|
||||||
|
|
|
@ -129,7 +129,7 @@ public class UserRepositoryCustomizedImpl implements UserRepositoryCustomized {
|
||||||
String countSql = "SELECT count(*) FROM (" + sql + ") user_";
|
String countSql = "SELECT count(*) FROM (" + sql + ") user_";
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
Integer count = jdbcTemplate.queryForObject(countSql, Integer.class);
|
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_";
|
String countSql = "SELECT COUNT(*) FROM(" + sql + ") user_";
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
Integer count = jdbcTemplate.queryForObject(countSql, Integer.class);
|
Integer count = jdbcTemplate.queryForObject(countSql, Integer.class);
|
||||||
return new PageImpl<>(list, pageable, count);
|
return new PageImpl<>(list, pageable, Objects.requireNonNull(count).longValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,12 +19,12 @@ package cn.topiam.employee.common.repository.app;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import cn.topiam.employee.common.entity.app.query.GetAppListQuery;
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
import cn.topiam.employee.common.entity.app.AppEntity;
|
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.AppQuery;
|
||||||
|
import cn.topiam.employee.common.entity.app.query.GetAppListQuery;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 应用 Repository Customized
|
* 应用 Repository Customized
|
||||||
|
|
|
@ -133,7 +133,7 @@ public class AppAccessPolicyRepositoryCustomizedImpl implements
|
||||||
String countSql = "SELECT count(*) FROM (" + sql + ") app_access_policy_";
|
String countSql = "SELECT count(*) FROM (" + sql + ") app_access_policy_";
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
Integer count = jdbcTemplate.queryForObject(countSql, Integer.class);
|
Integer count = jdbcTemplate.queryForObject(countSql, Integer.class);
|
||||||
return new PageImpl<>(list, pageable, count);
|
return new PageImpl<>(list, pageable, Objects.requireNonNull(count).longValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package cn.topiam.employee.common.repository.app.impl;
|
package cn.topiam.employee.common.repository.app.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
|
@ -106,7 +107,7 @@ public class AppAccountRepositoryCustomizedImpl implements AppAccountRepositoryC
|
||||||
String countSql = "SELECT count(*) FROM (" + sql + ") app_account_";
|
String countSql = "SELECT count(*) FROM (" + sql + ") app_account_";
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
Integer count = jdbcTemplate.queryForObject(countSql, Integer.class);
|
Integer count = jdbcTemplate.queryForObject(countSql, Integer.class);
|
||||||
return new PageImpl<>(list, pageable, count);
|
return new PageImpl<>(list, pageable, Objects.requireNonNull(count).longValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package cn.topiam.employee.common.repository.app.impl;
|
package cn.topiam.employee.common.repository.app.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
|
@ -77,7 +78,7 @@ public class AppGroupAssociationRepositoryCustomizedImpl implements
|
||||||
String countSql = "SELECT count(*) FROM (" + sql + ") app_";
|
String countSql = "SELECT count(*) FROM (" + sql + ") app_";
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
Integer count = jdbcTemplate.queryForObject(countSql, Integer.class);
|
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;
|
private final JdbcTemplate jdbcTemplate;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package cn.topiam.employee.common.repository.app.impl;
|
package cn.topiam.employee.common.repository.app.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -44,15 +45,38 @@ import lombok.AllArgsConstructor;
|
||||||
public class AppGroupRepositoryCustomizedImpl implements AppGroupRepositoryCustomized {
|
public class AppGroupRepositoryCustomizedImpl implements AppGroupRepositoryCustomized {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取应用组应用列表
|
* 获取应用组应用列表(分页)
|
||||||
*
|
*
|
||||||
* @param query {@link UserGroupMemberListQuery}
|
* @param query {@link UserGroupMemberListQuery}
|
||||||
* @param pageable {@link Pageable}
|
* @param pageable {@link Pageable}
|
||||||
* @return {@link Page}
|
* @return {@link Page}
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("DuplicatedCode")
|
|
||||||
@Override
|
@Override
|
||||||
public Page<AppGroupPO> getAppGroupList(AppGroupQuery query, Pageable pageable) {
|
public Page<AppGroupPO> getAppGroupList(AppGroupQuery query, Pageable pageable) {
|
||||||
|
StringBuilder builder = getBaseAppGroupListSql(query);
|
||||||
|
String sql = getBaseAppGroupListSql(query).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, Objects.requireNonNull(count).longValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询应用组列表(不分页)
|
||||||
|
*
|
||||||
|
* @return {@link List}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<AppGroupPO> getAppGroupList(AppGroupQuery query) {
|
||||||
|
return jdbcTemplate.query(getBaseAppGroupListSql(query).toString(), new AppGroupPoMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
private StringBuilder getBaseAppGroupListSql(AppGroupQuery query) {
|
||||||
//@formatter:off
|
//@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'");
|
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");
|
builder.append(" ORDER BY `group`.create_time DESC");
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
String sql = builder.toString();
|
return builder;
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询应用组列表
|
|
||||||
*
|
|
||||||
* @return {@link List}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<AppGroupPO> 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<AppGroupPO> list = jdbcTemplate.query(builder.toString(), new AppGroupPoMapper());
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final JdbcTemplate jdbcTemplate;
|
private final JdbcTemplate jdbcTemplate;
|
||||||
|
|
|
@ -22,7 +22,6 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import cn.topiam.employee.common.entity.app.query.GetAppListQuery;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageImpl;
|
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.account.UserGroupMemberEntity;
|
||||||
import cn.topiam.employee.common.entity.app.AppEntity;
|
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.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.OrganizationMemberRepository;
|
||||||
import cn.topiam.employee.common.repository.account.UserGroupMemberRepository;
|
import cn.topiam.employee.common.repository.account.UserGroupMemberRepository;
|
||||||
import cn.topiam.employee.common.repository.app.AppRepositoryCustomized;
|
import cn.topiam.employee.common.repository.app.AppRepositoryCustomized;
|
||||||
import cn.topiam.employee.common.repository.app.impl.mapper.AppEntityMapper;
|
import cn.topiam.employee.common.repository.app.impl.mapper.AppEntityMapper;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import static cn.topiam.employee.common.enums.app.AuthorizationType.ALL_ACCESS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* App Repository Customized
|
* App Repository Customized
|
||||||
|
@ -58,8 +59,8 @@ public class AppRepositoryCustomizedImpl implements AppRepositoryCustomized {
|
||||||
* 获取我的应用列表
|
* 获取我的应用列表
|
||||||
*
|
*
|
||||||
* @param userId {@link Long}
|
* @param userId {@link Long}
|
||||||
* @param query {@link query}
|
* @param query {@link GetAppListQuery}
|
||||||
* @param pageable {@link String}
|
* @param pageable {@link Pageable}
|
||||||
* @return {@link List}
|
* @return {@link List}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,18 +78,7 @@ public class AppRepositoryCustomizedImpl implements AppRepositoryCustomized {
|
||||||
Map<String, Object> paramMap = new HashMap<>(16);
|
Map<String, Object> paramMap = new HashMap<>(16);
|
||||||
paramMap.put("subjectIds", paramList);
|
paramMap.put("subjectIds", paramList);
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
StringBuilder builder = new StringBuilder("""
|
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()+"')");
|
||||||
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')
|
|
||||||
""");
|
|
||||||
//用户名
|
//用户名
|
||||||
if (StringUtils.isNoneBlank(query.getName())) {
|
if (StringUtils.isNoneBlank(query.getName())) {
|
||||||
builder.append(" AND app.name_ like '%").append(query.getName()).append("%'");
|
builder.append(" AND app.name_ like '%").append(query.getName()).append("%'");
|
||||||
|
@ -108,7 +98,7 @@ public class AppRepositoryCustomizedImpl implements AppRepositoryCustomized {
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
Integer count = namedParameterJdbcTemplate.queryForObject(countSql, paramMap,
|
Integer count = namedParameterJdbcTemplate.queryForObject(countSql, paramMap,
|
||||||
Integer.class);
|
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}
|
* @param pageable {@link Pageable}
|
||||||
* @return {@link List}
|
* @return {@link List}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Page<AppEntity> getAppList(AppQuery appQuery, Pageable pageable) {
|
public Page<AppEntity> getAppList(AppQuery appQuery, Pageable pageable) {
|
||||||
//@formatter:off
|
//@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");
|
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_";
|
String countSql = "SELECT count(*) FROM (" + sql + ") app_account_";
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
Integer count = jdbcTemplate.queryForObject(countSql, Integer.class);
|
Integer count = jdbcTemplate.queryForObject(countSql, Integer.class);
|
||||||
return new PageImpl<>(list, pageable, count);
|
return new PageImpl<>(list, pageable, Objects.requireNonNull(count).longValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
"@ant-design/maps": "^1.0.7",
|
"@ant-design/maps": "^1.0.7",
|
||||||
"@ant-design/pro-components": "^2.6.24",
|
"@ant-design/pro-components": "^2.6.24",
|
||||||
"ahooks": "^3.7.8",
|
"ahooks": "^3.7.8",
|
||||||
"antd": "^5.9.2",
|
"antd": "^5.9.3",
|
||||||
"antd-img-crop": "^4.13.0",
|
"antd-img-crop": "^4.13.0",
|
||||||
"antd-style": "^3.5.0",
|
"antd-style": "^3.5.0",
|
||||||
"classnames": "^2.3.2",
|
"classnames": "^2.3.2",
|
||||||
|
|
|
@ -25,11 +25,11 @@ import org.springframework.stereotype.Service;
|
||||||
import cn.topiam.employee.common.entity.app.AppEntity;
|
import cn.topiam.employee.common.entity.app.AppEntity;
|
||||||
import cn.topiam.employee.common.entity.app.po.AppGroupPO;
|
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.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.AppGroupRepository;
|
||||||
import cn.topiam.employee.common.repository.app.AppRepository;
|
import cn.topiam.employee.common.repository.app.AppRepository;
|
||||||
import cn.topiam.employee.portal.converter.AppConverter;
|
import cn.topiam.employee.portal.converter.AppConverter;
|
||||||
import cn.topiam.employee.portal.converter.AppGroupConverter;
|
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.AppGroupListResult;
|
||||||
import cn.topiam.employee.portal.pojo.result.GetAppListResult;
|
import cn.topiam.employee.portal.pojo.result.GetAppListResult;
|
||||||
import cn.topiam.employee.portal.service.AppService;
|
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}
|
* @return {@link AppGroupListResult}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<AppGroupListResult> getAppGroupList(AppGroupQuery appGroupQuery) {
|
public List<AppGroupListResult> getAppGroupList(AppGroupQuery query) {
|
||||||
//查询映射
|
List<AppGroupPO> list = appGroupRepository.getAppGroupList(query);
|
||||||
List<AppGroupPO> list = appGroupRepository.getAppGroupList(appGroupQuery);
|
|
||||||
return appGroupConverter.entityConvertToAppGroupListResult(list);
|
return appGroupConverter.entityConvertToAppGroupListResult(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
"@ant-design/maps": "^1.0.7",
|
"@ant-design/maps": "^1.0.7",
|
||||||
"@ant-design/pro-components": "^2.6.24",
|
"@ant-design/pro-components": "^2.6.24",
|
||||||
"ahooks": "^3.7.8",
|
"ahooks": "^3.7.8",
|
||||||
"antd": "^5.9.2",
|
"antd": "^5.9.3",
|
||||||
"antd-img-crop": "^4.13.0",
|
"antd-img-crop": "^4.13.0",
|
||||||
"antd-style": "^3.5.0",
|
"antd-style": "^3.5.0",
|
||||||
"classnames": "^2.3.2",
|
"classnames": "^2.3.2",
|
||||||
|
|
|
@ -25,16 +25,17 @@ import {
|
||||||
} from '@ant-design/pro-components';
|
} from '@ant-design/pro-components';
|
||||||
import { App, Avatar, Badge, Card, Typography } from 'antd';
|
import { App, Avatar, Badge, Card, Typography } from 'antd';
|
||||||
import React, { useRef, useState } from 'react';
|
import React, { useRef, useState } from 'react';
|
||||||
import { AppList, InitLoginType } from './data.d';
|
import { AppGroupList, AppList, InitLoginType } from './data.d';
|
||||||
import { getAppGroupList, queryAppList } from './service';
|
import { getAppGroupList, queryAppList } from './service';
|
||||||
import { useIntl } from '@@/exports';
|
|
||||||
import useStyle from './style';
|
import useStyle from './style';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import { useAsyncEffect } from 'ahooks';
|
import { useAsyncEffect } from 'ahooks';
|
||||||
import { SpinProps } from 'antd/es/spin';
|
import { SpinProps } from 'antd/es/spin';
|
||||||
|
import { useIntl } from '@umijs/max';
|
||||||
|
|
||||||
const { Paragraph } = Typography;
|
const { Paragraph } = Typography;
|
||||||
const prefixCls = 'topiam-app-list';
|
const prefixCls = 'topiam-app-list';
|
||||||
|
const all = 'all';
|
||||||
const renderBadge = (count: number, active = false) => {
|
const renderBadge = (count: number, active = false) => {
|
||||||
return (
|
return (
|
||||||
<Badge
|
<Badge
|
||||||
|
@ -57,8 +58,34 @@ const CardList = () => {
|
||||||
const { message } = App.useApp();
|
const { message } = App.useApp();
|
||||||
const actionRef = useRef<ActionType>();
|
const actionRef = useRef<ActionType>();
|
||||||
const [searchParams, setSearchParams] = useState<Record<string, any>>();
|
const [searchParams, setSearchParams] = useState<Record<string, any>>();
|
||||||
|
const [appGroupList, setAppGroupList] = useState<AppGroupList[]>([]);
|
||||||
const [loading, setLoading] = useState<boolean | SpinProps | undefined>(false);
|
const [loading, setLoading] = useState<boolean | SpinProps | undefined>(false);
|
||||||
const [items, setItems] = useState<{ key: string; label: React.JSX.Element }[]>([]);
|
|
||||||
|
const getItems = () => {
|
||||||
|
let data: { key: string; label: React.JSX.Element }[] = [
|
||||||
|
{
|
||||||
|
key: all,
|
||||||
|
label: (
|
||||||
|
<span>
|
||||||
|
{intl.formatMessage({ id: 'pages.application.group_all' })}
|
||||||
|
{renderBadge(0, currentGroup === all)}
|
||||||
|
</span>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
appGroupList.forEach((item) => {
|
||||||
|
data.push({
|
||||||
|
key: item.id,
|
||||||
|
label: (
|
||||||
|
<span>
|
||||||
|
{item.name}
|
||||||
|
{renderBadge(item.appCount, currentGroup === item.id)}
|
||||||
|
</span>
|
||||||
|
),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
const initSso = (idpInitUrl: string) => {
|
const initSso = (idpInitUrl: string) => {
|
||||||
const div = window.document.createElement('div');
|
const div = window.document.createElement('div');
|
||||||
|
@ -80,28 +107,10 @@ const CardList = () => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
});
|
});
|
||||||
if (success && result) {
|
if (success && result) {
|
||||||
let data: { key: string; label: React.JSX.Element }[] = [];
|
setAppGroupList(result);
|
||||||
result.forEach((item) => {
|
setCurrentGroup(all);
|
||||||
data.push({
|
|
||||||
key: item.id,
|
|
||||||
label: (
|
|
||||||
<span>
|
|
||||||
{item.name}
|
|
||||||
{renderBadge(item.appCount, currentGroup === item.id)}
|
|
||||||
</span>
|
|
||||||
),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
setItems(data);
|
|
||||||
// 如果有分组,取第一个分组
|
|
||||||
if (data.length > 0) {
|
|
||||||
setSearchParams({ groupId: data[0].key });
|
|
||||||
actionRef.current?.reload();
|
|
||||||
}
|
|
||||||
// 手动请求
|
// 手动请求
|
||||||
else {
|
actionRef.current?.reload();
|
||||||
actionRef.current?.reload();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
@ -125,19 +134,26 @@ const CardList = () => {
|
||||||
}}
|
}}
|
||||||
manualRequest
|
manualRequest
|
||||||
request={queryAppList}
|
request={queryAppList}
|
||||||
|
pagination={{}}
|
||||||
toolbar={
|
toolbar={
|
||||||
items.length > 0
|
appGroupList?.length > 0
|
||||||
? {
|
? {
|
||||||
menu: {
|
menu: {
|
||||||
type: 'tab',
|
type: 'tab',
|
||||||
activeKey: currentGroup,
|
activeKey: currentGroup,
|
||||||
items: items,
|
items: getItems(),
|
||||||
onChange(key) {
|
onChange(key) {
|
||||||
if (key) {
|
if (key) {
|
||||||
setCurrentGroup(key);
|
setCurrentGroup(key);
|
||||||
setSearchParams((values) => {
|
if (key === all) {
|
||||||
return { ...values, groupId: key };
|
setSearchParams((values) => {
|
||||||
});
|
return { ...values, groupId: undefined };
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setSearchParams((values) => {
|
||||||
|
return { ...values, groupId: key };
|
||||||
|
});
|
||||||
|
}
|
||||||
actionRef.current?.reload();
|
actionRef.current?.reload();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -199,7 +215,7 @@ const CardList = () => {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}}
|
}}
|
||||||
onReset={() => {
|
onReset={() => {
|
||||||
if (items.length > 0) {
|
if (currentGroup && currentGroup !== all) {
|
||||||
setSearchParams({ groupId: currentGroup });
|
setSearchParams({ groupId: currentGroup });
|
||||||
} else {
|
} else {
|
||||||
setSearchParams({});
|
setSearchParams({});
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
export default {
|
export default {
|
||||||
'pages.application.search.name': '应用名称',
|
'pages.application.search.name': '应用名称',
|
||||||
|
'pages.application.group_all': '全部',
|
||||||
'pages.application.tab.list': '应用列表',
|
'pages.application.tab.list': '应用列表',
|
||||||
'pages.application.tab.account': '应用账号',
|
'pages.application.tab.account': '应用账号',
|
||||||
'pages.application.init.warning': '仅允许应用发起',
|
'pages.application.init.warning': '仅允许应用发起',
|
||||||
|
|
Loading…
Reference in New Issue