diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/entity/account/UserElasticSearchEntity.java b/eiam-common/src/main/java/cn/topiam/employee/common/entity/account/UserElasticSearchEntity.java deleted file mode 100644 index b6982bce..00000000 --- a/eiam-common/src/main/java/cn/topiam/employee/common/entity/account/UserElasticSearchEntity.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * 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.account; - -import java.io.Serializable; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.util.List; - -import org.springframework.data.annotation.Id; -import org.springframework.data.elasticsearch.annotations.Document; -import org.springframework.data.elasticsearch.annotations.Field; -import org.springframework.data.elasticsearch.annotations.FieldType; -import org.springframework.data.elasticsearch.annotations.Setting; - -import cn.topiam.employee.common.entity.account.po.OrganizationPO; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import jakarta.persistence.Column; -import static org.springframework.data.elasticsearch.annotations.DateFormat.date; -import static org.springframework.data.elasticsearch.annotations.DateFormat.date_hour_minute_second_millis; - -/** - * 用户elasticsearch实体 - * - * @author TopIAM - * Created by support@topiam.cn on 2023/4/12 23:22 - */ -@Data -@Builder -@EqualsAndHashCode -@Document(indexName = "#{@userIndexName.getIndexName()}") -@Setting(replicas = 0) -public class UserElasticSearchEntity implements Serializable { - - /** - * 用户userId - */ - @Id - @Field(type = FieldType.Keyword, name = "id") - private String id; - - /** - * 用户名 - */ - @Field(type = FieldType.Keyword, name = "username") - private String username; - - /** - * 邮箱 - */ - @Field(type = FieldType.Keyword, name = "email") - private String email; - - /** - * 手机号 - */ - @Field(type = FieldType.Keyword, name = "phone") - private String phone; - - /** - * 手机号 - */ - @Field(type = FieldType.Keyword, name = "phoneAreaCode") - private String phoneAreaCode; - - /** - * 姓名 - */ - @Field(type = FieldType.Keyword, name = "fullName") - private String fullName; - - /** - * 昵称 - */ - @Field(type = FieldType.Keyword, name = "nickName") - private String nickName; - - /** - * 头像URL - */ - @Field(type = FieldType.Keyword, name = "avatar") - private String avatar; - - /** - * 状态 ENABLE:启用 DISABLE:禁用 LOCKING:锁定 - */ - @Field(type = FieldType.Keyword, name = "status") - private String status; - - /** - * 数据来源 - */ - @Field(type = FieldType.Keyword, name = "dataOrigin") - private String dataOrigin; - - /** - * 身份源ID - */ - @Field(type = FieldType.Keyword, name = "identitySourceId") - private Long identitySourceId; - - /** - * 邮箱验证有效 - */ - @Field(type = FieldType.Keyword, name = "emailVerified") - private Boolean emailVerified; - - /** - * 手机有效 - */ - @Field(type = FieldType.Keyword, name = "phoneVerified") - private Boolean phoneVerified; - - /** - * 认证次数 - */ - @Field(type = FieldType.Keyword, name = "authTotal") - private Long authTotal; - /** - * 上次认证IP - */ - @Field(type = FieldType.Keyword, name = "lastAuthIp") - private String lastAuthIp; - /** - * 上次认证时间 - */ - @Field(type = FieldType.Date, name = "lastAuthTime", format = date_hour_minute_second_millis) - private LocalDateTime lastAuthTime; - - /** - * 扩展参数 - */ - @Column(name = "expand_") - private String expand; - - /** - * 外部ID - */ - @Column(name = "external_id") - private String externalId; - - /** - * 过期时间 - */ - @Field(type = FieldType.Date, name = "expireDate", format = date) - private LocalDate expireDate; - - /** - * 最后修改密码时间 - */ - @Field(type = FieldType.Date, name = "lastUpdatePasswordTime", format = date_hour_minute_second_millis) - private LocalDateTime lastUpdatePasswordTime; - - // ----------------------------------用户详情---------------------------------- - /** - * 证件类型 - */ - @Field(type = FieldType.Keyword, name = "idType") - private String idType; - - /** - * 身份证号 - */ - @Field(type = FieldType.Keyword, name = "idCard") - private String idCard; - - /** - * 个人主页 - */ - @Field(type = FieldType.Text, name = "website") - private String website; - - /**u - * 地址 - */ - @Field(type = FieldType.Keyword, name = "address") - private String address; - - /** - * 组织列表 - */ - @Field(type = FieldType.Object, name = "organizations") - private List organizations; - - /** - * 用户组 - */ - @Field(type = FieldType.Object, name = "userGroups") - private List userGroups; - - @Data - @AllArgsConstructor - public static class UserGroup { - - /** - * id - */ - @Field(type = FieldType.Keyword, name = "id") - private String id; - - /** - * 用户组名称 - */ - @Field(type = FieldType.Keyword, name = "name") - private String name; - } -} diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/entity/account/po/UserEsPO.java b/eiam-common/src/main/java/cn/topiam/employee/common/entity/account/po/UserEsPO.java deleted file mode 100644 index 35003051..00000000 --- a/eiam-common/src/main/java/cn/topiam/employee/common/entity/account/po/UserEsPO.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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.account.po; - -import java.io.Serial; -import java.util.Map; -import java.util.Set; - -import cn.topiam.employee.common.entity.account.UserEntity; - -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - * 用户 PO - * - * @author TopIAM - * Created by support@topiam.cn on 2022/2/10 22:46 - */ -@EqualsAndHashCode(callSuper = true) -@Data -public class UserEsPO extends UserEntity { - - @Serial - private static final long serialVersionUID = 2330202241972458786L; - - /** - * 证件类型 - */ - private String idType; - - /** - * 身份证号 - */ - private String idCard; - - /** - * 个人主页 - */ - private String website; - - /** - * 地址 - */ - private String address; - - /** - * 组织id列表 - */ - private Set organizationIds; - - /** - * 静态用户组 - */ - private Map userGroups; -} diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/entity/account/po/UserIdpBindPo.java b/eiam-common/src/main/java/cn/topiam/employee/common/entity/account/po/UserIdpBindPO.java similarity index 95% rename from eiam-common/src/main/java/cn/topiam/employee/common/entity/account/po/UserIdpBindPo.java rename to eiam-common/src/main/java/cn/topiam/employee/common/entity/account/po/UserIdpBindPO.java index f4a7fcbd..506df083 100644 --- a/eiam-common/src/main/java/cn/topiam/employee/common/entity/account/po/UserIdpBindPo.java +++ b/eiam-common/src/main/java/cn/topiam/employee/common/entity/account/po/UserIdpBindPO.java @@ -30,7 +30,7 @@ import lombok.EqualsAndHashCode; */ @EqualsAndHashCode(callSuper = true) @Data -public class UserIdpBindPo extends UserIdpBindEntity { +public class UserIdpBindPO extends UserIdpBindEntity { /** * 用户名称 diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/UserElasticSearchRepository.java b/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/UserElasticSearchRepository.java deleted file mode 100644 index 69834d2a..00000000 --- a/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/UserElasticSearchRepository.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.account; - -import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; -import org.springframework.stereotype.Repository; - -import cn.topiam.employee.common.entity.account.UserElasticSearchEntity; - -/** - * 用户信息repository - * - * @author TopIAM - * Created by support@topiam.cn on 2021/9/11 22:32 - */ -@Repository -public interface UserElasticSearchRepository extends - ElasticsearchRepository { - -} diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/UserIdpRepositoryCustomized.java b/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/UserIdpRepositoryCustomized.java index 3ca657b9..0cbf58be 100644 --- a/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/UserIdpRepositoryCustomized.java +++ b/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/UserIdpRepositoryCustomized.java @@ -19,7 +19,7 @@ package cn.topiam.employee.common.repository.account; import java.util.Optional; -import cn.topiam.employee.common.entity.account.po.UserIdpBindPo; +import cn.topiam.employee.common.entity.account.po.UserIdpBindPO; import cn.topiam.employee.support.repository.page.domain.Page; /** @@ -37,7 +37,7 @@ public interface UserIdpRepositoryCustomized { * @param openId {@link String} * @return {@link Optional} */ - Optional findByIdpIdAndOpenId(String idpId, String openId); + Optional findByIdpIdAndOpenId(String idpId, String openId); /** * 根据身份源ID和userId查询 @@ -46,7 +46,7 @@ public interface UserIdpRepositoryCustomized { * @param userId {@link String} * @return {@link Optional} */ - Optional findByIdpIdAndUserId(String idpId, Long userId); + Optional findByIdpIdAndUserId(String idpId, Long userId); /** * 查询用户身份提供商绑定 @@ -54,5 +54,5 @@ public interface UserIdpRepositoryCustomized { * @param userId {@link Long} * @return {@link Page} */ - Iterable getUserIdpBindList(Long userId); + Iterable getUserIdpBindList(Long userId); } diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/UserRepositoryCustomized.java b/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/UserRepositoryCustomized.java index 4501d6d8..fa98945c 100644 --- a/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/UserRepositoryCustomized.java +++ b/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/UserRepositoryCustomized.java @@ -21,17 +21,12 @@ import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; -import cn.topiam.employee.common.entity.account.UserElasticSearchEntity; import cn.topiam.employee.common.entity.account.UserEntity; -import cn.topiam.employee.common.entity.account.po.UserEsPO; import cn.topiam.employee.common.entity.account.po.UserPO; import cn.topiam.employee.common.entity.account.query.UserListNotInGroupQuery; import cn.topiam.employee.common.entity.account.query.UserListQuery; -import co.elastic.clients.elasticsearch._types.query_dsl.Query; - /** * User Repository Customized * @@ -107,29 +102,4 @@ public interface UserRepositoryCustomized { */ void batchUpdate(List list); - /** - * 获取用户列表 - * - * @param idList {@link List} - * @return {@link List} - */ - List getUserList(List idList); - - /** - * 查询es用户数据 - * - * @param userIndex {@link IndexCoordinates} - * @return {@link List} - */ - List getAllUserElasticSearchEntity(IndexCoordinates userIndex); - - /** - * 查询es用户数据 - * - * @param userIndex {@link IndexCoordinates} - * @param queryBuilder {@link Query} - * @return {@link List} - */ - List getAllUserElasticSearchEntity(IndexCoordinates userIndex, - Query queryBuilder); } diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/impl/UserIdpRepositoryCustomizedImpl.java b/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/impl/UserIdpRepositoryCustomizedImpl.java index 61ac7bf3..53cdfbe2 100644 --- a/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/impl/UserIdpRepositoryCustomizedImpl.java +++ b/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/impl/UserIdpRepositoryCustomizedImpl.java @@ -26,7 +26,7 @@ import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Repository; -import cn.topiam.employee.common.entity.account.po.UserIdpBindPo; +import cn.topiam.employee.common.entity.account.po.UserIdpBindPO; import cn.topiam.employee.common.repository.account.UserIdpRepositoryCustomized; import cn.topiam.employee.common.repository.account.impl.mapper.UserIdpBindPoMapper; import cn.topiam.employee.support.repository.page.domain.Page; @@ -53,7 +53,7 @@ public class UserIdpRepositoryCustomizedImpl implements UserIdpRepositoryCustomi * @return {@link Optional} */ @Override - public Optional findByIdpIdAndOpenId(String idpId, String openId) { + public Optional findByIdpIdAndOpenId(String idpId, String openId) { //@formatter:off StringBuilder builder = new StringBuilder("SELECT uidp.*,`user`.username_,idp.name_ as idp_name FROM user_idp_bind uidp LEFT JOIN `user` ON uidp.user_id = `user`.id_ AND `user`.is_deleted = '0' LEFT JOIN identity_provider idp ON uidp.idp_id = idp.id_ AND idp.is_deleted = '0' WHERE uidp.is_deleted = '0' "); //身份提供商ID @@ -67,7 +67,7 @@ public class UserIdpRepositoryCustomizedImpl implements UserIdpRepositoryCustomi //@formatter:on String sql = builder.toString(); try { - UserIdpBindPo userIdpBindPo = jdbcTemplate.queryForObject(sql, + UserIdpBindPO userIdpBindPo = jdbcTemplate.queryForObject(sql, new UserIdpBindPoMapper()); return Optional.ofNullable(userIdpBindPo); } catch (EmptyResultDataAccessException e) { @@ -83,7 +83,7 @@ public class UserIdpRepositoryCustomizedImpl implements UserIdpRepositoryCustomi * @return {@link Optional} */ @Override - public Optional findByIdpIdAndUserId(String idpId, Long userId) { + public Optional findByIdpIdAndUserId(String idpId, Long userId) { //@formatter:off StringBuilder builder = new StringBuilder("SELECT uidp.*,`user`.username_,idp.name_ as idp_name FROM user_idp_bind uidp LEFT JOIN `user` ON uidp.user_id = `user`.id_ AND `user`.is_deleted = '0' LEFT JOIN identity_provider idp ON uidp.idp_id = idp.id_ AND idp.is_deleted = '0' WHERE uidp.is_deleted = '0' "); //身份提供商ID @@ -97,7 +97,7 @@ public class UserIdpRepositoryCustomizedImpl implements UserIdpRepositoryCustomi //@formatter:on String sql = builder.toString(); try { - UserIdpBindPo userIdpBindPo = jdbcTemplate.queryForObject(sql, + UserIdpBindPO userIdpBindPo = jdbcTemplate.queryForObject(sql, new UserIdpBindPoMapper()); return Optional.ofNullable(userIdpBindPo); } catch (EmptyResultDataAccessException e) { @@ -112,7 +112,7 @@ public class UserIdpRepositoryCustomizedImpl implements UserIdpRepositoryCustomi * @return {@link Page} */ @Override - public Iterable getUserIdpBindList(Long userId) { + public Iterable getUserIdpBindList(Long userId) { //@formatter:off StringBuilder builder = new StringBuilder("SELECT uidp.*,idp.name_ as idp_name FROM user_idp_bind uidp LEFT JOIN identity_provider idp ON uidp.idp_id = idp.id_ AND idp.is_deleted = '0' WHERE uidp.is_deleted = '0' "); //用户ID 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 333eee86..3c8d9c59 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 @@ -21,7 +21,6 @@ import java.sql.Date; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Timestamp; -import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -31,34 +30,21 @@ import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheEvict; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; -import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate; -import org.springframework.data.elasticsearch.client.elc.NativeQuery; -import org.springframework.data.elasticsearch.client.elc.NativeQueryBuilder; -import org.springframework.data.elasticsearch.core.SearchHit; -import org.springframework.data.elasticsearch.core.SearchHitsIterator; -import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; import org.springframework.jdbc.core.BatchPreparedStatementSetter; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Repository; -import org.springframework.util.CollectionUtils; -import cn.topiam.employee.common.entity.account.UserElasticSearchEntity; import cn.topiam.employee.common.entity.account.UserEntity; -import cn.topiam.employee.common.entity.account.po.UserEsPO; import cn.topiam.employee.common.entity.account.po.UserPO; import cn.topiam.employee.common.entity.account.query.UserListNotInGroupQuery; import cn.topiam.employee.common.entity.account.query.UserListQuery; import cn.topiam.employee.common.repository.account.UserRepositoryCustomized; import cn.topiam.employee.common.repository.account.impl.mapper.UserEntityMapper; -import cn.topiam.employee.common.repository.account.impl.mapper.UserEsMapper; import cn.topiam.employee.common.repository.account.impl.mapper.UserPoMapper; import lombok.AllArgsConstructor; - -import co.elastic.clients.elasticsearch._types.query_dsl.Query; -import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders; import static cn.topiam.employee.common.constant.AccountConstants.USER_CACHE_NAME; /** @@ -362,120 +348,6 @@ public class UserRepositoryCustomizedImpl implements UserRepositoryCustomized { //@formatter:on } - @Override - - public List getUserList(List idList) { - //@formatter:off - String whereUserId = ""; - if (!CollectionUtils.isEmpty(idList)) { - if (idList.size() > 1) { - whereUserId = "AND `user`.id_ IN ('%s')".formatted(String.join("','", idList)); - } - else { - whereUserId = "AND `user`.id_ = '%s'".formatted(idList.get(0)); - } - } - String sql = """ - SELECT - `user`.id_, - `user`.username_, - `user`.email_, - `user`.phone_, - `user`.phone_area_code, - `user`.full_name, - `user`.nick_name, - `user`.avatar_, - `user`.status_, - `user`.data_origin, - `user`.email_verified, - `user`.phone_verified, - `user`.auth_total, - `user`.last_auth_ip, - `user`.last_auth_time, - `user`.expand_, - `user`.external_id, - `user`.expire_date, - `user`.create_by, - `user`.create_time, - `user`.update_by, - `user`.update_time, - `user`.remark_, - `user`.identity_source_id, - `user`.last_update_password_time, - `user_detail`.id_type, - `user_detail`.id_card, - `user_detail`.website_, - `user_detail`.address_, - GROUP_CONCAT( DISTINCT `organization_member`.org_id SEPARATOR ',' ) AS organization_ids, - CONCAT( '{', GROUP_CONCAT( DISTINCT CONCAT( '"', user_group.id_, '": "', user_group.name_, '"' ) SEPARATOR ',' ), '}' ) AS user_groups - FROM - `user` - LEFT JOIN `user_detail` ON `user`.id_ = user_detail.user_id - AND user_detail.is_deleted = '0' - LEFT JOIN `organization_member` ON `user`.id_ = organization_member.user_id - AND organization_member.is_deleted = '0' - LEFT JOIN `user_group_member` ON `user`.id_ = user_group_member.user_id - AND user_group_member.is_deleted = '0' - LEFT JOIN `user_group` ON `user_group`.id_ = user_group_member.group_id - AND user_group.is_deleted = '0' - WHERE - `user`.is_deleted = 0 %s - GROUP BY - `user`.id_, - `user`.username_, - `user`.email_, - `user`.phone_, - `user`.phone_area_code, - `user`.full_name, - `user`.nick_name, - `user`.avatar_, - `user`.status_, - `user`.data_origin, - `user`.email_verified, - `user`.phone_verified, - `user`.auth_total, - `user`.last_auth_ip, - `user`.last_auth_time, - `user`.expand_, - `user`.external_id, - `user`.expire_date, - `user`.create_by, - `user`.create_time, - `user`.update_by, - `user`.update_time, - `user`.remark_, - `user`.identity_source_id, - `user`.last_update_password_time - """.formatted(whereUserId); - //@formatter:on - return jdbcTemplate.query(sql, new UserEsMapper()); - } - - @Override - public List getAllUserElasticSearchEntity(IndexCoordinates userIndex) { - return getAllUserElasticSearchEntity(userIndex, - QueryBuilders.matchAll().build()._toQuery()); - } - - @Override - public List getAllUserElasticSearchEntity(IndexCoordinates userIndex, - Query query) { - if (!elasticsearchTemplate.indexOps(userIndex).exists()) { - return null; - } - NativeQuery searchQuery = new NativeQueryBuilder().withQuery(query) - // 设置每页数据量 - .withPageable(PageRequest.of(0, 2000)).build(); - List userElasticSearchEntityList = new ArrayList<>(); - SearchHitsIterator searchScrollHits = elasticsearchTemplate - .searchForStream(searchQuery, UserElasticSearchEntity.class, userIndex); - while (searchScrollHits.hasNext()) { - SearchHit next = searchScrollHits.next(); - userElasticSearchEntityList.add(next.getContent()); - } - return userElasticSearchEntityList; - } - /** * JdbcTemplate */ diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/impl/mapper/UserEsMapper.java b/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/impl/mapper/UserEsMapper.java deleted file mode 100644 index 4580e0cc..00000000 --- a/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/impl/mapper/UserEsMapper.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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.account.impl.mapper; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Map; -import java.util.Set; - -import org.apache.commons.lang3.ObjectUtils; -import org.apache.commons.lang3.StringUtils; -import org.springframework.jdbc.core.RowMapper; -import org.springframework.lang.NonNull; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; - -import cn.topiam.employee.common.entity.account.po.UserEsPO; -import cn.topiam.employee.common.enums.DataOrigin; -import cn.topiam.employee.common.enums.UserStatus; - -import lombok.extern.slf4j.Slf4j; - -/** - * @author TopIAM - * Created by support@topiam.cn on 2023/5/30 22:25 - */ -@Slf4j -public class UserEsMapper 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) - */ - @Override - public UserEsPO mapRow(@NonNull ResultSet rs, int rowNum) throws SQLException { - //@formatter:off - UserEsPO user = new UserEsPO(); - user.setId(rs.getLong("id_")); - user.setUsername(rs.getString("username_")); - user.setEmail(rs.getString("email_")); - user.setPhone(rs.getString("phone_")); - user.setPhoneAreaCode(rs.getString("phone_area_code")); - user.setFullName(rs.getString("full_name")); - user.setNickName(rs.getString("nick_name")); - user.setAvatar(rs.getString("avatar_")); - user.setStatus(UserStatus.getStatus(rs.getString("status_"))); - user.setDataOrigin(DataOrigin.getType(rs.getString("data_origin"))); - user.setEmailVerified(rs.getBoolean("email_verified")); - user.setAuthTotal(rs.getLong("auth_total")); - user.setLastAuthIp(rs.getString("last_auth_ip")); - user.setLastAuthTime(ObjectUtils.isNotEmpty(rs.getTimestamp("last_auth_time")) ? rs.getTimestamp("last_auth_time").toLocalDateTime() : null); - user.setExpand(rs.getString("expand_")); - user.setExternalId(rs.getString("external_id")); - user.setIdentitySourceId(rs.getLong("identity_source_id")); - user.setExpireDate(ObjectUtils.isNotEmpty(rs.getTimestamp("expire_date")) ? rs.getDate("expire_date").toLocalDate() : null); - user.setLastAuthTime(ObjectUtils.isNotEmpty(rs.getTimestamp("last_auth_time")) ? rs.getTimestamp("last_auth_time").toLocalDateTime() : null); - user.setCreateBy(rs.getString("create_by")); - user.setCreateTime(ObjectUtils.isNotEmpty(rs.getTimestamp("create_time")) ? rs.getTimestamp("create_time").toLocalDateTime() : null); - user.setUpdateBy(rs.getString("update_by")); - user.setUpdateTime(ObjectUtils.isNotEmpty(rs.getTimestamp("update_time")) ? rs.getTimestamp("update_time").toLocalDateTime() : null); - user.setRemark(rs.getString("remark_")); - user.setLastUpdatePasswordTime(ObjectUtils.isNotEmpty(rs.getTimestamp("last_update_password_time")) ? rs.getTimestamp("last_update_password_time").toLocalDateTime() : null); - // 额外数据 - user.setIdType(rs.getString("id_type")); - user.setIdCard(rs.getString("id_card")); - user.setWebsite(rs.getString("website_")); - user.setAddress(rs.getString("address_")); - String organizationIds = rs.getString("organization_ids"); - if (StringUtils.isNotBlank(organizationIds)) { - user.setOrganizationIds(Set.of((organizationIds.split(",")))); - } - ObjectMapper objectMapper = new ObjectMapper(); - String userGroups = rs.getString("user_groups"); - if (StringUtils.isNotBlank(userGroups)) { - Map userGroupMap; - try { - userGroupMap = objectMapper.readValue(userGroups, new TypeReference<>() { - }); - } catch (JsonProcessingException e) { - log.error("解析用户组字段json异常:[{}]", e.getMessage()); - throw new RuntimeException(e); - } - user.setUserGroups(userGroupMap); - } - return user; - //@formatter:on - } -} diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/impl/mapper/UserIdpBindPoMapper.java b/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/impl/mapper/UserIdpBindPoMapper.java index 54cb4782..a543997e 100644 --- a/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/impl/mapper/UserIdpBindPoMapper.java +++ b/eiam-common/src/main/java/cn/topiam/employee/common/repository/account/impl/mapper/UserIdpBindPoMapper.java @@ -24,14 +24,14 @@ import org.apache.commons.lang3.ObjectUtils; import org.springframework.jdbc.core.RowMapper; import org.springframework.lang.NonNull; -import cn.topiam.employee.common.entity.account.po.UserIdpBindPo; +import cn.topiam.employee.common.entity.account.po.UserIdpBindPO; /** * @author TopIAM * Created by support@topiam.cn on 2022/2/13 22:25 */ @SuppressWarnings("DuplicatedCode") -public class UserIdpBindPoMapper implements RowMapper { +public class UserIdpBindPoMapper implements RowMapper { /** * Implementations must implement this method to map each row of data * in the ResultSet. This method should not call {@code next()} on @@ -44,9 +44,9 @@ public class UserIdpBindPoMapper implements RowMapper { * column values (that is, there's no need to catch SQLException) */ @Override - public UserIdpBindPo mapRow(@NonNull ResultSet rs, int rowNum) throws SQLException { + public UserIdpBindPO mapRow(@NonNull ResultSet rs, int rowNum) throws SQLException { //@formatter:off - UserIdpBindPo userIdpBindPo = new UserIdpBindPo(); + UserIdpBindPO userIdpBindPo = new UserIdpBindPO(); userIdpBindPo.setId(rs.getLong("id_")); userIdpBindPo.setUserId(rs.getLong("user_id")); userIdpBindPo.setOpenId(rs.getString("open_id")); diff --git a/eiam-console/src/main/java/cn/topiam/employee/console/converter/app/UserIdpBindConverter.java b/eiam-console/src/main/java/cn/topiam/employee/console/converter/app/UserIdpBindConverter.java index efcd4d7c..33146f3c 100644 --- a/eiam-console/src/main/java/cn/topiam/employee/console/converter/app/UserIdpBindConverter.java +++ b/eiam-console/src/main/java/cn/topiam/employee/console/converter/app/UserIdpBindConverter.java @@ -22,7 +22,7 @@ import java.util.List; import org.mapstruct.Mapper; -import cn.topiam.employee.common.entity.account.po.UserIdpBindPo; +import cn.topiam.employee.common.entity.account.po.UserIdpBindPO; import cn.topiam.employee.console.pojo.result.app.UserIdpBindListResult; import cn.topiam.employee.support.repository.page.domain.Page; @@ -41,9 +41,9 @@ public interface UserIdpBindConverter { * @param page {@link Page} * @return {@link Page} */ - default List userIdpBindEntityConvertToUserIdpBindListResult(Iterable page) { + default List userIdpBindEntityConvertToUserIdpBindListResult(Iterable page) { List list = new ArrayList<>(); - for (UserIdpBindPo entity : page) { + for (UserIdpBindPO entity : page) { list.add(entityConvertToAppAccountResult(entity)); } return list; @@ -52,8 +52,8 @@ public interface UserIdpBindConverter { /** * 用户身份提供商绑定关系转换结果 * - * @param userIdpBindPo {@link UserIdpBindPo} + * @param userIdpBindPo {@link UserIdpBindPO} * @return {@link UserIdpBindListResult} */ - UserIdpBindListResult entityConvertToAppAccountResult(UserIdpBindPo userIdpBindPo); + UserIdpBindListResult entityConvertToAppAccountResult(UserIdpBindPO userIdpBindPo); } diff --git a/eiam-core/src/main/java/cn/topiam/employee/core/mq/UserMessageListener.java b/eiam-core/src/main/java/cn/topiam/employee/core/mq/UserMessageListener.java deleted file mode 100644 index ee95cfbf..00000000 --- a/eiam-core/src/main/java/cn/topiam/employee/core/mq/UserMessageListener.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * eiam-core - 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.core.mq; - -import java.io.IOException; -import java.util.*; - -import org.jetbrains.annotations.NotNull; -import org.springframework.amqp.core.Message; -import org.springframework.amqp.rabbit.annotation.RabbitHandler; -import org.springframework.amqp.rabbit.annotation.RabbitListener; -import org.springframework.messaging.handler.annotation.Headers; -import org.springframework.messaging.handler.annotation.Payload; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; - -import com.rabbitmq.client.Channel; - -import cn.topiam.employee.common.entity.account.UserElasticSearchEntity; -import cn.topiam.employee.common.entity.account.po.UserEsPO; -import cn.topiam.employee.common.repository.account.OrganizationRepository; -import cn.topiam.employee.common.repository.account.UserElasticSearchRepository; -import cn.topiam.employee.common.repository.account.UserRepository; - -import lombok.extern.slf4j.Slf4j; -import static cn.topiam.employee.core.mq.AbstractMessagePublisher.USER_DELETE; -import static cn.topiam.employee.core.mq.AbstractMessagePublisher.USER_SAVE; - -/** - * 用户消息监听器 - * - * @author TopIAM - * Created by support@topiam.cn on 2023/5/30 23:12 - */ -@Slf4j -@Component -public class UserMessageListener extends AbstractMessageListener { - - /** - * 接收用户消息 - * - * @param message {@link Message} - * @param channel {@link Channel} - * @param body {@link String} - * @param headers {@link Map} - */ - @Override - @RabbitListener(queues = { USER_SAVE, USER_DELETE }, ackMode = "MANUAL") - @RabbitHandler() - public void onMessage(Message message, Channel channel, @Payload String body, - @Headers Map headers) throws IOException { - super.onMessage(message, channel, body, headers); - log.info("异步接收ES用户信息入参: [{}]", message); - syncUser(message, channel, body); - } - - /** - * 同步用户数据 - * - * @param message {@link Message} - * @param channel {@link Channel} - * @param body {@link String} - */ - private void syncUser(Message message, Channel channel, String body) { - try { - // 处理消息逻辑 - String queueName = message.getMessageProperties().getConsumerQueue(); - if (!StringUtils.hasText(body)) { - log.warn("接收用户消息内容为空:[{}]", message.getMessageProperties().getDeliveryTag()); - return; - } - log.info("接收用户消息:[{}]", body); - List idList = Arrays.asList(body.split(",")); - if (queueName.equals(USER_SAVE)) { - List userList = userRepository.getUserList(idList); - List userElasticSearchEntity = getUserElasticSearchEntity( - userList, organizationRepository); - userElasticSearchRepository.saveAll(userElasticSearchEntity); - } else if (queueName.equals(USER_DELETE)) { - userElasticSearchRepository.deleteAllById(idList); - } - log.info("同步用户数据成功:[{}]", message.getMessageProperties().getDeliveryTag()); - channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); - } catch (Exception e) { - log.error("处理用户数据失败出现异常: MessageProperties: [{}], 用户ID:[{}], Error:[{}]", - message.getMessageProperties(), body, e.getMessage(), e); - try { - channel.basicReject(message.getMessageProperties().getDeliveryTag(), true); - } catch (IOException exception) { - log.error("接收用户消息退回出现异常: MessageProperties: [{}], 用户ID:[{}], Error:[{}]", - message.getMessageProperties(), body, e.getMessage(), e); - } - } - } - - /** - * 构建用户es对象 - * - * @param userList {@link List} - * @param organizationRepository {@link OrganizationRepository} - * @return {@link List} - */ - @NotNull - public static List getUserElasticSearchEntity(List userList, - OrganizationRepository organizationRepository) { - List userElasticSearchEntityList = new ArrayList<>(); - userList.forEach(user -> { - UserElasticSearchEntity entity = UserElasticSearchEntity.builder().build(); - entity.setId(user.getId().toString()); - entity.setUsername(user.getUsername()); - entity.setEmail(user.getEmail()); - entity.setPhone(user.getPhone()); - entity.setPhoneAreaCode(user.getPhoneAreaCode()); - entity.setFullName(user.getFullName()); - entity.setNickName(user.getNickName()); - entity.setAvatar(user.getAvatar()); - if (Objects.nonNull(user.getStatus())) { - entity.setStatus(user.getStatus().getCode()); - } - if (Objects.nonNull(user.getDataOrigin())) { - entity.setDataOrigin(user.getDataOrigin().getCode()); - } - entity.setIdentitySourceId(user.getIdentitySourceId()); - entity.setEmailVerified(user.getEmailVerified()); - entity.setPhoneVerified(user.getPhoneVerified()); - entity.setAuthTotal(user.getAuthTotal()); - entity.setLastAuthIp(user.getLastAuthIp()); - if (Objects.nonNull(user.getLastUpdatePasswordTime())) { - entity.setLastUpdatePasswordTime(user.getLastUpdatePasswordTime()); - } - if (Objects.nonNull(user.getLastAuthTime())) { - entity.setLastAuthTime(user.getLastAuthTime()); - } - entity.setExpand(user.getExpand()); - entity.setExternalId(user.getExternalId()); - if (Objects.nonNull(user.getExpireDate())) { - entity.setExpireDate(user.getExpireDate()); - } - // 用户详情 - entity.setIdType(user.getIdType()); - entity.setIdCard(user.getIdCard()); - entity.setWebsite(user.getWebsite()); - entity.setAddress(user.getAddress()); - // 组织列表 - if (!CollectionUtils.isEmpty(user.getOrganizationIds())) { - entity.setOrganizations(organizationRepository - .getOrganizationList(new ArrayList<>(user.getOrganizationIds()))); - } - // 用户组 - List userGroups = new ArrayList<>(); - if (!CollectionUtils.isEmpty(user.getUserGroups())) { - userGroups.addAll(user.getUserGroups().entrySet().stream() - .map(group -> new UserElasticSearchEntity.UserGroup(group.getKey(), - group.getValue())) - .toList()); - } - entity.setUserGroups(userGroups); - userElasticSearchEntityList.add(entity); - }); - - return userElasticSearchEntityList; - } - - /** - * UserElasticSearchRepository - */ - private final UserElasticSearchRepository userElasticSearchRepository; - - /** - * UserRepository - */ - private final UserRepository userRepository; - - /** - * OrganizationRepository - */ - private final OrganizationRepository organizationRepository; - - public UserMessageListener(UserElasticSearchRepository userElasticSearchRepository, - UserRepository userRepository, - OrganizationRepository organizationRepository) { - this.userElasticSearchRepository = userElasticSearchRepository; - this.userRepository = userRepository; - this.organizationRepository = organizationRepository; - } -} diff --git a/eiam-core/src/main/java/cn/topiam/employee/core/mq/UserMessagePublisher.java b/eiam-core/src/main/java/cn/topiam/employee/core/mq/UserMessagePublisher.java deleted file mode 100644 index 4b43395f..00000000 --- a/eiam-core/src/main/java/cn/topiam/employee/core/mq/UserMessagePublisher.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * eiam-core - 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.core.mq; - -import org.springframework.amqp.core.AmqpAdmin; -import org.springframework.amqp.core.BindingBuilder; -import org.springframework.amqp.core.Queue; -import org.springframework.amqp.core.TopicExchange; -import org.springframework.amqp.rabbit.AsyncRabbitTemplate; -import org.springframework.amqp.rabbit.RabbitConverterFuture; -import org.springframework.stereotype.Component; - -import cn.topiam.employee.support.constant.EiamConstants; - -import lombok.extern.slf4j.Slf4j; - -import jakarta.annotation.PostConstruct; - -/** - * 用户MQ消息发送 - * - * @author TopIAM - * Created by support@topiam.cn on 2023/5/30 23:12 - */ -@Slf4j -@Component -public class UserMessagePublisher extends AbstractMessagePublisher { - - @PostConstruct - public void init() { - TopicExchange topicExchange = new TopicExchange(USER); - Queue saveQueue = new Queue(USER_SAVE, true); - Queue deleteQueue = new Queue(USER_DELETE, true); - amqpAdmin.declareExchange(topicExchange); - amqpAdmin.declareQueue(saveQueue); - amqpAdmin.declareQueue(deleteQueue); - amqpAdmin.declareBinding(BindingBuilder.bind(saveQueue).to(topicExchange).with(USER_SAVE)); - amqpAdmin - .declareBinding(BindingBuilder.bind(deleteQueue).to(topicExchange).with(USER_DELETE)); - } - - /** - * 构造函数 - * - * @param asyncRabbitTemplate {@link AsyncRabbitTemplate} - * @param amqpAdmin {@link AmqpAdmin} - */ - public UserMessagePublisher(AsyncRabbitTemplate asyncRabbitTemplate, AmqpAdmin amqpAdmin) { - super(asyncRabbitTemplate, amqpAdmin); - } - - /** - * 发送异步用户消息 - * - * @param tag {@link UserMessageTag} SAVE/DELETE - * @param userIds {@link String} 逗号分隔的用户id - */ - public void sendUserChangeMessage(UserMessageTag tag, String userIds) { - log.info("发送[{}]用户消息, 用户ID:[{}]", tag.name(), userIds); - String routingKey = USER + EiamConstants.POINT + tag.name().toLowerCase(); - RabbitConverterFuture future = sendMessage(USER, routingKey, userIds); - future.whenComplete((result, ex) -> { - if (ex == null) { - log.info("发送[{}]用户消息成功, 用户ID:[{}],处理结果为:[{}]", tag.name(), userIds, result); - } else { - log.info("发送[{}]用户消息异常,用户ID:[{}],失败原因:[{}] ", tag.name(), userIds, ex); - } - }); - } -} diff --git a/eiam-core/src/main/java/cn/topiam/employee/core/mq/UserMessageTag.java b/eiam-core/src/main/java/cn/topiam/employee/core/mq/UserMessageTag.java deleted file mode 100644 index 380e5621..00000000 --- a/eiam-core/src/main/java/cn/topiam/employee/core/mq/UserMessageTag.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * eiam-core - 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.core.mq; - -/** - * 用户消息标签 - * - * @author TopIAM - * Created by support@topiam.cn on 2023/5/30 23:12 - */ -public enum UserMessageTag { - /** - * 删除 - */ - DELETE, - /** - * 保存 - */ - SAVE -} diff --git a/eiam-portal/src/main/java/cn/topiam/employee/portal/converter/AccountConverter.java b/eiam-portal/src/main/java/cn/topiam/employee/portal/converter/AccountConverter.java index b831db35..75573ee4 100644 --- a/eiam-portal/src/main/java/cn/topiam/employee/portal/converter/AccountConverter.java +++ b/eiam-portal/src/main/java/cn/topiam/employee/portal/converter/AccountConverter.java @@ -31,7 +31,7 @@ import cn.topiam.employee.authentication.common.authentication.IdpUserDetails; import cn.topiam.employee.common.entity.account.UserDetailEntity; import cn.topiam.employee.common.entity.account.UserEntity; import cn.topiam.employee.common.entity.account.UserIdpBindEntity; -import cn.topiam.employee.common.entity.account.po.UserIdpBindPo; +import cn.topiam.employee.common.entity.account.po.UserIdpBindPO; import cn.topiam.employee.common.entity.authn.IdentityProviderEntity; import cn.topiam.employee.portal.pojo.request.UpdateUserInfoRequest; import cn.topiam.employee.portal.pojo.result.BoundIdpListResult; @@ -124,11 +124,11 @@ public interface AccountConverter { * 账号绑定entity转result * * @param identityProviderList {@link List} - * @param userIdpBindList {@link Iterable} + * @param userIdpBindList {@link Iterable< UserIdpBindPO >} * @return {@link List< BoundIdpListResult >} */ default List entityConverterToBoundIdpListResult(List identityProviderList, - Iterable userIdpBindList) { + Iterable userIdpBindList) { List boundIdpListResultList = new ArrayList<>(); for (IdentityProviderEntity identityProviderEntity : identityProviderList) { BoundIdpListResult boundIdpListResult = new BoundIdpListResult(); @@ -138,7 +138,7 @@ public interface AccountConverter { boundIdpListResult.setType(identityProviderEntity.getType()); boundIdpListResult.setCategory(identityProviderEntity.getCategory()); boundIdpListResult.setBound(false); - for (UserIdpBindPo userIdpBindPo : userIdpBindList) { + for (UserIdpBindPO userIdpBindPo : userIdpBindList) { if (userIdpBindPo.getIdpId() .equals(String.valueOf(identityProviderEntity.getId()))) { boundIdpListResult.setBound(true); diff --git a/eiam-portal/src/main/java/cn/topiam/employee/portal/service/impl/AccountServiceImpl.java b/eiam-portal/src/main/java/cn/topiam/employee/portal/service/impl/AccountServiceImpl.java index 843f64fa..baf61061 100644 --- a/eiam-portal/src/main/java/cn/topiam/employee/portal/service/impl/AccountServiceImpl.java +++ b/eiam-portal/src/main/java/cn/topiam/employee/portal/service/impl/AccountServiceImpl.java @@ -40,7 +40,7 @@ import cn.topiam.employee.audit.context.AuditContext; import cn.topiam.employee.audit.entity.Target; import cn.topiam.employee.common.entity.account.UserDetailEntity; import cn.topiam.employee.common.entity.account.UserEntity; -import cn.topiam.employee.common.entity.account.po.UserIdpBindPo; +import cn.topiam.employee.common.entity.account.po.UserIdpBindPO; import cn.topiam.employee.common.entity.authn.IdentityProviderEntity; import cn.topiam.employee.common.enums.MailType; import cn.topiam.employee.common.enums.MessageNoticeChannel; @@ -353,7 +353,7 @@ public class AccountServiceImpl implements AccountService { List identityProviderList = identityProviderRepository .findByEnabledIsTrueAndDisplayedIsTrue(); // 获取已绑定idp - Iterable userIdpBindList = userIdpRepository + Iterable userIdpBindList = userIdpRepository .getUserIdpBindList(Long.valueOf(SecurityUtils.getCurrentUserId())); return accountConverter.entityConverterToBoundIdpListResult(identityProviderList, userIdpBindList); diff --git a/eiam-portal/src/main/java/cn/topiam/employee/portal/service/impl/UserIdpServiceImpl.java b/eiam-portal/src/main/java/cn/topiam/employee/portal/service/impl/UserIdpServiceImpl.java index ac46e8d9..f380468e 100644 --- a/eiam-portal/src/main/java/cn/topiam/employee/portal/service/impl/UserIdpServiceImpl.java +++ b/eiam-portal/src/main/java/cn/topiam/employee/portal/service/impl/UserIdpServiceImpl.java @@ -28,7 +28,7 @@ import cn.topiam.employee.authentication.common.authentication.IdpUserDetails; import cn.topiam.employee.authentication.common.service.UserIdpService; import cn.topiam.employee.common.entity.account.UserEntity; import cn.topiam.employee.common.entity.account.UserIdpBindEntity; -import cn.topiam.employee.common.entity.account.po.UserIdpBindPo; +import cn.topiam.employee.common.entity.account.po.UserIdpBindPO; import cn.topiam.employee.common.entity.authn.IdentityProviderEntity; import cn.topiam.employee.common.repository.account.UserIdpRepository; import cn.topiam.employee.common.repository.account.UserRepository; @@ -68,7 +68,7 @@ public class UserIdpServiceImpl implements UserIdpService { if (!source.get().getEnabled()) { throw new TopIamException("认证源已禁用"); } - Optional authnBind = userIdpRepository.findByIdpIdAndOpenId(providerId, + Optional authnBind = userIdpRepository.findByIdpIdAndOpenId(providerId, openId); return authnBind.isPresent(); } @@ -119,7 +119,7 @@ public class UserIdpServiceImpl implements UserIdpService { } private UserEntity getUser(String openId, String providerId) { - Optional bindEntity = userIdpRepository.findByIdpIdAndOpenId(providerId, + Optional bindEntity = userIdpRepository.findByIdpIdAndOpenId(providerId, openId); if (bindEntity.isEmpty()) { throw new NullPointerException("用户未绑定");