♻️ 重构

pull/82/head^2
awenes 2024-04-04 21:57:11 +08:00
parent 4214f08ee4
commit b146b35911
79 changed files with 605 additions and 608 deletions

View File

@ -31,20 +31,61 @@ public final class AppConstants {
/**
* API
*/
public final static String APP_PATH = V1_API_PATH + "/app";
public final static String APP_PATH = V1_API_PATH + "/app";
/**
*
*/
public static final String APP_GROUP_NAME = "应用管理";
public static final String APP_GROUP_NAME = "应用管理";
/**
* APP
*/
public static final String APP_CACHE_NAME_PREFIX = "app" + COLON;
public static final String APP_CACHE_NAME_PREFIX = "app" + COLON;
/**
* APP
*/
public static final String APP_CACHE_NAME = APP_CACHE_NAME_PREFIX + "basic";
public static final String APP_CACHE_NAME = APP_CACHE_NAME_PREFIX + "basic";
/**
* code
*/
public static final String APP_CODE = "appCode";
/**
*
*/
public static final String APP_CODE_VARIABLE = "{" + APP_CODE + "}";
/**
*
*/
public static final String APP_ACCOUNT_CACHE_NAME = APP_CACHE_NAME_PREFIX + "account";
/**
* OIDC
*/
public static final String OIDC_CONFIG_CACHE_NAME = APP_CACHE_NAME_PREFIX + "oidc";
/**
* APP Cert
*/
public static final String APP_CERT_CACHE_NAME = APP_CACHE_NAME_PREFIX + "cert";
/**
* FORM
*/
public static final String FORM_CONFIG_CACHE_NAME = APP_CACHE_NAME_PREFIX + "form";
/**
* TSA
*/
public static final String TSA_CONFIG_CACHE_NAME = APP_CACHE_NAME_PREFIX + "tsa";
/**
* JWT
*/
public static final String JWT_CONFIG_CACHE_NAME = APP_CACHE_NAME_PREFIX + "jwt";
}

View File

@ -20,7 +20,7 @@ package cn.topiam.employee.common.constant;
import lombok.Data;
import static com.nimbusds.openid.connect.sdk.op.OIDCProviderConfigurationRequest.OPENID_PROVIDER_WELL_KNOWN_PATH;
import static cn.topiam.employee.common.constant.AppConstants.APP_CACHE_NAME_PREFIX;
import static cn.topiam.employee.common.constant.AppConstants.APP_CODE_VARIABLE;
import static cn.topiam.employee.common.constant.AuthorizeConstants.AUTHORIZE_PATH;
/**
@ -31,46 +31,6 @@ import static cn.topiam.employee.common.constant.AuthorizeConstants.AUTHORIZE_PA
*/
public final class ProtocolConstants {
/**
* code
*/
public static final String APP_CODE = "appCode";
/**
*
*/
public static final String APP_CODE_VARIABLE = "{" + APP_CODE + "}";
/**
*
*/
public static final String APP_ACCOUNT_CACHE_NAME = APP_CACHE_NAME_PREFIX + "account";
/**
* OIDC
*/
public static final String OIDC_CONFIG_CACHE_NAME = APP_CACHE_NAME_PREFIX + "oidc";
/**
* APP Cert
*/
public static final String APP_CERT_CACHE_NAME = APP_CACHE_NAME_PREFIX + "cert";
/**
* FORM
*/
public static final String FORM_CONFIG_CACHE_NAME = APP_CACHE_NAME_PREFIX + "form";
/**
* TSA
*/
public static final String TSA_CONFIG_CACHE_NAME = APP_CACHE_NAME_PREFIX + "tsa";
/**
* JWT
*/
public static final String JWT_CONFIG_CACHE_NAME = APP_CACHE_NAME_PREFIX + "jwt";
/**
* OIDC Endpoint config
*/

View File

@ -54,16 +54,21 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
public class UserGroupEntity extends LogicDeleteEntity<Long> {
@Serial
private static final long serialVersionUID = -2619231849746900857L;
private static final long serialVersionUID = -2619231849746900857L;
public static final String CODE_FIELD_NAME = "code";
public static final String NAME_FIELD_NAME = "name";
/**
*
*/
@Column(name = "name_")
private String name;
private String name;
/**
*
*/
@Column(name = "code_")
private String code;
private String code;
}

View File

@ -50,81 +50,86 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
@SQLDelete(sql = "update app_cert set " + SOFT_DELETE_SET + " where id_ = ?")
@Where(clause = SOFT_DELETE_WHERE)
public class AppCertEntity extends LogicDeleteEntity<Long> {
public static final String APP_ID_FIELD_NAME = "appId";
public static final String USING_TYPE_FIELD_NAME = "usingType";
/**
* ID
*/
@Column(name = "app_id")
private Long appId;
private Long appId;
/**
*
*/
@Column(name = "serial_")
private BigInteger serial;
private BigInteger serial;
/**
*
*/
@Column(name = "subject_")
private String subject;
private String subject;
/**
*
*/
@Column(name = "issuer_")
private String issuer;
private String issuer;
/**
*
*/
@Column(name = "begin_date")
private LocalDateTime beginDate;
private LocalDateTime beginDate;
/**
*
*/
@Column(name = "end_date")
private LocalDateTime endDate;
private LocalDateTime endDate;
/**
*
*/
@Column(name = "validity_")
private Integer validity;
private Integer validity;
/**
*
*/
@Column(name = "sign_algo")
private String signAlgo;
private String signAlgo;
/**
*
*/
@Column(name = "key_long")
private Integer keyLong;
private Integer keyLong;
/**
*
*/
@Column(name = "private_key")
private String privateKey;
private String privateKey;
/**
*
*/
@Column(name = "public_key")
private String publicKey;
private String publicKey;
/**
*
*/
@Column(name = "cert_")
private String cert;
private String cert;
/**
* 使
*/
@Column(name = "using_type")
private AppCertUsingType usingType;
private AppCertUsingType usingType;
}

View File

@ -20,9 +20,10 @@ package cn.topiam.employee.common.entity.app;
import java.io.Serializable;
import java.util.List;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.Where;
import org.hibernate.type.SqlTypes;
import cn.topiam.employee.common.enums.app.FormEncryptType;
import cn.topiam.employee.common.enums.app.FormSubmitType;
@ -34,7 +35,6 @@ import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;
import io.hypersistence.utils.hibernate.type.json.JsonType;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
@ -116,7 +116,7 @@ public class AppFormConfigEntity extends LogicDeleteEntity<Long> {
*
*/
@Column(name = "other_field")
@Type(JsonType.class)
@JdbcTypeCode(SqlTypes.JSON)
private List<OtherField> otherField;
@Data

View File

@ -20,6 +20,8 @@ package cn.topiam.employee.common.entity.app;
import java.util.Set;
import org.hibernate.annotations.*;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.type.SqlTypes;
import cn.topiam.employee.support.repository.domain.LogicDeleteEntity;
@ -28,7 +30,6 @@ import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;
import io.hypersistence.utils.hibernate.type.json.JsonType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
@ -61,42 +62,42 @@ public class AppOidcConfigEntity extends LogicDeleteEntity<Long> {
*
*/
@Column(name = "client_auth_methods")
@Type(JsonType.class)
@JdbcTypeCode(SqlTypes.JSON)
private Set<String> clientAuthMethods;
/**
*
*/
@Column(name = "auth_grant_types")
@Type(JsonType.class)
@JdbcTypeCode(SqlTypes.JSON)
private Set<String> authGrantTypes;
/**
*
*/
@Column(name = "response_types")
@Type(JsonType.class)
@JdbcTypeCode(SqlTypes.JSON)
private Set<String> responseTypes;
/**
* URIs
*/
@Column(name = "redirect_uris")
@Type(JsonType.class)
@JdbcTypeCode(SqlTypes.JSON)
private Set<String> redirectUris;
/**
* URIs
*/
@Column(name = "post_logout_redirect_uris")
@Type(JsonType.class)
@JdbcTypeCode(SqlTypes.JSON)
private Set<String> postLogoutRedirectUris;
/**
* scopes
*/
@Column(name = "grant_scopes")
@Type(JsonType.class)
@JdbcTypeCode(SqlTypes.JSON)
private Set<String> grantScopes;
/**

View File

@ -54,48 +54,52 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
public class IdentityProviderEntity extends LogicDeleteEntity<Long> {
@Serial
private static final long serialVersionUID = -7936931011805155568L;
private static final long serialVersionUID = -7936931011805155568L;
public static final String CATEGORY_FIELD_NAME = "category";
public static final String NAME_FIELD_NAME = "name";
/**
*
*/
@Column(name = "name_")
private String name;
private String name;
/**
* CODE
*/
@Column(name = "code_")
private String code;
private String code;
/**
*
*/
@Column(name = "type_")
private String type;
private String type;
/**
*
*/
@Column(name = "category_")
private String category;
private String category;
/**
* JSON
*/
@Column(name = "config_")
private String config;
private String config;
/**
*
*/
@Column(name = "is_enabled")
private Boolean enabled;
private Boolean enabled;
/**
*
*/
@Column(name = "is_displayed")
private Boolean displayed;
private Boolean displayed;
}

View File

@ -19,9 +19,10 @@ package cn.topiam.employee.common.entity.identitysource;
import java.io.Serial;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.Where;
import org.hibernate.type.SqlTypes;
import cn.topiam.employee.common.entity.identitysource.config.JobConfig;
import cn.topiam.employee.common.entity.identitysource.config.StrategyConfig;
@ -33,7 +34,6 @@ import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;
import io.hypersistence.utils.hibernate.type.json.JsonType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
@ -60,6 +60,9 @@ public class IdentitySourceEntity extends LogicDeleteEntity<Long> {
@Serial
private static final long serialVersionUID = -7936931011805155568L;
public static final String NAME_FIELD_NAME = "name";
/**
*
*/
@ -88,14 +91,14 @@ public class IdentitySourceEntity extends LogicDeleteEntity<Long> {
* JSON
*/
@Column(name = "strategy_config")
@Type(JsonType.class)
@JdbcTypeCode(SqlTypes.JSON)
private StrategyConfig strategyConfig;
/**
* JSON
*/
@Column(name = "job_config")
@Type(JsonType.class)
@JdbcTypeCode(SqlTypes.JSON)
private JobConfig jobConfig;
/**

View File

@ -56,6 +56,14 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
@Where(clause = SOFT_DELETE_WHERE)
public class IdentitySourceEventRecordEntity extends LogicDeleteEntity<Long> {
public static final String IDENTITY_SOURCE_ID_FIELD_NAME = "identitySourceId";
public static final String ACTION_TYPE_FIELD_NAME = "actionType";
public static final String OBJECT_TYPE_FIELD_NAME = "objectType";
public static final String STATUS_FIELD_NAME = "status";
/**
* ID
*/

View File

@ -56,6 +56,14 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
@Where(clause = SOFT_DELETE_WHERE)
public class IdentitySourceSyncHistoryEntity extends LogicDeleteEntity<Long> {
public static final String IDENTITY_SOURCE_ID_FIELD_NAME = "identitySourceId";
public static final String TRIGGER_TYPE_FIELD_NAME = "triggerType";
public static final String OBJECT_TYPE_FIELD_NAME = "objectType";
public static final String STATUS_FIELD_NAME = "status";
/**
*
*/

View File

@ -56,100 +56,106 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
public class AdministratorEntity extends LogicDeleteEntity<Long> {
@Serial
private static final long serialVersionUID = -2619231849746900857L;
private static final long serialVersionUID = -2619231849746900857L;
public static final String USERNAME_FIELD_NAME = "username";
public static final String PHONE_FIELD_NAME = "phone";
public static final String EMAIL_FIELD_NAME = "email";
/**
*
*/
@Column(name = "username_")
private String username;
private String username;
/**
*
*/
@Column(name = "full_name")
private String fullName;
private String fullName;
/**
*
*/
@Column(name = "nick_name")
private String nickName;
private String nickName;
/**
*
*/
@Column(name = "password_")
private String password;
private String password;
/**
*
*/
@Column(name = "email_")
private String email;
private String email;
/**
*
*/
@Column(name = "phone_")
private String phone;
private String phone;
/**
*
*/
@Column(name = "phone_area_code")
private String phoneAreaCode;
private String phoneAreaCode;
/**
*
*/
@Column(name = "phone_verified")
private Boolean phoneVerified;
private Boolean phoneVerified;
/**
* URL
*/
@Column(name = "avatar_")
private String avatar;
private String avatar;
/**
* ENABLE: DISABLE: LOCKING:
*/
@Column(name = "status_")
private UserStatus status;
private UserStatus status;
/**
*
*/
@Column(name = "email_verified")
private Boolean emailVerified;
private Boolean emailVerified;
/**
*
*/
@Column(name = "auth_total")
private Long authTotal;
private Long authTotal;
/**
* IP
*/
@Column(name = "last_auth_ip")
private String lastAuthIp;
private String lastAuthIp;
/**
*
*/
@Column(name = "last_auth_time")
private LocalDateTime lastAuthTime;
private LocalDateTime lastAuthTime;
/**
*
*/
@Column(name = "last_update_password_time")
private LocalDateTime lastUpdatePasswordTime;
private LocalDateTime lastUpdatePasswordTime;
/**
*
*/
@Column(name = "expand_")
private String expand;
private String expand;
}

View File

@ -17,9 +17,10 @@
*/
package cn.topiam.employee.common.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import cn.topiam.employee.support.enums.BaseEnum;
import cn.topiam.employee.support.web.converter.EnumConvert;
import com.fasterxml.jackson.annotation.JsonValue;
/**
* <p>

View File

@ -48,6 +48,7 @@ public class DefaultMailProviderSendImpl implements MailProviderSend {
public static final String MAIL_SMTP_SOCKET_FACTORY_CLASS = "mail.smtp.socketFactory.class";
public static final String JAVAX_NET_SSL_SSLSOCKET_FACTORY = "javax.net.ssl.SSLSocketFactory";
public static final String MAIL_SMTP_AUTH = "mail.smtp.auth";
public static final String MAIL_SMTP_STARTTLS_ENABLE = "mail.smtp.starttls.enable";
private final MailProviderConfig mailProvider;
public DefaultMailProviderSendImpl(MailProviderConfig mailProvider, TaskExecutor taskExecutor) {
@ -73,6 +74,7 @@ public class DefaultMailProviderSendImpl implements MailProviderSend {
Properties properties = new Properties();
properties.setProperty(MAIL_SMTP_AUTH, TRUE);
properties.setProperty(MAIL_SMTP_SOCKET_FACTORY_CLASS, JAVAX_NET_SSL_SSLSOCKET_FACTORY);
properties.setProperty(MAIL_SMTP_STARTTLS_ENABLE, TRUE);
javaMailSender.setJavaMailProperties(properties);
}
return javaMailSender;

View File

@ -21,7 +21,6 @@ import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@ -39,7 +38,6 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
@Repository
public interface OrganizationMemberRepository extends
LogicDeleteRepository<OrganizationMemberEntity, Long>,
QuerydslPredicateExecutor<OrganizationMemberEntity>,
OrganizationMemberCustomizedRepository {
/**

View File

@ -29,7 +29,6 @@ import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@ -52,7 +51,6 @@ import static cn.topiam.employee.common.constant.AccountConstants.ORG_CACHE_NAME
@CacheConfig(cacheNames = { ORG_CACHE_NAME })
public interface OrganizationRepository extends LogicDeleteRepository<OrganizationEntity, String>,
JpaSpecificationExecutor<OrganizationEntity>,
QuerydslPredicateExecutor<OrganizationRepository>,
OrganizationRepositoryCustomized {
/**
@ -287,4 +285,22 @@ public interface OrganizationRepository extends LogicDeleteRepository<Organizati
@CacheEvict(allEntries = true)
@Override
void deleteAllById(@NotNull Iterable<? extends String> ids);
/**
* id
*
* @param orgId {@link String}
* @return {@link List}
*/
@Query(value = """
SELECT
user.id
FROM
UserEntity user
INNER JOIN OrganizationMemberEntity om ON user.id = om.userId
INNER JOIN OrganizationEntity organization ON organization.id = om.orgId
WHERE
organization.id = :orgId OR LOCATE(:orgId, organization.path) > 0
""")
List<String> getOrgMemberList(@Param("orgId") String orgId);
}

View File

@ -19,8 +19,6 @@ package cn.topiam.employee.common.repository.account;
import java.util.List;
import com.querydsl.core.types.dsl.NumberExpression;
import cn.topiam.employee.common.entity.account.OrganizationEntity;
import cn.topiam.employee.common.entity.account.po.OrganizationPO;
@ -51,13 +49,4 @@ public interface OrganizationRepositoryCustomized {
* @return {@link List}
*/
List<OrganizationPO> getOrganizationList(List<String> idList);
/**
* id
*
* @param orgId {@link String}
* @param orgId {@link NumberExpression}
* @return {@link List}
*/
List<Long> getOrgMemberList(String orgId, NumberExpression<Long> expression);
}

View File

@ -22,7 +22,6 @@ import java.util.Optional;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@ -41,7 +40,6 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
*/
@Repository
public interface UserDetailRepository extends LogicDeleteRepository<UserDetailEntity, Long>,
QuerydslPredicateExecutor<UserDetailEntity>,
UserDetailRepositoryCustomized {
/**
* user id

View File

@ -21,7 +21,6 @@ import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@ -39,7 +38,6 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
@Repository
public interface UserGroupMemberRepository extends
LogicDeleteRepository<UserGroupMemberEntity, Long>,
QuerydslPredicateExecutor<UserGroupMemberEntity>,
UserGroupMemberRepositoryCustomized {
/**

View File

@ -20,8 +20,8 @@ package cn.topiam.employee.common.repository.account;
import java.util.Optional;
import org.jetbrains.annotations.NotNull;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
@ -38,7 +38,7 @@ import cn.topiam.employee.support.repository.LogicDeleteRepository;
*/
@Repository
public interface UserGroupRepository extends LogicDeleteRepository<UserGroupEntity, Long>,
QuerydslPredicateExecutor<UserGroupEntity> {
JpaSpecificationExecutor<UserGroupEntity> {
/**
* findByIdContainsDeleted

View File

@ -19,7 +19,6 @@ package cn.topiam.employee.common.repository.account;
import java.util.List;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.stereotype.Repository;
import cn.topiam.employee.common.entity.account.UserHistoryPasswordEntity;
@ -35,8 +34,7 @@ import cn.topiam.employee.support.repository.LogicDeleteRepository;
*/
@Repository
public interface UserHistoryPasswordRepository extends
LogicDeleteRepository<UserHistoryPasswordEntity, Long>,
QuerydslPredicateExecutor<UserHistoryPasswordEntity> {
LogicDeleteRepository<UserHistoryPasswordEntity, Long> {
/**
* ID
*

View File

@ -19,7 +19,6 @@ package cn.topiam.employee.common.repository.account;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@ -36,7 +35,6 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
*/
@Repository
public interface UserIdpRepository extends LogicDeleteRepository<UserIdpBindEntity, Long>,
QuerydslPredicateExecutor<UserIdpBindEntity>,
UserIdpRepositoryCustomized {
/**

View File

@ -28,7 +28,6 @@ import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@ -51,7 +50,7 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
@Repository
@CacheConfig(cacheNames = { USER_CACHE_NAME })
public interface UserRepository extends LogicDeleteRepository<UserEntity, Long>,
QuerydslPredicateExecutor<UserEntity>, UserRepositoryCustomized {
UserRepositoryCustomized {
/**
* findById
*
@ -272,4 +271,12 @@ public interface UserRepository extends LogicDeleteRepository<UserEntity, Long>,
@Modifying
@Query(value = "UPDATE user SET auth_total = (IFNULL(auth_total,0) +1),last_auth_ip = ?2,last_auth_time = ?3 WHERE id_ = ?1", nativeQuery = true)
void updateAuthSucceedInfo(String id, String ip, LocalDateTime loginTime);
/**
* status
*
* @param status {@link UserStatus}
* @return {@link List}
*/
List<UserEntity> findAllByStatus(UserStatus status);
}

View File

@ -32,18 +32,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.util.CollectionUtils;
import com.querydsl.core.types.ExpressionUtils;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.core.types.dsl.NumberExpression;
import com.querydsl.jpa.impl.JPAQuery;
import com.querydsl.jpa.impl.JPAQueryFactory;
import cn.topiam.employee.common.entity.account.OrganizationEntity;
import cn.topiam.employee.common.entity.account.QOrganizationEntity;
import cn.topiam.employee.common.entity.account.QOrganizationMemberEntity;
import cn.topiam.employee.common.entity.account.QUserEntity;
import cn.topiam.employee.common.entity.account.po.OrganizationPO;
import cn.topiam.employee.common.repository.account.OrganizationRepositoryCustomized;
import cn.topiam.employee.common.repository.account.impl.mapper.OrganizationPoMapper;
@ -181,38 +170,9 @@ public class OrganizationRepositoryCustomizedImpl implements OrganizationReposit
return jdbcTemplate.query(sql, new OrganizationPoMapper());
}
@Override
public List<Long> getOrgMemberList(String orgId, NumberExpression<Long> expression) {
//条件
QUserEntity user = QUserEntity.userEntity;
QOrganizationEntity qOrganization = QOrganizationEntity.organizationEntity;
Predicate predicate = ExpressionUtils.and(user.isNotNull(), user.deleted.eq(Boolean.FALSE));
//FIND_IN_SET函数
BooleanExpression template = Expressions.booleanTemplate(
"FIND_IN_SET({0}, replace({1}, '/', ','))> 0", orgId, qOrganization.path);
predicate = ExpressionUtils.and(predicate, qOrganization.id.eq(orgId).or(template));
//构造查询
JPAQuery<Long> jpaQuery = jpaQueryFactory.selectFrom(user).select(expression)
.innerJoin(QOrganizationMemberEntity.organizationMemberEntity)
.on(user.id.eq(QOrganizationMemberEntity.organizationMemberEntity.userId)
.and(QOrganizationMemberEntity.organizationMemberEntity.deleted.isFalse()))
.innerJoin(qOrganization)
.on(qOrganization.id.eq(QOrganizationMemberEntity.organizationMemberEntity.orgId)
.and(qOrganization.deleted.isFalse()))
.where(predicate);
return jpaQuery.fetch();
}
private final JdbcTemplate jdbcTemplate;
private final JdbcTemplate jdbcTemplate;
/**
* JPAQueryFactory
*/
private final JPAQueryFactory jpaQueryFactory;
public OrganizationRepositoryCustomizedImpl(JdbcTemplate jdbcTemplate,
JPAQueryFactory jpaQueryFactory) {
public OrganizationRepositoryCustomizedImpl(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
this.jpaQueryFactory = jpaQueryFactory;
}
}

View File

@ -21,7 +21,6 @@ import java.util.Optional;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@ -40,7 +39,6 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
@Repository
public interface AppAccessPolicyRepository extends
LogicDeleteRepository<AppAccessPolicyEntity, Long>,
QuerydslPredicateExecutor<AppAccessPolicyEntity>,
AppAccessPolicyRepositoryCustomized {
/**
* ID

View File

@ -25,14 +25,13 @@ import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import cn.topiam.employee.common.entity.app.AppAccountEntity;
import cn.topiam.employee.support.repository.LogicDeleteRepository;
import static cn.topiam.employee.common.constant.ProtocolConstants.APP_ACCOUNT_CACHE_NAME;
import static cn.topiam.employee.common.constant.AppConstants.APP_ACCOUNT_CACHE_NAME;
import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOFT_DELETE_SET;
/**
@ -44,7 +43,6 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
@Repository
@CacheConfig(cacheNames = { APP_ACCOUNT_CACHE_NAME })
public interface AppAccountRepository extends LogicDeleteRepository<AppAccountEntity, Long>,
QuerydslPredicateExecutor<AppAccountEntity>,
AppAccountRepositoryCustomized {
/**
* save

View File

@ -25,7 +25,6 @@ import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;
@ -33,7 +32,7 @@ import cn.topiam.employee.common.entity.app.AppCertEntity;
import cn.topiam.employee.common.entity.app.AppOidcConfigEntity;
import cn.topiam.employee.common.enums.app.AppCertUsingType;
import cn.topiam.employee.support.repository.LogicDeleteRepository;
import static cn.topiam.employee.common.constant.ProtocolConstants.APP_CERT_CACHE_NAME;
import static cn.topiam.employee.common.constant.AppConstants.APP_CERT_CACHE_NAME;
import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOFT_DELETE_SET;
/**
@ -43,8 +42,7 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
* Created by support@topiam.cn on 2022/5/31 21:52
*/
@CacheConfig(cacheNames = { APP_CERT_CACHE_NAME })
public interface AppCertRepository extends LogicDeleteRepository<AppCertEntity, Long>,
QuerydslPredicateExecutor<AppCertEntity> {
public interface AppCertRepository extends LogicDeleteRepository<AppCertEntity, Long> {
/**
* ID
*

View File

@ -24,14 +24,13 @@ import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import cn.topiam.employee.common.entity.app.AppFormConfigEntity;
import cn.topiam.employee.support.repository.LogicDeleteRepository;
import static cn.topiam.employee.common.constant.ProtocolConstants.FORM_CONFIG_CACHE_NAME;
import static cn.topiam.employee.common.constant.AppConstants.FORM_CONFIG_CACHE_NAME;
import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOFT_DELETE_SET;
/**
@ -40,7 +39,6 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
@Repository
@CacheConfig(cacheNames = { FORM_CONFIG_CACHE_NAME })
public interface AppFormConfigRepository extends LogicDeleteRepository<AppFormConfigEntity, Long>,
QuerydslPredicateExecutor<AppFormConfigEntity>,
AppFormConfigRepositoryCustomized {
/**
* ID

View File

@ -21,7 +21,6 @@ import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@ -39,7 +38,6 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
@Repository
public interface AppGroupAssociationRepository extends
LogicDeleteRepository<AppGroupAssociationEntity, Long>,
QuerydslPredicateExecutor<AppGroupAssociationEntity>,
AppGroupAssociationRepositoryCustomized {
/**

View File

@ -26,7 +26,6 @@ import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
@ -40,7 +39,6 @@ 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>,
AppGroupRepositoryCustomized {
/**

View File

@ -24,14 +24,13 @@ import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import cn.topiam.employee.common.entity.app.AppJwtConfigEntity;
import cn.topiam.employee.support.repository.LogicDeleteRepository;
import static cn.topiam.employee.common.constant.ProtocolConstants.JWT_CONFIG_CACHE_NAME;
import static cn.topiam.employee.common.constant.AppConstants.JWT_CONFIG_CACHE_NAME;
import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOFT_DELETE_SET;
/**
@ -40,7 +39,6 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
@Repository
@CacheConfig(cacheNames = { JWT_CONFIG_CACHE_NAME })
public interface AppJwtConfigRepository extends LogicDeleteRepository<AppJwtConfigEntity, Long>,
QuerydslPredicateExecutor<AppJwtConfigEntity>,
AppJwtConfigRepositoryCustomized {
/**
* ID

View File

@ -24,14 +24,13 @@ import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import cn.topiam.employee.common.entity.app.AppOidcConfigEntity;
import cn.topiam.employee.support.repository.LogicDeleteRepository;
import static cn.topiam.employee.common.constant.ProtocolConstants.OIDC_CONFIG_CACHE_NAME;
import static cn.topiam.employee.common.constant.AppConstants.OIDC_CONFIG_CACHE_NAME;
import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOFT_DELETE_SET;
/**
@ -40,7 +39,6 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
@Repository
@CacheConfig(cacheNames = { OIDC_CONFIG_CACHE_NAME })
public interface AppOidcConfigRepository extends LogicDeleteRepository<AppOidcConfigEntity, Long>,
QuerydslPredicateExecutor<AppOidcConfigEntity>,
AppOidcConfigRepositoryCustomized {
/**
* ID

View File

@ -25,7 +25,6 @@ import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@ -40,7 +39,7 @@ import static cn.topiam.employee.common.constant.AppConstants.APP_CACHE_NAME;
@Repository
@CacheConfig(cacheNames = { APP_CACHE_NAME })
public interface AppRepository extends LogicDeleteRepository<AppEntity, Long>,
QuerydslPredicateExecutor<AppEntity>, AppRepositoryCustomized {
AppRepositoryCustomized {
/**
* ID

View File

@ -28,7 +28,7 @@ import cn.topiam.employee.common.repository.app.AppFormConfigRepositoryCustomize
import cn.topiam.employee.common.repository.app.impl.mapper.AppFormConfigPoMapper;
import lombok.AllArgsConstructor;
import static cn.topiam.employee.common.constant.ProtocolConstants.FORM_CONFIG_CACHE_NAME;
import static cn.topiam.employee.common.constant.AppConstants.FORM_CONFIG_CACHE_NAME;
/**
*

View File

@ -28,7 +28,7 @@ import cn.topiam.employee.common.repository.app.AppJwtConfigRepositoryCustomized
import cn.topiam.employee.common.repository.app.impl.mapper.AppJwtConfigPoMapper;
import lombok.AllArgsConstructor;
import static cn.topiam.employee.common.constant.ProtocolConstants.JWT_CONFIG_CACHE_NAME;
import static cn.topiam.employee.common.constant.AppConstants.JWT_CONFIG_CACHE_NAME;
/**
*

View File

@ -28,7 +28,7 @@ import cn.topiam.employee.common.repository.app.AppOidcConfigRepositoryCustomize
import cn.topiam.employee.common.repository.app.impl.mapper.AppOidcConfigPoMapper;
import lombok.AllArgsConstructor;
import static cn.topiam.employee.common.constant.ProtocolConstants.OIDC_CONFIG_CACHE_NAME;
import static cn.topiam.employee.common.constant.AppConstants.OIDC_CONFIG_CACHE_NAME;
/**
*

View File

@ -24,9 +24,9 @@ import org.jetbrains.annotations.NotNull;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@ -46,7 +46,7 @@ import cn.topiam.employee.support.repository.LogicDeleteRepository;
@CacheConfig(cacheNames = "idp")
public interface IdentityProviderRepository extends
LogicDeleteRepository<IdentityProviderEntity, Long>,
QuerydslPredicateExecutor<IdentityProviderEntity> {
JpaSpecificationExecutor<IdentityProviderEntity> {
/**
*
*

View File

@ -17,7 +17,7 @@
*/
package cn.topiam.employee.common.repository.identitysource;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
import cn.topiam.employee.common.entity.identitysource.IdentitySourceEventRecordEntity;
@ -32,6 +32,6 @@ import cn.topiam.employee.support.repository.LogicDeleteRepository;
@Repository
public interface IdentitySourceEventRecordRepository extends
LogicDeleteRepository<IdentitySourceEventRecordEntity, Long>,
QuerydslPredicateExecutor<IdentitySourceEventRecordEntity>,
JpaSpecificationExecutor<IdentitySourceEventRecordEntity>,
IdentitySourceEventRecordRepositoryCustomized {
}

View File

@ -24,9 +24,9 @@ import org.jetbrains.annotations.NotNull;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Repository;
@ -49,7 +49,7 @@ import cn.topiam.employee.support.repository.LogicDeleteRepository;
@Repository
@CacheConfig(cacheNames = { AccountConstants.IDS_CACHE_NAME })
public interface IdentitySourceRepository extends LogicDeleteRepository<IdentitySourceEntity, Long>,
QuerydslPredicateExecutor<IdentitySourceEntity> {
JpaSpecificationExecutor<IdentitySourceEntity> {
/**
* ID
*

View File

@ -17,7 +17,7 @@
*/
package cn.topiam.employee.common.repository.identitysource;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
import cn.topiam.employee.common.entity.identitysource.IdentitySourceSyncHistoryEntity;
@ -32,5 +32,5 @@ import cn.topiam.employee.support.repository.LogicDeleteRepository;
@Repository
public interface IdentitySourceSyncHistoryRepository extends
LogicDeleteRepository<IdentitySourceSyncHistoryEntity, Long>,
QuerydslPredicateExecutor<IdentitySourceSyncHistoryEntity> {
JpaSpecificationExecutor<IdentitySourceSyncHistoryEntity> {
}

View File

@ -17,7 +17,7 @@
*/
package cn.topiam.employee.common.repository.identitysource;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
import cn.topiam.employee.common.entity.identitysource.IdentitySourceSyncRecordEntity;
@ -32,6 +32,6 @@ import cn.topiam.employee.support.repository.LogicDeleteRepository;
@Repository
public interface IdentitySourceSyncRecordRepository extends
LogicDeleteRepository<IdentitySourceSyncRecordEntity, Long>,
QuerydslPredicateExecutor<IdentitySourceSyncRecordEntity>,
JpaSpecificationExecutor<IdentitySourceSyncRecordEntity>,
IdentitySourceSyncRecordRepositoryCustomized {
}

View File

@ -24,9 +24,9 @@ import org.jetbrains.annotations.NotNull;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@ -42,7 +42,7 @@ import static cn.topiam.employee.common.constant.SettingConstants.ADMIN_CACHE_NA
@Repository
@CacheConfig(cacheNames = { ADMIN_CACHE_NAME })
public interface AdministratorRepository extends LogicDeleteRepository<AdministratorEntity, Long>,
QuerydslPredicateExecutor<AdministratorEntity> {
JpaSpecificationExecutor<AdministratorEntity> {
/**
* findById

View File

@ -90,6 +90,7 @@ public class AliYunOssStorage extends AbstractStorage {
inputStream);
// 上传字符串
ossClient.putObject(putObjectRequest);
return aliYunConfig.getDomain() + SEPARATOR + aliYunConfig.getBucket() + SEPARATOR
+ URLEncoder.encode(key, StandardCharsets.UTF_8).replaceAll("\\+", "%20");
} catch (Exception e) {

View File

@ -1,4 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
eiam-console - 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/>.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

View File

@ -56,11 +56,11 @@ import cn.topiam.employee.common.constant.AuthorizeConstants;
import cn.topiam.employee.common.entity.setting.SettingEntity;
import cn.topiam.employee.common.repository.setting.AdministratorRepository;
import cn.topiam.employee.common.repository.setting.SettingRepository;
import cn.topiam.employee.console.security.handler.*;
import cn.topiam.employee.console.security.listener.ConsoleAuthenticationFailureEventListener;
import cn.topiam.employee.console.security.listener.ConsoleAuthenticationSuccessEventListener;
import cn.topiam.employee.console.security.listener.ConsoleLogoutSuccessEventListener;
import cn.topiam.employee.console.security.listener.ConsoleSessionInformationExpiredStrategy;
import cn.topiam.employee.console.authentication.*;
import cn.topiam.employee.console.authentication.ConsoleAuthenticationFailureEventListener;
import cn.topiam.employee.console.authentication.ConsoleAuthenticationSuccessEventListener;
import cn.topiam.employee.console.authentication.ConsoleLogoutSuccessEventListener;
import cn.topiam.employee.console.authentication.ConsoleSessionInformationExpiredStrategy;
import cn.topiam.employee.core.security.form.FormLoginSecretFilter;
import cn.topiam.employee.support.geo.GeoLocationService;
import cn.topiam.employee.support.jackjson.SupportJackson2Module;

View File

@ -40,8 +40,8 @@ import lombok.extern.slf4j.Slf4j;
import io.swagger.v3.oas.annotations.media.Schema;
import static cn.topiam.employee.common.constant.SessionConstants.CURRENT_USER;
import static cn.topiam.employee.common.util.ImageAvatarUtils.bufferedImageToBase64;
import static cn.topiam.employee.common.util.ImageAvatarUtils.generateAvatarImg;
import static cn.topiam.employee.support.util.ImageAvatarUtils.bufferedImageToBase64;
import static cn.topiam.employee.support.util.ImageAvatarUtils.generateAvatarImg;
/**
*

View File

@ -19,23 +19,21 @@ package cn.topiam.employee.console.converter.account;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.springframework.data.elasticsearch.client.elc.NativeQuery;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import com.querydsl.core.types.ExpressionUtils;
import com.querydsl.core.types.Predicate;
import cn.topiam.employee.audit.entity.AuditEntity;
import cn.topiam.employee.audit.entity.GeoLocation;
import cn.topiam.employee.audit.entity.QAuditEntity;
import cn.topiam.employee.audit.entity.UserAgent;
import cn.topiam.employee.audit.event.type.PortalEventType;
import cn.topiam.employee.common.constant.CommonConstants;
import cn.topiam.employee.common.entity.account.UserDetailEntity;
import cn.topiam.employee.common.entity.account.UserEntity;
import cn.topiam.employee.common.entity.account.po.UserPO;
@ -50,11 +48,15 @@ import cn.topiam.employee.console.pojo.update.account.UserUpdateParam;
import cn.topiam.employee.support.context.ApplicationContextHelp;
import cn.topiam.employee.support.repository.page.domain.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel;
import jakarta.persistence.criteria.Order;
import jakarta.persistence.criteria.Predicate;
import static cn.topiam.employee.audit.entity.AuditEntity.*;
import static cn.topiam.employee.audit.enums.TargetType.PORTAL;
import static cn.topiam.employee.audit.event.type.EventType.APP_SSO;
import static cn.topiam.employee.audit.event.type.EventType.LOGIN_PORTAL;
import static cn.topiam.employee.common.util.ImageAvatarUtils.bufferedImageToBase64;
import static cn.topiam.employee.common.util.ImageAvatarUtils.generateAvatarImg;
import static cn.topiam.employee.audit.service.converter.AuditDataConverter.SORT_EVENT_TIME;
import static cn.topiam.employee.support.util.ImageAvatarUtils.*;
import static cn.topiam.employee.support.util.PhoneNumberUtils.getPhoneAreaCode;
import static cn.topiam.employee.support.util.PhoneNumberUtils.getPhoneNumber;
@ -80,9 +82,8 @@ public interface UserConverter {
for (UserPO user : page.getContent()) {
UserListResult userListResult = userPoConvertToUserListResult(user);
if (org.apache.commons.lang3.StringUtils.isEmpty(userListResult.getAvatar())) {
userListResult.setAvatar(bufferedImageToBase64(
generateAvatarImg(org.apache.commons.lang3.StringUtils.defaultString(
userListResult.getFullName(), userListResult.getUsername()))));
userListResult.setAvatar(bufferedImageToBase64(generateAvatarImg(Objects
.toString(userListResult.getFullName(), userListResult.getUsername()))));
} else {
userListResult.setAvatar(userListResult.getAvatar());
}
@ -133,7 +134,7 @@ public interface UserConverter {
userEntity.setNickName(param.getNickName());
userEntity.setLastUpdatePasswordTime(LocalDateTime.now());
userEntity.setStatus(cn.topiam.employee.common.enums.UserStatus.ENABLE);
userEntity.setAvatar(CommonConstants.getRandomAvatar());
userEntity.setAvatar(getRandomAvatar());
userEntity.setDataOrigin(cn.topiam.employee.common.enums.DataOrigin.INPUT);
userEntity.setExpireDate(
java.util.Objects.isNull(param.getExpireDate()) ? java.time.LocalDate.of(2116, 12, 31)
@ -248,11 +249,29 @@ public interface UserConverter {
* @param id {@link Long}
* @return {@link NativeQuery}
*/
default Predicate auditListRequestConvertToNativeQuery(Long id) {
QAuditEntity auditEntity = QAuditEntity.auditEntity;
return ExpressionUtils.and(auditEntity.isNotNull(),
auditEntity.deleted.eq(Boolean.FALSE).and(auditEntity.actorId.eq(id.toString()))
.and(auditEntity.eventType.in(LOGIN_PORTAL, APP_SSO)));
default Specification<AuditEntity> auditListRequestConvertToSpecification(Long id,
PageModel pageModel) {
//@formatter:off
return (root, query, cb) -> {
List<Predicate> predicates = new ArrayList<>();
List<Order> orders = new ArrayList<>();
predicates.add(cb.in(root.get(EVENT_TYPE_FIELD_NAME)).value(Arrays.asList(LOGIN_PORTAL, APP_SSO)));
cb.equal(root.get(ACTOR_ID_FIELD_NAME), id);
//默认降序
orders.add(cb.desc(root.get(EVENT_TIME_FIELD_NAME)));
for (PageModel.Sort sort : pageModel.getSorts()) {
if (org.apache.commons.lang3.StringUtils.equals(sort.getSorter(),
SORT_EVENT_TIME)) {
if (sort.getAsc()) {
orders.add(cb.asc(root.get(EVENT_TIME_FIELD_NAME)));
}
}
}
query.where(cb.and(predicates.toArray(new Predicate[0])));
query.orderBy(orders);
return query.getRestriction();
};
//@formatter:on
}
/**

View File

@ -23,13 +23,11 @@ import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.util.CollectionUtils;
import com.google.common.collect.Lists;
import com.querydsl.core.types.ExpressionUtils;
import com.querydsl.core.types.Predicate;
import cn.topiam.employee.common.entity.account.QUserGroupEntity;
import cn.topiam.employee.common.entity.account.UserEntity;
import cn.topiam.employee.common.entity.account.UserGroupEntity;
import cn.topiam.employee.common.entity.account.po.UserPO;
@ -42,6 +40,11 @@ import cn.topiam.employee.console.pojo.update.account.UserGroupUpdateParam;
import cn.topiam.employee.support.context.ApplicationContextHelp;
import cn.topiam.employee.support.repository.page.domain.Page;
import jakarta.persistence.criteria.Predicate;
import static cn.topiam.employee.common.entity.account.UserGroupEntity.CODE_FIELD_NAME;
import static cn.topiam.employee.common.entity.account.UserGroupEntity.NAME_FIELD_NAME;
import static cn.topiam.employee.support.repository.base.BaseEntity.LAST_MODIFIED_TIME;
/**
*
*
@ -147,21 +150,26 @@ public interface UserGroupConverter {
UserGroupMemberListResult userPoConvertToGroupMemberListResult(UserPO user);
/**
* Querydsl Predicate
* Specification
*
* @param query {@link UserGroupListQuery} query
* @param listQuery {@link UserGroupListQuery} query
* @return {@link Predicate}
*/
default Predicate queryUserGroupListParamConvertToPredicate(UserGroupListQuery query) {
QUserGroupEntity userGroup = QUserGroupEntity.userGroupEntity;
Predicate predicate = ExpressionUtils.and(userGroup.isNotNull(),
userGroup.deleted.eq(Boolean.FALSE));
//查询条件
default Specification<UserGroupEntity> queryUserGroupListParamConvertToSpecification(UserGroupListQuery listQuery) {
//@formatter:off
predicate = StringUtils.isBlank(query.getName()) ? predicate : ExpressionUtils.and(predicate, userGroup.name.like("%" + query.getName() + "%"));
predicate = StringUtils.isBlank(query.getCode()) ? predicate : ExpressionUtils.and(predicate, userGroup.code.eq(query.getCode()));
return (root, query, cb) -> {
List<Predicate> predicates = new ArrayList<>();
if (StringUtils.isNotBlank(listQuery.getName())) {
predicates.add(cb.like(root.get(NAME_FIELD_NAME), listQuery.getName()));
}
if (StringUtils.isNotBlank(listQuery.getCode())) {
predicates.add(cb.like(root.get(CODE_FIELD_NAME), listQuery.getCode()));
}
query.where(predicates.toArray(new Predicate[0]));
query.orderBy(cb.desc(root.get(LAST_MODIFIED_TIME)));
return query.getRestriction();
};
//@formatter:on
return predicate;
}
/**

View File

@ -23,14 +23,14 @@ import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
import org.mapstruct.Mapper;
import com.querydsl.core.types.ExpressionUtils;
import com.querydsl.core.types.Predicate;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import cn.topiam.employee.common.entity.app.AppCertEntity;
import cn.topiam.employee.common.entity.app.QAppCertEntity;
import cn.topiam.employee.console.pojo.query.app.AppCertQuery;
import cn.topiam.employee.console.pojo.result.app.AppCertListResult;
import static cn.topiam.employee.common.entity.app.AppCertEntity.APP_ID_FIELD_NAME;
import static cn.topiam.employee.common.entity.app.AppCertEntity.USING_TYPE_FIELD_NAME;
/**
* Converter
@ -41,20 +41,27 @@ import cn.topiam.employee.console.pojo.result.app.AppCertListResult;
@Mapper(componentModel = "spring")
public interface AppCertConverter {
/**
* Querydsl Predicate
* Example
*
* @param query {@link AppCertQuery} query
* @return {@link Predicate}
* @return {@link Example}
*/
default Predicate queryAppCertListParamConvertToPredicate(AppCertQuery query) {
QAppCertEntity cert = QAppCertEntity.appCertEntity;
Predicate predicate = ExpressionUtils.and(cert.isNotNull(), cert.deleted.eq(Boolean.FALSE));
default Example<AppCertEntity> queryAppCertListParamConvertToExample(AppCertQuery query) {
//查询条件
//@formatter:off
predicate = StringUtils.isBlank(query.getAppId()) ? predicate : ExpressionUtils.and(predicate, cert.appId.eq(Long.valueOf(query.getAppId())));
predicate = Objects.isNull(query.getUsingType()) ? predicate : ExpressionUtils.and(predicate, cert.usingType.eq(query.getUsingType()));
//@formatter:on
return predicate;
AppCertEntity entity = new AppCertEntity();
ExampleMatcher exampleMatcher = ExampleMatcher.matching();
if (!StringUtils.isBlank(query.getAppId())) {
exampleMatcher.withMatcher(APP_ID_FIELD_NAME,
ExampleMatcher.GenericPropertyMatchers.exact());
entity.setAppId(Long.valueOf(query.getAppId()));
}
if (!Objects.isNull(query.getUsingType())) {
exampleMatcher.withMatcher(USING_TYPE_FIELD_NAME,
ExampleMatcher.GenericPropertyMatchers.exact());
entity.setUsingType(query.getUsingType());
}
return Example.of(entity, exampleMatcher);
}
/**

View File

@ -24,14 +24,12 @@ import java.util.Objects;
import org.apache.commons.lang3.RandomStringUtils;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.springframework.data.querydsl.QPageRequest;
import org.springframework.data.jpa.domain.Specification;
import com.alibaba.fastjson2.JSONObject;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.querydsl.core.types.ExpressionUtils;
import com.querydsl.core.types.Predicate;
import cn.topiam.employee.authentication.alipay.AlipayIdpOAuth2Config;
import cn.topiam.employee.authentication.common.IdentityProviderCategory;
@ -46,7 +44,6 @@ import cn.topiam.employee.authentication.qq.QqIdpOauthConfig;
import cn.topiam.employee.authentication.wechat.WeChatIdpScanCodeConfig;
import cn.topiam.employee.authentication.wechatwork.WeChatWorkIdpScanCodeConfig;
import cn.topiam.employee.common.entity.authn.IdentityProviderEntity;
import cn.topiam.employee.common.entity.authn.QIdentityProviderEntity;
import cn.topiam.employee.console.pojo.query.authn.IdentityProviderListQuery;
import cn.topiam.employee.console.pojo.result.authn.IdentityProviderListResult;
import cn.topiam.employee.console.pojo.result.authn.IdentityProviderResult;
@ -55,12 +52,14 @@ import cn.topiam.employee.console.pojo.update.authn.IdpUpdateParam;
import cn.topiam.employee.core.help.ServerHelp;
import cn.topiam.employee.support.exception.TopIamException;
import cn.topiam.employee.support.repository.page.domain.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel;
import cn.topiam.employee.support.repository.page.domain.QueryDslRequest;
import cn.topiam.employee.support.validation.ValidationUtils;
import jakarta.persistence.criteria.Predicate;
import jakarta.validation.ConstraintViolationException;
import static cn.topiam.employee.authentication.common.IdentityProviderType.*;
import static cn.topiam.employee.common.entity.authn.IdentityProviderEntity.CATEGORY_FIELD_NAME;
import static cn.topiam.employee.common.entity.authn.IdentityProviderEntity.NAME_FIELD_NAME;
import static cn.topiam.employee.support.repository.base.BaseEntity.LAST_MODIFIED_TIME;
/**
*
@ -181,26 +180,22 @@ public interface IdentityProviderConverter {
/**
* Predicate
*
* @param query {@link IdentityProviderListQuery}
* @param pageModel {@link PageModel}
* @return {@link QueryDslRequest}
* @param listQuery {@link IdentityProviderListQuery}
* @return {@link Specification}
*/
default QueryDslRequest queryIdentityProviderListParamConvertToPredicate(IdentityProviderListQuery query,
PageModel pageModel) {
QueryDslRequest request = new QueryDslRequest();
QIdentityProviderEntity queryEntity = QIdentityProviderEntity.identityProviderEntity;
Predicate predicate = ExpressionUtils.and(queryEntity.isNotNull(),
queryEntity.deleted.eq(Boolean.FALSE));
//查询条件
//@formatter:off
predicate = Objects.isNull(query.getCategory()) ? predicate : ExpressionUtils.and(predicate, queryEntity.category.eq(query.getCategory()));
predicate = Objects.isNull(query.getName()) ? predicate : ExpressionUtils.and(predicate, queryEntity.name.eq(query.getName()));
//@formatter:on
request.setPredicate(predicate);
//分页条件
request.setPageRequest(QPageRequest.of(pageModel.getCurrent(), pageModel.getPageSize(),
queryEntity.updateTime.desc()));
return request;
default Specification<IdentityProviderEntity> queryIdentityProviderListParamConvertToSpecification(IdentityProviderListQuery listQuery) {
return (root, query, cb) -> {
List<Predicate> predicates = new ArrayList<>();
if (!Objects.isNull(listQuery.getCategory())) {
predicates.add(cb.equal(root.get(CATEGORY_FIELD_NAME), listQuery.getCategory()));
}
if (!Objects.isNull(listQuery.getName())) {
predicates.add(cb.like(root.get(NAME_FIELD_NAME), "%" + listQuery.getName() + "%"));
}
query.where(predicates.toArray(new Predicate[0]));
query.orderBy(cb.desc(root.get(LAST_MODIFIED_TIME)));
return query.getRestriction();
};
}
/**

View File

@ -25,18 +25,14 @@ import org.apache.commons.lang3.StringUtils;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.springframework.data.domain.Page;
import org.springframework.data.querydsl.QPageRequest;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.util.CollectionUtils;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.JSONWriter;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.querydsl.core.types.ExpressionUtils;
import com.querydsl.core.types.Predicate;
import cn.topiam.employee.common.constant.CommonConstants;
import cn.topiam.employee.common.entity.identitysource.IdentitySourceEntity;
import cn.topiam.employee.common.entity.identitysource.QIdentitySourceEntity;
import cn.topiam.employee.common.enums.identitysource.IdentitySourceProvider;
import cn.topiam.employee.console.pojo.query.identity.IdentitySourceListQuery;
import cn.topiam.employee.console.pojo.result.identitysource.IdentitySourceConfigGetResult;
@ -51,11 +47,14 @@ import cn.topiam.employee.identitysource.dingtalk.DingTalkConfig;
import cn.topiam.employee.identitysource.feishu.FeiShuConfig;
import cn.topiam.employee.identitysource.wechatwork.WeChatWorkConfig;
import cn.topiam.employee.support.exception.TopIamException;
import cn.topiam.employee.support.repository.page.domain.PageModel;
import cn.topiam.employee.support.repository.page.domain.QueryDslRequest;
import cn.topiam.employee.support.validation.ValidationUtils;
import jakarta.persistence.criteria.Predicate;
import jakarta.validation.ConstraintViolationException;
import static com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME;
import static cn.topiam.employee.common.entity.identitysource.IdentitySourceEntity.NAME_FIELD_NAME;
import static cn.topiam.employee.support.repository.base.BaseEntity.LAST_MODIFIED_TIME;
/**
*
@ -66,6 +65,11 @@ import jakarta.validation.ConstraintViolationException;
@Mapper(componentModel = "spring")
public interface IdentitySourceConverter {
/**
*
*/
String CALLBACK_URL = "callbackUrl";
ObjectMapper OBJECT_MAPPER = new ObjectMapper();
/**
@ -231,25 +235,19 @@ public interface IdentitySourceConverter {
/**
* Request
*
* @param query {@link IdentitySourceListQuery}
* @param pageModel {@link PageModel}
* @return {@link QueryDslRequest }
* @param listQuery {@link IdentitySourceListQuery}
* @return {@link Specification }
*/
default QueryDslRequest queryIdentitySourceListParamConvertToPredicate(IdentitySourceListQuery query,
PageModel pageModel) {
QueryDslRequest request = new QueryDslRequest();
QIdentitySourceEntity queryEntity = QIdentitySourceEntity.identitySourceEntity;
Predicate predicate = ExpressionUtils.and(queryEntity.isNotNull(),
queryEntity.deleted.eq(Boolean.FALSE));
//查询条件
//@formatter:off
predicate = StringUtils.isBlank(query.getName()) ? predicate : ExpressionUtils.and(predicate, queryEntity.name.like("%" + query.getName() + "%"));
//@formatter:on
request.setPredicate(predicate);
//分页条件
//@formatter:off
request.setPageRequest(QPageRequest.of(pageModel.getCurrent(), pageModel.getPageSize(),queryEntity.updateTime.desc()));
return request;
default Specification<IdentitySourceEntity> queryIdentitySourceListParamConvertToPredicate(IdentitySourceListQuery listQuery) {
return (root, query, cb) -> {
List<Predicate> predicates = new ArrayList<>();
if (StringUtils.isNotBlank(listQuery.getName())) {
predicates.add(cb.like(root.get(NAME_FIELD_NAME), "%" + listQuery.getName() + "%"));
}
query.where(predicates.toArray(new Predicate[0]));
query.orderBy(cb.desc(root.get(LAST_MODIFIED_TIME)));
return query.getRestriction();
};
}
/**
@ -258,22 +256,22 @@ public interface IdentitySourceConverter {
* @param entity {@link IdentitySourceEntity}
* @return {@link IdentitySourceConfigGetResult}
*/
default IdentitySourceConfigGetResult entityConverterToIdentitySourceConfigGetResult(IdentitySourceEntity entity){
if (entity == null) {
return null;
}
IdentitySourceConfigGetResult identitySourceResult = new IdentitySourceConfigGetResult();
if (entity.getId() != null) {
identitySourceResult.setId(String.valueOf(entity.getId()));
}
identitySourceResult.setConfigured(entity.getConfigured());
identitySourceResult.setJobConfig(entity.getJobConfig());
identitySourceResult.setStrategyConfig(entity.getStrategyConfig());
try {
JSONObject value = OBJECT_MAPPER.readValue(entity.getBasicConfig(), JSONObject.class);
value.remove(CommonConstants.TYPE);
default IdentitySourceConfigGetResult entityConverterToIdentitySourceConfigGetResult(IdentitySourceEntity entity) {
if (entity == null) {
return null;
}
IdentitySourceConfigGetResult identitySourceResult = new IdentitySourceConfigGetResult();
if (entity.getId() != null) {
identitySourceResult.setId(String.valueOf(entity.getId()));
}
identitySourceResult.setConfigured(entity.getConfigured());
identitySourceResult.setJobConfig(entity.getJobConfig());
identitySourceResult.setStrategyConfig(entity.getStrategyConfig());
try {
JSONObject value = OBJECT_MAPPER.readValue(entity.getBasicConfig(), JSONObject.class);
value.remove(NAME);
//@formatter:off
value.put(CommonConstants.CALLBACK_URL, ServerHelp.getSynchronizerPublicBaseUrl() + "/api/v1/synchronizer/event_receive/" + entity.getCode());
value.put(CALLBACK_URL, ServerHelp.getSynchronizerPublicBaseUrl() + "/api/v1/synchronizer/event_receive/" + entity.getCode());
//@formatter:on
identitySourceResult.setBasicConfig(value);
} catch (Exception e) {

View File

@ -23,20 +23,21 @@ import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
import org.mapstruct.Mapper;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.util.CollectionUtils;
import com.querydsl.core.types.ExpressionUtils;
import com.querydsl.core.types.Predicate;
import cn.topiam.employee.common.entity.account.UserGroupEntity;
import cn.topiam.employee.common.entity.identitysource.IdentitySourceEventRecordEntity;
import cn.topiam.employee.common.entity.identitysource.QIdentitySourceEventRecordEntity;
import cn.topiam.employee.console.pojo.query.identity.IdentitySourceEventRecordListQuery;
import cn.topiam.employee.console.pojo.result.account.UserGroupListResult;
import cn.topiam.employee.console.pojo.result.identitysource.IdentitySourceEventRecordListResult;
import cn.topiam.employee.support.context.ApplicationContextHelp;
import cn.topiam.employee.support.repository.page.domain.Page;
import jakarta.persistence.criteria.Predicate;
import static cn.topiam.employee.common.entity.identitysource.IdentitySourceEventRecordEntity.*;
import static cn.topiam.employee.support.repository.base.BaseEntity.LAST_MODIFIED_TIME;
/**
*
*
@ -47,23 +48,35 @@ import cn.topiam.employee.support.repository.page.domain.Page;
public interface IdentitySourceEventRecordConverter {
/**
* Querydsl Predicate
* Specification
*
* @param query {@link IdentitySourceEventRecordListQuery} query
* @return {@link Predicate}
* @param listQuery {@link IdentitySourceEventRecordListQuery} listQuery
* @return {@link Specification}
*/
default Predicate queryIdentitySourceEventRecordListQueryConvertToPredicate(IdentitySourceEventRecordListQuery query) {
QIdentitySourceEventRecordEntity queryEntity = QIdentitySourceEventRecordEntity.identitySourceEventRecordEntity;
Predicate predicate = ExpressionUtils.and(queryEntity.isNotNull(),
queryEntity.deleted.eq(Boolean.FALSE));
default Specification<IdentitySourceEventRecordEntity> queryIdentitySourceEventRecordListQueryConvertToSpecification(IdentitySourceEventRecordListQuery listQuery) {
//查询条件
//@formatter:off
predicate = StringUtils.isBlank(query.getIdentitySourceId()) ? predicate : ExpressionUtils.and(predicate, queryEntity.identitySourceId.eq(Long.valueOf(query.getIdentitySourceId())));
predicate = Objects.isNull(query.getActionType()) ? predicate : ExpressionUtils.and(predicate, queryEntity.actionType.eq(query.getActionType()));
predicate = Objects.isNull(query.getObjectType()) ? predicate : ExpressionUtils.and(predicate, queryEntity.objectType.eq(query.getObjectType()));
predicate = Objects.isNull(query.getStatus()) ? predicate : ExpressionUtils.and(predicate, queryEntity.status.eq(query.getStatus()));
//@formatter:on
return predicate;
return (root, query, criteriaBuilder) -> {
List<Predicate> predicates = new ArrayList<>();
if (StringUtils.isNotBlank(listQuery.getIdentitySourceId())) {
predicates.add(criteriaBuilder.equal(root.get(IDENTITY_SOURCE_ID_FIELD_NAME),
listQuery.getIdentitySourceId()));
}
if (Objects.isNull(listQuery.getActionType())) {
predicates.add(criteriaBuilder.equal(root.get(ACTION_TYPE_FIELD_NAME),
listQuery.getActionType()));
}
if (Objects.isNull(listQuery.getObjectType())) {
predicates.add(criteriaBuilder.equal(root.get(OBJECT_TYPE_FIELD_NAME),
listQuery.getObjectType()));
}
if (Objects.isNull(listQuery.getStatus())) {
predicates
.add(criteriaBuilder.equal(root.get(STATUS_FIELD_NAME), listQuery.getStatus()));
}
query.where(predicates.toArray(new Predicate[0]));
query.orderBy(criteriaBuilder.desc(root.get(LAST_MODIFIED_TIME)));
return query.getRestriction();
};
}
/**

View File

@ -24,16 +24,12 @@ import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.util.CollectionUtils;
import com.querydsl.core.types.ExpressionUtils;
import com.querydsl.core.types.Predicate;
import cn.topiam.employee.common.entity.account.UserGroupEntity;
import cn.topiam.employee.common.entity.identitysource.IdentitySourceSyncHistoryEntity;
import cn.topiam.employee.common.entity.identitysource.IdentitySourceSyncRecordEntity;
import cn.topiam.employee.common.entity.identitysource.QIdentitySourceSyncHistoryEntity;
import cn.topiam.employee.common.entity.identitysource.QIdentitySourceSyncRecordEntity;
import cn.topiam.employee.console.pojo.query.identity.IdentitySourceSyncHistoryListQuery;
import cn.topiam.employee.console.pojo.query.identity.IdentitySourceSyncRecordListQuery;
import cn.topiam.employee.console.pojo.result.account.UserGroupListResult;
@ -41,6 +37,10 @@ import cn.topiam.employee.console.pojo.result.identitysource.IdentitySourceSyncH
import cn.topiam.employee.console.pojo.result.identitysource.IdentitySourceSyncRecordListResult;
import cn.topiam.employee.support.repository.page.domain.Page;
import jakarta.persistence.criteria.Predicate;
import static cn.topiam.employee.common.entity.identitysource.IdentitySourceSyncHistoryEntity.*;
import static cn.topiam.employee.support.repository.base.BaseEntity.LAST_MODIFIED_TIME;
/**
*
*
@ -51,23 +51,34 @@ import cn.topiam.employee.support.repository.page.domain.Page;
public interface IdentitySourceSyncConverter {
/**
* Querydsl Predicate
* Specification
*
* @param query {@link IdentitySourceSyncHistoryListQuery} query
* @return {@link Predicate}
* @param listQuery {@link IdentitySourceSyncHistoryListQuery} query
* @return {@link Specification}
*/
default Predicate queryIdentitySourceSyncHistoryListQueryConvertToPredicate(IdentitySourceSyncHistoryListQuery query) {
QIdentitySourceSyncHistoryEntity queryEntity = QIdentitySourceSyncHistoryEntity.identitySourceSyncHistoryEntity;
Predicate predicate = ExpressionUtils.and(queryEntity.isNotNull(),
queryEntity.deleted.eq(Boolean.FALSE));
//查询条件
//@formatter:off
predicate = StringUtils.isBlank(query.getIdentitySourceId()) ? predicate : ExpressionUtils.and(predicate, queryEntity.identitySourceId.eq(Long.valueOf(query.getIdentitySourceId())));
predicate = Objects.isNull(query.getObjectType()) ? predicate : ExpressionUtils.and(predicate, queryEntity.objectType.eq(query.getObjectType()));
predicate = Objects.isNull(query.getTriggerType()) ? predicate : ExpressionUtils.and(predicate, queryEntity.triggerType.eq(query.getTriggerType()));
predicate = Objects.isNull(query.getStatus()) ? predicate : ExpressionUtils.and(predicate, queryEntity.status.eq(query.getStatus()));
//@formatter:on
return predicate;
default Specification<IdentitySourceSyncHistoryEntity> queryIdentitySourceSyncHistoryListQueryConvertToSpecification(IdentitySourceSyncHistoryListQuery listQuery) {
return (root, query, criteriaBuilder) -> {
List<Predicate> predicates = new ArrayList<>();
if (StringUtils.isNotBlank(listQuery.getIdentitySourceId())) {
predicates.add(criteriaBuilder.equal(root.get(IDENTITY_SOURCE_ID_FIELD_NAME),
listQuery.getIdentitySourceId()));
}
if (Objects.isNull(listQuery.getTriggerType())) {
predicates.add(criteriaBuilder.equal(root.get(TRIGGER_TYPE_FIELD_NAME),
listQuery.getTriggerType()));
}
if (Objects.isNull(listQuery.getStatus())) {
predicates
.add(criteriaBuilder.equal(root.get(STATUS_FIELD_NAME), listQuery.getStatus()));
}
if (Objects.isNull(listQuery.getObjectType())) {
predicates.add(criteriaBuilder.equal(root.get(OBJECT_TYPE_FIELD_NAME),
listQuery.getObjectType()));
}
query.where(predicates.toArray(new Predicate[0]));
query.orderBy(criteriaBuilder.desc(root.get(LAST_MODIFIED_TIME)));
return query.getRestriction();
};
}
/**
@ -150,23 +161,33 @@ public interface IdentitySourceSyncConverter {
}
/**
* Querydsl Predicate
* Specification
*
* @param query {@link IdentitySourceSyncRecordListQuery} query
* @return {@link Predicate}
* @param listQuery {@link IdentitySourceSyncRecordListQuery} query
* @return {@link Specification}
*/
default Predicate queryIdentitySourceSyncRecordListQueryConvertToPredicate(IdentitySourceSyncRecordListQuery query) {
QIdentitySourceSyncRecordEntity entity = QIdentitySourceSyncRecordEntity.identitySourceSyncRecordEntity;
Predicate predicate = ExpressionUtils.and(entity.isNotNull(),
entity.deleted.eq(Boolean.FALSE));
//查询条件
//@formatter:off
predicate = StringUtils.isBlank(query.getSyncHistoryId()) ? predicate : ExpressionUtils.and(predicate, entity.syncHistoryId.eq(Long.valueOf(query.getSyncHistoryId())));
predicate = Objects.isNull(query.getObjectType()) ? predicate : ExpressionUtils.and(predicate, entity.objectType.eq(query.getObjectType()));
predicate = Objects.isNull(query.getActionType()) ? predicate : ExpressionUtils.and(predicate, entity.actionType.eq(query.getActionType()));
predicate = Objects.isNull(query.getStatus()) ? predicate : ExpressionUtils.and(predicate, entity.status.eq(query.getStatus()));
//@formatter:on
return predicate;
default Specification<IdentitySourceSyncRecordEntity> queryIdentitySourceSyncRecordListQueryConvertToSpecification(IdentitySourceSyncRecordListQuery listQuery) {
return (root, query, criteriaBuilder) -> {
List<Predicate> predicates = new ArrayList<>();
if (Objects.isNull(listQuery.getStatus())) {
predicates.add(criteriaBuilder.equal(root.get("status"), listQuery.getStatus()));
}
if (StringUtils.isNotBlank(listQuery.getSyncHistoryId())) {
predicates.add(
criteriaBuilder.equal(root.get("syncHistoryId"), listQuery.getSyncHistoryId()));
}
if (Objects.isNull(listQuery.getObjectType())) {
predicates
.add(criteriaBuilder.equal(root.get("objectType"), listQuery.getObjectType()));
}
if (Objects.isNull(listQuery.getActionType())) {
predicates
.add(criteriaBuilder.equal(root.get("actionType"), listQuery.getActionType()));
}
query.where(predicates.toArray(new Predicate[0]));
query.orderBy(criteriaBuilder.desc(root.get(LAST_MODIFIED_TIME)));
return query.getRestriction();
};
}
/**

View File

@ -19,19 +19,16 @@ package cn.topiam.employee.console.converter.setting;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.util.CollectionUtils;
import com.querydsl.core.types.ExpressionUtils;
import com.querydsl.core.types.Predicate;
import cn.topiam.employee.common.constant.CommonConstants;
import cn.topiam.employee.common.entity.account.query.UserListQuery;
import cn.topiam.employee.common.entity.setting.AdministratorEntity;
import cn.topiam.employee.common.entity.setting.QAdministratorEntity;
import cn.topiam.employee.console.pojo.query.setting.AdministratorListQuery;
import cn.topiam.employee.console.pojo.result.setting.AdministratorListResult;
import cn.topiam.employee.console.pojo.result.setting.AdministratorResult;
@ -39,10 +36,14 @@ import cn.topiam.employee.console.pojo.save.setting.AdministratorCreateParam;
import cn.topiam.employee.console.pojo.update.setting.AdministratorUpdateParam;
import cn.topiam.employee.support.repository.page.domain.Page;
import cn.topiam.employee.support.util.BeanUtils;
import static cn.topiam.employee.common.util.ImageAvatarUtils.bufferedImageToBase64;
import static cn.topiam.employee.common.util.ImageAvatarUtils.generateAvatarImg;
import cn.topiam.employee.support.util.ImageAvatarUtils;
import jakarta.persistence.criteria.Predicate;
import static cn.topiam.employee.common.entity.setting.AdministratorEntity.*;
import static cn.topiam.employee.support.repository.domain.BaseEntity.LAST_MODIFIED_BY;
import static cn.topiam.employee.support.repository.domain.BaseEntity.LAST_MODIFIED_TIME;
import static cn.topiam.employee.support.util.ImageAvatarUtils.generateAvatarImg;
import static cn.topiam.employee.support.util.ImageAvatarUtils.getRandomAvatar;
import static cn.topiam.employee.support.util.PhoneNumberUtils.getPhoneAreaCode;
import static cn.topiam.employee.support.util.PhoneNumberUtils.getPhoneNumber;
@ -70,7 +71,8 @@ public interface AdministratorConverter {
user);
//头像
if (StringUtils.isEmpty(user.getAvatar())) {
convert.setAvatar(bufferedImageToBase64(generateAvatarImg(user.getUsername())));
convert.setAvatar(ImageAvatarUtils
.bufferedImageToBase64(generateAvatarImg(user.getUsername())));
} else {
convert.setAvatar(user.getAvatar());
}
@ -133,8 +135,7 @@ public interface AdministratorConverter {
entity.setPhoneVerified(Boolean.TRUE);
entity.setPhoneAreaCode(getPhoneAreaCode(param.getPhone()));
}
entity.setAvatar(
StringUtils.defaultString(param.getAvatar(), CommonConstants.getRandomAvatar()));
entity.setAvatar(Objects.toString(param.getAvatar(), getRandomAvatar()));
entity.setStatus(cn.topiam.employee.common.enums.UserStatus.ENABLE);
entity.setAuthTotal(0L);
entity.setLastUpdatePasswordTime(java.time.LocalDateTime.now());
@ -199,21 +200,30 @@ public interface AdministratorConverter {
AdministratorResult entityConvertToAdministratorDetailsResult(AdministratorEntity user);
/**
* Querydsl Predicate
* Specification
*
* @param query {@link UserListQuery} query
* @return {@link Predicate}
* @param listQuery {@link UserListQuery} listQuery
* @return {@link Specification}
*/
default Predicate queryAdministratorListParamConvertToPredicate(AdministratorListQuery query) {
QAdministratorEntity user = QAdministratorEntity.administratorEntity;
Predicate predicate = ExpressionUtils.and(user.isNotNull(), user.deleted.eq(Boolean.FALSE));
//查询条件
//@formatter:off
predicate = StringUtils.isBlank(query.getUsername()) ? predicate : ExpressionUtils.and(predicate, user.username.eq(query.getUsername()));
predicate = StringUtils.isBlank(query.getPhone()) ? predicate : ExpressionUtils.and(predicate, user.phone.like("%" + query.getPhone() + "%"));
predicate = StringUtils.isBlank(query.getEmail()) ? predicate : ExpressionUtils.and(predicate, user.email.like("%" + query.getEmail() + "%"));
//@formatter:on
return predicate;
default Specification<AdministratorEntity> queryAdministratorListParamConvertToSpecification(AdministratorListQuery listQuery) {
return (root, query, criteriaBuilder) -> {
List<Predicate> predicates = new ArrayList<>();
if (StringUtils.isNotBlank(listQuery.getUsername())) {
predicates.add(criteriaBuilder.equal(root.get(USERNAME_FIELD_NAME),
"%" + listQuery.getUsername() + "%"));
}
if (StringUtils.isNotBlank(listQuery.getPhone())) {
predicates.add(
criteriaBuilder.equal(root.get(PHONE_FIELD_NAME), listQuery.getUsername()));
}
if (StringUtils.isNotBlank(listQuery.getEmail())) {
predicates.add(
criteriaBuilder.equal(root.get(EMAIL_FIELD_NAME), listQuery.getUsername()));
}
query.where(predicates.toArray(new Predicate[0]));
query.orderBy(criteriaBuilder.desc(root.get(LAST_MODIFIED_TIME)));
return query.getRestriction();
};
}
}

View File

@ -136,14 +136,6 @@ public interface OrganizationService {
*/
OrganizationEntity getOrganizationByExternalId(String id, Long identitySourceId);
/**
*
*
* @param orgId {@link String}
* @return {@link Long}
*/
Long getOrgMemberCount(String orgId);
/**
*
*

View File

@ -17,10 +17,7 @@
*/
package cn.topiam.employee.console.service.account.impl;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -33,7 +30,6 @@ import cn.topiam.employee.audit.context.AuditContext;
import cn.topiam.employee.audit.entity.Target;
import cn.topiam.employee.audit.enums.TargetType;
import cn.topiam.employee.common.entity.account.OrganizationEntity;
import cn.topiam.employee.common.entity.account.QUserEntity;
import cn.topiam.employee.common.enums.DataOrigin;
import cn.topiam.employee.common.repository.account.OrganizationRepository;
import cn.topiam.employee.console.converter.account.OrganizationConverter;
@ -41,7 +37,7 @@ import cn.topiam.employee.console.pojo.result.account.*;
import cn.topiam.employee.console.pojo.save.account.OrganizationCreateParam;
import cn.topiam.employee.console.pojo.update.account.OrganizationUpdateParam;
import cn.topiam.employee.console.service.account.OrganizationService;
import cn.topiam.employee.support.repository.id.SnowflakeIdGenerator;
import cn.topiam.employee.support.repository.generator.SnowflakeIdGenerator;
import cn.topiam.employee.support.util.BeanUtils;
import lombok.RequiredArgsConstructor;
@ -210,7 +206,7 @@ public class OrganizationServiceImpl implements OrganizationService {
List<OrganizationEntity> list = organizationRepository.findByParentId(id);
if (CollectionUtils.isEmpty(list)) {
//查询当前机构和当前机构下子机构下是否存在用户,不存在删除,存在抛出异常
Long count = getOrgMemberCount(id);
Integer count = getOrgMemberCount(id);
if (count > 0) {
throw new RuntimeException("删除机构失败,当前机构下存在用户");
}
@ -273,11 +269,9 @@ public class OrganizationServiceImpl implements OrganizationService {
}
entity.setParentId(parentId);
//父级路径
entity.setPath(
StringUtils.defaultString(parent.getPath()) + SEPARATE + entity.getId());
entity.setPath(parent.getPath() + SEPARATE + entity.getId());
//父级展示路径
entity.setDisplayPath(StringUtils.defaultString(parent.getDisplayPath()) + SEPARATE
+ entity.getName());
entity.setDisplayPath(parent.getDisplayPath() + SEPARATE + entity.getName());
}
organizationRepository.save(entity);
// 判断旧的父节点下是否还存在子节点,不存在更改此节点为叶子节点
@ -410,10 +404,8 @@ public class OrganizationServiceImpl implements OrganizationService {
* @param orgId {@link String}
* @return {@link Long}
*/
@Override
public Long getOrgMemberCount(String orgId) {
return organizationRepository.getOrgMemberList(orgId, QUserEntity.userEntity.count())
.get(0);
public Integer getOrgMemberCount(String orgId) {
return organizationRepository.getOrgMemberList(orgId).size();
}
/**

View File

@ -22,23 +22,18 @@ import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.querydsl.QPageRequest;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import com.google.common.collect.Lists;
import com.querydsl.core.types.ExpressionUtils;
import com.querydsl.core.types.Predicate;
import com.querydsl.jpa.impl.JPAQuery;
import com.querydsl.jpa.impl.JPAQueryFactory;
import cn.topiam.employee.audit.context.AuditContext;
import cn.topiam.employee.audit.entity.Target;
import cn.topiam.employee.audit.enums.TargetType;
import cn.topiam.employee.common.entity.account.*;
import cn.topiam.employee.common.entity.account.QUserEntity;
import cn.topiam.employee.common.entity.account.QUserGroupEntity;
import cn.topiam.employee.common.entity.account.QUserGroupMemberEntity;
import cn.topiam.employee.common.entity.account.UserGroupEntity;
import cn.topiam.employee.common.entity.account.UserGroupMemberEntity;
import cn.topiam.employee.common.entity.account.po.UserPO;
import cn.topiam.employee.common.entity.account.query.UserGroupMemberListQuery;
import cn.topiam.employee.common.repository.account.UserGroupMemberRepository;
@ -80,13 +75,11 @@ public class UserGroupServiceImpl implements UserGroupService {
@Override
public Page<UserGroupListResult> getUserGroupList(PageModel page, UserGroupListQuery query) {
//查询条件
Predicate predicate = userGroupConverter.queryUserGroupListParamConvertToPredicate(query);
//分页条件
QPageRequest request = QPageRequest.of(page.getCurrent(), page.getPageSize(),
QUserGroupEntity.userGroupEntity.updateTime.desc());
Specification<UserGroupEntity> specification = userGroupConverter
.queryUserGroupListParamConvertToSpecification(query);
//查询映射
org.springframework.data.domain.Page<UserGroupEntity> list = userGroupRepository
.findAll(predicate, request);
.findAll(specification, PageRequest.of(page.getCurrent(), page.getPageSize()));
return userGroupConverter.userGroupEntityConvertToUserGroupResult(list);
}
@ -251,27 +244,10 @@ public class UserGroupServiceImpl implements UserGroupService {
@Override
public Long getUserGroupMemberCount(String groupId) {
//条件
QUserEntity user = QUserEntity.userEntity;
QUserGroupEntity qUserGroup = QUserGroupEntity.userGroupEntity;
Predicate predicate = ExpressionUtils.and(user.isNotNull(), user.deleted.eq(Boolean.FALSE));
predicate = ExpressionUtils.and(predicate, qUserGroup.id.eq(Long.valueOf(groupId)));
//构造查询
JPAQuery<Long> jpaQuery = jpaQueryFactory.selectFrom(user).select(user.count())
.innerJoin(QUserGroupMemberEntity.userGroupMemberEntity)
.on(user.id.eq(QUserGroupMemberEntity.userGroupMemberEntity.userId)
.and(QUserGroupMemberEntity.userGroupMemberEntity.deleted.eq(Boolean.FALSE)))
.innerJoin(qUserGroup)
.on(qUserGroup.id.eq(QUserGroupMemberEntity.userGroupMemberEntity.groupId))
.where(predicate);
return jpaQuery.fetch().get(0);
return userGroupMemberRepository
.count(Example.of(new UserGroupMemberEntity().setGroupId(Long.valueOf(groupId))));
}
/**
* JPAQueryFactory
*/
private final JPAQueryFactory jpaQueryFactory;
/**
*
*/

View File

@ -24,8 +24,9 @@ import java.time.LocalDateTime;
import java.util.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.querydsl.QPageRequest;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.http.HttpStatus;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
@ -34,17 +35,16 @@ import org.springframework.transaction.annotation.Transactional;
import com.google.i18n.phonenumbers.NumberParseException;
import com.google.i18n.phonenumbers.PhoneNumberUtil;
import com.google.i18n.phonenumbers.Phonenumber;
import com.querydsl.core.types.OrderSpecifier;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanExpression;
import cn.topiam.employee.audit.context.AuditContext;
import cn.topiam.employee.audit.entity.QAuditEntity;
import cn.topiam.employee.audit.entity.AuditEntity;
import cn.topiam.employee.audit.entity.Target;
import cn.topiam.employee.audit.enums.TargetType;
import cn.topiam.employee.audit.repository.AuditRepository;
import cn.topiam.employee.common.entity.account.*;
import cn.topiam.employee.common.entity.account.QUserEntity;
import cn.topiam.employee.common.entity.account.OrganizationMemberEntity;
import cn.topiam.employee.common.entity.account.UserDetailEntity;
import cn.topiam.employee.common.entity.account.UserEntity;
import cn.topiam.employee.common.entity.account.UserHistoryPasswordEntity;
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;
@ -76,7 +76,6 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import static cn.topiam.employee.audit.enums.TargetType.USER;
import static cn.topiam.employee.audit.enums.TargetType.USER_DETAIL;
import static cn.topiam.employee.audit.service.converter.AuditDataConverter.SORT_EVENT_TIME;
import static cn.topiam.employee.core.message.sms.SmsMsgEventPublish.USERNAME;
import static cn.topiam.employee.support.repository.domain.BaseEntity.LAST_MODIFIED_BY;
import static cn.topiam.employee.support.repository.domain.BaseEntity.LAST_MODIFIED_TIME;
@ -424,7 +423,6 @@ public class UserServiceImpl implements UserService {
if (StringUtils.isEmpty(value)) {
return true;
}
QUserEntity user = QUserEntity.userEntity;
UserEntity entity = new UserEntity();
boolean result = false;
// ID存在说明是修改操作查询一下当前数据
@ -441,10 +439,9 @@ public class UserServiceImpl implements UserService {
}
Phonenumber.PhoneNumber phoneNumber = PhoneNumberUtil.getInstance().parse(value,
"CN");
BooleanExpression eq = user.phone
.eq(String.valueOf(phoneNumber.getNationalNumber()))
.and(user.phoneAreaCode.eq(String.valueOf(phoneNumber.getCountryCode())));
result = !userRepository.exists(eq);
result = !userRepository.exists(Example
.of(new UserEntity().setPhone(String.valueOf(phoneNumber.getNationalNumber()))
.setPhoneAreaCode(String.valueOf(phoneNumber.getCountryCode()))));
} catch (NumberParseException e) {
log.error("校验手机号发生异常", e);
throw new TopIamException("校验手机号发生异常");
@ -455,16 +452,14 @@ public class UserServiceImpl implements UserService {
if (StringUtils.equals(entity.getEmail(), value)) {
return true;
}
BooleanExpression eq = user.email.eq(value);
result = !userRepository.exists(eq);
result = !userRepository.exists(Example.of(new UserEntity().setEmail(value)));
}
//用户名
if (CheckValidityType.USERNAME.equals(type)) {
if (StringUtils.equals(entity.getUsername(), value)) {
return true;
}
BooleanExpression eq = user.username.eq(value);
result = !userRepository.exists(eq);
result = !userRepository.exists(Example.of(new UserEntity().setUsername(value)));
}
return result;
}
@ -479,21 +474,12 @@ public class UserServiceImpl implements UserService {
@Override
public Page<UserLoginAuditListResult> findUserLoginAuditList(Long id, PageModel pageModel) {
//查询入参转查询条件
Predicate predicate = userConverter.auditListRequestConvertToNativeQuery(id);
// 字段排序
OrderSpecifier<LocalDateTime> order = QAuditEntity.auditEntity.eventTime.desc();
for (PageModel.Sort sort : pageModel.getSorts()) {
if (StringUtils.equals(sort.getSorter(), SORT_EVENT_TIME)) {
if (sort.getAsc()) {
order = QAuditEntity.auditEntity.eventTime.asc();
}
}
}
Specification<AuditEntity> specification = userConverter
.auditListRequestConvertToSpecification(id, pageModel);
//分页条件
QPageRequest request = QPageRequest.of(pageModel.getCurrent(), pageModel.getPageSize(),
order);
return userConverter
.entityConvertToAuditListResult(auditRepository.findAll(predicate, request), pageModel);
PageRequest request = PageRequest.of(pageModel.getCurrent(), pageModel.getPageSize());
return userConverter.entityConvertToAuditListResult(
auditRepository.findAll(specification, request), pageModel);
}
/**

View File

@ -20,7 +20,7 @@ package cn.topiam.employee.console.service.app.impl;
import java.util.List;
import java.util.Optional;
import org.springframework.data.querydsl.QPageRequest;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -67,7 +67,7 @@ public class AppAccessPolicyServiceImpl implements AppAccessPolicyService {
public Page<AppAccessPolicyResult> getAppAccessPolicyList(PageModel pageModel,
AppAccessPolicyQuery query) {
//分页条件
QPageRequest request = QPageRequest.of(pageModel.getCurrent(), pageModel.getPageSize());
PageRequest request = PageRequest.of(pageModel.getCurrent(), pageModel.getPageSize());
//查询映射
org.springframework.data.domain.Page<AppAccessPolicyPO> list = appAccessPolicyRepository
.getAppPolicyList(query, request);

View File

@ -21,7 +21,7 @@ import java.nio.charset.StandardCharsets;
import java.util.Optional;
import org.apache.commons.codec.binary.Base64;
import org.springframework.data.querydsl.QPageRequest;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -69,7 +69,7 @@ public class AppAccountServiceImpl implements AppAccountService {
public Page<AppAccountListResult> getAppAccountList(PageModel pageModel,
AppAccountQuery query) {
//分页条件
QPageRequest request = QPageRequest.of(pageModel.getCurrent(), pageModel.getPageSize());
PageRequest request = PageRequest.of(pageModel.getCurrent(), pageModel.getPageSize());
//查询映射
org.springframework.data.domain.Page<AppAccountPO> list = appAccountRepository
.getAppAccountList(query, request);

View File

@ -48,8 +48,8 @@ public class AppCertServiceImpl implements AppCertService {
*/
@Override
public List<AppCertListResult> getAppCertListResult(AppCertQuery query) {
List<AppCertEntity> list = (List<AppCertEntity>) appCertRepository
.findAll(appCertConverter.queryAppCertListParamConvertToPredicate(query));
List<AppCertEntity> list = appCertRepository
.findAll(appCertConverter.queryAppCertListParamConvertToExample(query));
return appCertConverter.entityConvertToAppCertListResult(list);
}

View File

@ -20,6 +20,8 @@ package cn.topiam.employee.console.service.authn.impl;
import java.util.List;
import java.util.Optional;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -40,7 +42,6 @@ import cn.topiam.employee.support.context.ApplicationContextHelp;
import cn.topiam.employee.support.exception.TopIamException;
import cn.topiam.employee.support.repository.page.domain.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel;
import cn.topiam.employee.support.repository.page.domain.QueryDslRequest;
import cn.topiam.employee.support.util.BeanUtils;
import lombok.AllArgsConstructor;
@ -94,10 +95,11 @@ public class IdentityProviderServiceImpl implements IdentityProviderService {
@Override
public Page<IdentityProviderListResult> getIdentityProviderList(PageModel pageModel,
IdentityProviderListQuery query) {
QueryDslRequest request = identityProviderConverter
.queryIdentityProviderListParamConvertToPredicate(query, pageModel);
Specification<IdentityProviderEntity> specification = identityProviderConverter
.queryIdentityProviderListParamConvertToSpecification(query);
PageRequest request = PageRequest.of(pageModel.getCurrent(), pageModel.getPageSize());
org.springframework.data.domain.Page<IdentityProviderEntity> list = identityProviderRepository
.findAll(request.getPredicate(), request.getPageRequest());
.findAll(specification, request);
return identityProviderConverter.entityConverterToIdentityProviderResult(list);
}

View File

@ -17,16 +17,11 @@
*/
package cn.topiam.employee.console.service.identitysource.impl;
import java.time.LocalDateTime;
import org.springframework.data.querydsl.QPageRequest;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import com.querydsl.core.types.OrderSpecifier;
import com.querydsl.core.types.Predicate;
import cn.topiam.employee.common.entity.identitysource.IdentitySourceEventRecordEntity;
import cn.topiam.employee.common.entity.identitysource.QIdentitySourceEventRecordEntity;
import cn.topiam.employee.common.repository.identitysource.IdentitySourceEventRecordRepository;
import cn.topiam.employee.console.converter.identitysource.IdentitySourceEventRecordConverter;
import cn.topiam.employee.console.pojo.query.identity.IdentitySourceEventRecordListQuery;
@ -58,17 +53,13 @@ public class IdentitySourceEventRecordServiceImpl implements IdentitySourceEvent
public Page<IdentitySourceEventRecordListResult> getIdentitySourceEventRecordList(IdentitySourceEventRecordListQuery query,
PageModel pageModel) {
//查询条件
Predicate predicate = identitySourceEventRecordConverter
.queryIdentitySourceEventRecordListQueryConvertToPredicate(query);
Specification<IdentitySourceEventRecordEntity> specification = identitySourceEventRecordConverter
.queryIdentitySourceEventRecordListQueryConvertToSpecification(query);
//分页条件
OrderSpecifier<LocalDateTime> desc = QIdentitySourceEventRecordEntity.identitySourceEventRecordEntity.eventTime
.desc();
//分页条件
QPageRequest request = QPageRequest.of(pageModel.getCurrent(), pageModel.getPageSize(),
desc);
//查询映射
org.springframework.data.domain.Page<IdentitySourceEventRecordEntity> list = identitySourceEventRecordRepository
.findAll(predicate, request);
.findAll(specification,
PageRequest.of(pageModel.getCurrent(), pageModel.getPageSize()));
return identitySourceEventRecordConverter
.entityConvertToIdentitySourceSyncRecordListResult(list);
}

View File

@ -21,6 +21,8 @@ import java.util.List;
import java.util.Optional;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -50,7 +52,6 @@ import cn.topiam.employee.identitysource.wechatwork.WeChatWorkConfig;
import cn.topiam.employee.identitysource.wechatwork.WeChatWorkConfigValidator;
import cn.topiam.employee.support.exception.TopIamException;
import cn.topiam.employee.support.repository.page.domain.PageModel;
import cn.topiam.employee.support.repository.page.domain.QueryDslRequest;
import cn.topiam.employee.support.util.BeanUtils;
import lombok.AllArgsConstructor;
@ -81,10 +82,11 @@ public class IdentitySourceServiceImpl implements IdentitySourceService {
@Override
public cn.topiam.employee.support.repository.page.domain.Page<IdentitySourceListResult> getIdentitySourceList(IdentitySourceListQuery query,
PageModel pageModel) {
QueryDslRequest request = identitySourceConverter
.queryIdentitySourceListParamConvertToPredicate(query, pageModel);
Specification<IdentitySourceEntity> specification = identitySourceConverter
.queryIdentitySourceListParamConvertToPredicate(query);
org.springframework.data.domain.Page<IdentitySourceEntity> list = identitySourceRepository
.findAll(request.getPredicate(), request.getPageRequest());
.findAll(specification,
PageRequest.of(pageModel.getCurrent(), pageModel.getPageSize()));
return identitySourceConverter.entityConverterToIdentitySourceListResult(list);
}

View File

@ -17,22 +17,18 @@
*/
package cn.topiam.employee.console.service.identitysource.impl;
import java.time.LocalDateTime;
import java.util.Objects;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.data.querydsl.QPageRequest;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
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;
import cn.topiam.employee.common.entity.identitysource.IdentitySourceEntity;
import cn.topiam.employee.common.entity.identitysource.IdentitySourceSyncHistoryEntity;
import cn.topiam.employee.common.entity.identitysource.IdentitySourceSyncRecordEntity;
import cn.topiam.employee.common.entity.identitysource.QIdentitySourceSyncHistoryEntity;
import cn.topiam.employee.common.repository.identitysource.IdentitySourceSyncHistoryRepository;
import cn.topiam.employee.common.repository.identitysource.IdentitySourceSyncRecordRepository;
import cn.topiam.employee.console.converter.identitysource.IdentitySourceSyncConverter;
@ -72,16 +68,12 @@ public class IdentitySourceSyncServiceImpl implements IdentitySourceSyncService
public Page<IdentitySourceSyncHistoryListResult> getIdentitySourceSyncHistoryList(IdentitySourceSyncHistoryListQuery query,
PageModel pageModel) {
//查询条件
Predicate predicate = identitySourceSyncConverter
.queryIdentitySourceSyncHistoryListQueryConvertToPredicate(query);
//分页条件
OrderSpecifier<LocalDateTime> desc = QIdentitySourceSyncHistoryEntity.identitySourceSyncHistoryEntity.createTime
.desc();
QPageRequest request = QPageRequest.of(pageModel.getCurrent(), pageModel.getPageSize(),
desc);
Specification<IdentitySourceSyncHistoryEntity> specification = identitySourceSyncConverter
.queryIdentitySourceSyncHistoryListQueryConvertToSpecification(query);
PageRequest request = PageRequest.of(pageModel.getCurrent(), pageModel.getPageSize());
//查询映射
org.springframework.data.domain.Page<IdentitySourceSyncHistoryEntity> list = identitySourceSyncHistoryRepository
.findAll(predicate, request);
.findAll(specification, request);
return identitySourceSyncConverter.entityConvertToIdentitySourceSyncHistoryListResult(list);
}
@ -96,13 +88,13 @@ public class IdentitySourceSyncServiceImpl implements IdentitySourceSyncService
public Page<IdentitySourceSyncRecordListResult> getIdentitySourceSyncRecordList(IdentitySourceSyncRecordListQuery query,
PageModel pageModel) {
//查询条件
Predicate predicate = identitySourceSyncConverter
.queryIdentitySourceSyncRecordListQueryConvertToPredicate(query);
Specification<IdentitySourceSyncRecordEntity> specification = identitySourceSyncConverter
.queryIdentitySourceSyncRecordListQueryConvertToSpecification(query);
//分页条件
QPageRequest request = QPageRequest.of(pageModel.getCurrent(), pageModel.getPageSize());
PageRequest request = PageRequest.of(pageModel.getCurrent(), pageModel.getPageSize());
//查询映射
org.springframework.data.domain.Page<IdentitySourceSyncRecordEntity> list = identitySourceSyncRecordRepository
.findAll(predicate, request);
.findAll(specification, request);
return identitySourceSyncConverter.entityConvertToIdentitySourceSyncRecordListResult(list);
}

View File

@ -27,7 +27,9 @@ import java.util.concurrent.Executor;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.springframework.data.querydsl.QPageRequest;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.http.HttpStatus;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.security.core.session.SessionInformation;
@ -39,14 +41,11 @@ import org.springframework.transaction.annotation.Transactional;
import com.google.i18n.phonenumbers.NumberParseException;
import com.google.i18n.phonenumbers.PhoneNumberUtil;
import com.google.i18n.phonenumbers.Phonenumber;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanExpression;
import cn.topiam.employee.audit.context.AuditContext;
import cn.topiam.employee.audit.entity.Target;
import cn.topiam.employee.audit.enums.TargetType;
import cn.topiam.employee.common.entity.setting.AdministratorEntity;
import cn.topiam.employee.common.entity.setting.QAdministratorEntity;
import cn.topiam.employee.common.enums.CheckValidityType;
import cn.topiam.employee.common.enums.UserStatus;
import cn.topiam.employee.common.repository.setting.AdministratorRepository;
@ -86,12 +85,10 @@ public class AdministratorServiceImpl implements AdministratorService {
@Override
public Page<AdministratorListResult> getAdministratorList(PageModel model,
AdministratorListQuery query) {
Predicate predicate = administratorConverter
.queryAdministratorListParamConvertToPredicate(query);
//分页条件
QPageRequest request = QPageRequest.of(model.getCurrent(), model.getPageSize());
Specification<AdministratorEntity> specification = administratorConverter
.queryAdministratorListParamConvertToSpecification(query);
org.springframework.data.domain.Page<AdministratorEntity> page = administratorRepository
.findAll(predicate, request);
.findAll(specification, PageRequest.of(model.getCurrent(), model.getPageSize()));
return administratorConverter.entityConvertToAdministratorPaginationResult(page);
}
@ -265,7 +262,6 @@ public class AdministratorServiceImpl implements AdministratorService {
*/
@Override
public Boolean administratorParamCheck(CheckValidityType type, String value, Long id) {
QAdministratorEntity administrator = QAdministratorEntity.administratorEntity;
AdministratorEntity entity = new AdministratorEntity();
boolean result = false;
// ID存在说明是修改操作查询一下当前数据
@ -277,8 +273,8 @@ public class AdministratorServiceImpl implements AdministratorService {
if (StringUtils.equals(entity.getEmail(), value)) {
return true;
}
BooleanExpression eq = administrator.email.eq(value);
result = !administratorRepository.exists(eq);
result = !administratorRepository
.exists(Example.of(new AdministratorEntity().setEmail(value)));
}
//手机号
if (CheckValidityType.PHONE.equals(type)) {
@ -290,11 +286,9 @@ public class AdministratorServiceImpl implements AdministratorService {
}
Phonenumber.PhoneNumber phoneNumber = PhoneNumberUtil.getInstance().parse(value,
"CN");
BooleanExpression eq = administrator.phone
.eq(String.valueOf(phoneNumber.getNationalNumber()))
.and(administrator.phoneAreaCode
.eq(String.valueOf(phoneNumber.getCountryCode())));
result = !administratorRepository.exists(eq);
result = !administratorRepository.exists(Example.of(new AdministratorEntity()
.setPhone(String.valueOf(phoneNumber.getNationalNumber()))
.setPhoneAreaCode(String.valueOf(phoneNumber.getCountryCode()))));
} catch (NumberParseException e) {
log.error("校验手机号发生异常", e);
throw new TopIamException("校验手机号发生异常");
@ -305,8 +299,8 @@ public class AdministratorServiceImpl implements AdministratorService {
if (StringUtils.equals(entity.getUsername(), value)) {
return true;
}
BooleanExpression eq = administrator.username.eq(value);
result = !administratorRepository.exists(eq);
result = !administratorRepository
.exists(Example.of(new AdministratorEntity().setUsername(value)));
}
return result;
}

View File

@ -66,7 +66,7 @@ import cn.topiam.employee.identitysource.wechatwork.WeChatWorkConfig;
import cn.topiam.employee.identitysource.wechatwork.WeChatWorkIdentitySource;
import cn.topiam.employee.identitysource.wechatwork.client.WeChatWorkClient;
import cn.topiam.employee.support.context.ApplicationContextHelp;
import cn.topiam.employee.support.scheduler.SpringSchedulerRegister;
import cn.topiam.employee.support.scheduling.SpringSchedulerRegister;
import cn.topiam.employee.support.trace.TraceUtils;
import lombok.extern.slf4j.Slf4j;

View File

@ -41,12 +41,12 @@ import cn.topiam.employee.common.enums.DataOrigin;
import cn.topiam.employee.common.enums.MailType;
import cn.topiam.employee.common.enums.SmsType;
import cn.topiam.employee.common.enums.UserStatus;
import cn.topiam.employee.common.enums.ViewContentType;
import cn.topiam.employee.common.enums.identitysource.IdentitySourceProvider;
import cn.topiam.employee.common.repository.identitysource.IdentitySourceRepository;
import cn.topiam.employee.common.repository.identitysource.IdentitySourceSyncHistoryRepository;
import cn.topiam.employee.common.repository.identitysource.IdentitySourceSyncRecordRepository;
import cn.topiam.employee.common.storage.Storage;
import cn.topiam.employee.common.util.ViewContentType;
import cn.topiam.employee.core.message.MsgVariable;
import cn.topiam.employee.core.message.mail.MailMsgEventPublish;
import cn.topiam.employee.core.message.sms.SmsMsgEventPublish;
@ -60,11 +60,11 @@ import lombok.Cleanup;
import lombok.extern.slf4j.Slf4j;
import jakarta.persistence.EntityManager;
import static cn.topiam.employee.common.constant.CommonConstants.SYSTEM_DEFAULT_USER_NAME;
import static cn.topiam.employee.common.enums.UserStatus.DISABLE;
import static cn.topiam.employee.common.enums.UserStatus.ENABLE;
import static cn.topiam.employee.common.enums.identitysource.IdentitySourceProvider.*;
import static cn.topiam.employee.core.message.sms.SmsMsgEventPublish.USERNAME;
import static cn.topiam.employee.support.constant.EiamConstants.SYSTEM_DEFAULT_USER_NAME;
/**
*
@ -144,7 +144,7 @@ public class AbstractIdentitySourcePostProcessor {
String defaultPassword = null;
if (!Objects.isNull(strategyConfig)) {
enabled = Boolean.TRUE.equals(strategyConfig.getEnabled());
defaultPassword = StringUtils.defaultString(strategyConfig.getDefaultPassword());
defaultPassword = Objects.toString(strategyConfig.getDefaultPassword());
}
if (StringUtils.isBlank(defaultPassword)) {
defaultPassword = passwordGenerator.generatePassword();

View File

@ -69,8 +69,8 @@ import static java.util.stream.Collectors.toList;
import static cn.topiam.employee.common.constant.AccountConstants.ROOT_DEPT_ID;
import static cn.topiam.employee.common.constant.AccountConstants.ROOT_DEPT_NAME;
import static cn.topiam.employee.common.constant.CommonConstants.PATH_SEPARATOR;
import static cn.topiam.employee.common.constant.CommonConstants.SYSTEM_DEFAULT_USER_NAME;
import static cn.topiam.employee.support.constant.EiamConstants.PATH_SEPARATOR;
import static cn.topiam.employee.support.constant.EiamConstants.SYSTEM_DEFAULT_USER_NAME;
/**
* pull post

View File

@ -68,7 +68,7 @@ import lombok.extern.slf4j.Slf4j;
import jakarta.persistence.EntityManager;
import static java.util.stream.Collectors.toSet;
import static cn.topiam.employee.common.constant.CommonConstants.SYSTEM_DEFAULT_USER_NAME;
import static cn.topiam.employee.support.constant.EiamConstants.SYSTEM_DEFAULT_USER_NAME;
/**
* event

View File

@ -65,7 +65,7 @@ import lombok.extern.slf4j.Slf4j;
import jakarta.persistence.EntityManager;
import static java.util.stream.Collectors.toSet;
import static cn.topiam.employee.common.constant.CommonConstants.SYSTEM_DEFAULT_USER_NAME;
import static cn.topiam.employee.support.constant.EiamConstants.SYSTEM_DEFAULT_USER_NAME;
/**
* pull post

View File

@ -148,8 +148,6 @@ public class PortalAuthenticationSuccessHandler extends
session.removeAttribute(SecretType.LOGIN.getKey());
//清理验证码
session.removeAttribute(CAPTCHA_CODE_SESSION);
//清理保存请求
session.removeAttribute(SAVED_REQUEST);
//清理认证异常
session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
}

View File

@ -44,10 +44,10 @@ import cn.topiam.employee.common.entity.setting.SettingEntity;
import cn.topiam.employee.common.repository.setting.SettingRepository;
import cn.topiam.employee.core.setting.constant.SecuritySettingConstants;
import cn.topiam.employee.portal.authentication.AuthenticationTrustResolverImpl;
import cn.topiam.employee.portal.security.handler.PortalAccessDeniedHandler;
import cn.topiam.employee.portal.security.handler.PortalAuthenticationEntryPoint;
import cn.topiam.employee.portal.security.handler.PortalLogoutSuccessHandler;
import cn.topiam.employee.portal.security.listener.PortalSessionInformationExpiredStrategy;
import cn.topiam.employee.portal.authentication.PortalAccessDeniedHandler;
import cn.topiam.employee.portal.authentication.PortalAuthenticationEntryPoint;
import cn.topiam.employee.portal.authentication.PortalLogoutSuccessHandler;
import cn.topiam.employee.portal.authentication.PortalSessionInformationExpiredStrategy;
import cn.topiam.employee.support.redis.KeyStringRedisSerializer;
import cn.topiam.employee.support.security.csrf.SpaCsrfTokenRequestHandler;
import static org.springframework.security.web.header.writers.XXssProtectionHeaderWriter.HeaderValue.ENABLED_MODE_BLOCK;

View File

@ -62,8 +62,8 @@ public class FormProtocolSecurityConfiguration extends AbstractSecurityConfigura
//@formatter:off
httpSecurity.getSharedObject(AuthenticationManagerBuilder.class).parentAuthenticationManager(null);
//Form IDP 配置
FormAuthorizationServerConfigurer configurer = new FormAuthorizationServerConfigurer();
RequestMatcher endpointsMatcher = configurer.getEndpointsMatcher();
FormAuthorizationServerConfigurer serverConfigurer = new FormAuthorizationServerConfigurer();
RequestMatcher endpointsMatcher = serverConfigurer.getEndpointsMatcher();
httpSecurity.securityMatcher(endpointsMatcher)
.authorizeHttpRequests(authorizeRequests -> authorizeRequests.anyRequest().authenticated())
//安全上下文
@ -76,7 +76,7 @@ public class FormProtocolSecurityConfiguration extends AbstractSecurityConfigura
.cors(withCorsConfigurerDefaults())
//会话管理器
.sessionManagement(withSessionManagementConfigurerDefaults())
.apply(configurer);
.with(serverConfigurer,configurer-> {});
return httpSecurity.build();
//@formatter:on
}

View File

@ -66,8 +66,8 @@ public class JwtProtocolSecurityConfiguration extends AbstractSecurityConfigurat
//@formatter:off
httpSecurity.getSharedObject(AuthenticationManagerBuilder.class).parentAuthenticationManager(null);
//Jwt IDP 配置
JwtAuthorizationServerConfigurer configurer = new JwtAuthorizationServerConfigurer();
RequestMatcher endpointsMatcher = configurer.getEndpointsMatcher();
JwtAuthorizationServerConfigurer serverConfigurer = new JwtAuthorizationServerConfigurer();
RequestMatcher endpointsMatcher = serverConfigurer.getEndpointsMatcher();
httpSecurity.securityMatcher(endpointsMatcher)
.authorizeHttpRequests(authorizeRequests -> authorizeRequests.anyRequest().authenticated())
//安全上下文
@ -80,7 +80,7 @@ public class JwtProtocolSecurityConfiguration extends AbstractSecurityConfigurat
.cors(withCorsConfigurerDefaults())
//会话管理器
.sessionManagement(withSessionManagementConfigurerDefaults())
.apply(configurer);
.with(serverConfigurer,configurer-> {});
return httpSecurity.build();
//@formatter:on
}

View File

@ -102,7 +102,7 @@ public class OidcProtocolSecurityConfiguration extends AbstractSecurityConfigura
.cors(withCorsConfigurerDefaults())
//会话管理器
.sessionManagement(withSessionManagementConfigurerDefaults())
.apply(authorizationServerConfigurer);
.with(authorizationServerConfigurer,configurer-> {});
return httpSecurity.build();
//@formatter:on
}

View File

@ -38,7 +38,6 @@ import org.springframework.security.config.annotation.web.configurers.FormLoginC
import org.springframework.security.config.annotation.web.configurers.RequestCacheConfigurer;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestRedirectFilter;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
@ -77,15 +76,14 @@ import cn.topiam.employee.core.security.password.task.impl.PasswordExpireLockTas
import cn.topiam.employee.core.security.password.task.impl.PasswordExpireWarnTask;
import cn.topiam.employee.core.security.task.UserExpireLockTask;
import cn.topiam.employee.core.security.task.UserUnlockTask;
import cn.topiam.employee.portal.security.handler.PortalAuthenticationFailureHandler;
import cn.topiam.employee.portal.security.handler.PortalAuthenticationSuccessHandler;
import cn.topiam.employee.portal.security.listener.PortalAuthenticationFailureEventListener;
import cn.topiam.employee.portal.security.listener.PortalAuthenticationSuccessEventListener;
import cn.topiam.employee.portal.security.listener.PortalLogoutSuccessEventListener;
import cn.topiam.employee.portal.authentication.PortalAuthenticationFailureEventListener;
import cn.topiam.employee.portal.authentication.PortalAuthenticationFailureHandler;
import cn.topiam.employee.portal.authentication.PortalAuthenticationSuccessEventListener;
import cn.topiam.employee.portal.authentication.PortalAuthenticationSuccessHandler;
import cn.topiam.employee.portal.authentication.PortalLogoutSuccessEventListener;
import cn.topiam.employee.support.geo.GeoLocationService;
import cn.topiam.employee.support.jackjson.SupportJackson2Module;
import cn.topiam.employee.support.security.authentication.WebAuthenticationDetailsSource;
import cn.topiam.employee.support.security.savedredirect.LoginRedirectParameterFilter;
import static org.springframework.http.HttpMethod.*;
import static org.springframework.security.config.Customizer.withDefaults;
@ -158,7 +156,7 @@ public class PortalSecurityConfiguration extends AbstractSecurityConfiguration
.failureHandler(failureHandler)
.authenticationDetailsSource(authenticationDetailsSource);
requestMatchers.add(qq.getRequestMatcher());
httpSecurity.apply(qq);
httpSecurity.with(qq,configurer-> {});
//微信扫码
WeChatScanCodeAuthenticationConfigurer chatScanCode = weChatScanCode(identityProviderRepository, userIdpService)
@ -166,7 +164,7 @@ public class PortalSecurityConfiguration extends AbstractSecurityConfiguration
.failureHandler(failureHandler)
.authenticationDetailsSource(authenticationDetailsSource);
requestMatchers.add(chatScanCode.getRequestMatcher());
httpSecurity.apply(chatScanCode);
httpSecurity.with(chatScanCode,configurer-> {});
//GITHUB
GithubOauthAuthenticationConfigurer github = github(identityProviderRepository, userIdpService)
@ -174,7 +172,7 @@ public class PortalSecurityConfiguration extends AbstractSecurityConfiguration
.failureHandler(failureHandler)
.authenticationDetailsSource(authenticationDetailsSource);
requestMatchers.add(github.getRequestMatcher());
httpSecurity.apply(github);
httpSecurity.with(github,configurer-> {});
//企业微信
WeChatWorkScanCodeAuthenticationConfigurer weChatWorkScanCode = weChatWorkScanCode(identityProviderRepository, userIdpService)
@ -182,7 +180,7 @@ public class PortalSecurityConfiguration extends AbstractSecurityConfiguration
.failureHandler(failureHandler)
.authenticationDetailsSource(authenticationDetailsSource);
requestMatchers.add(weChatWorkScanCode.getRequestMatcher());
httpSecurity.apply(weChatWorkScanCode);
httpSecurity.with(weChatWorkScanCode,configurer-> {});
//钉钉OAuth2
DingtalkOAuth2AuthenticationConfigurer dingtalkOauth2 = dingtalkOAuth2(identityProviderRepository, userIdpService)
@ -190,7 +188,7 @@ public class PortalSecurityConfiguration extends AbstractSecurityConfiguration
.failureHandler(failureHandler)
.authenticationDetailsSource(authenticationDetailsSource);
requestMatchers.add(dingtalkOauth2.getRequestMatcher());
httpSecurity.apply(dingtalkOauth2);
httpSecurity.with(dingtalkOauth2,configurer-> {});
//钉钉扫码
DingtalkScanCodeAuthenticationConfigurer dingtalkScanCode = dingtalkScanCode(identityProviderRepository, userIdpService)
@ -198,7 +196,7 @@ public class PortalSecurityConfiguration extends AbstractSecurityConfiguration
.failureHandler(failureHandler)
.authenticationDetailsSource(authenticationDetailsSource);
requestMatchers.add(dingtalkScanCode.getRequestMatcher());
httpSecurity.apply(dingtalkScanCode);
httpSecurity.with(dingtalkScanCode,configurer-> {});
//飞书扫码
FeiShuScanCodeAuthenticationConfigurer feiShuScanCode = feiShuScanCode(identityProviderRepository, userIdpService)
@ -206,7 +204,7 @@ public class PortalSecurityConfiguration extends AbstractSecurityConfiguration
.failureHandler(failureHandler)
.authenticationDetailsSource(authenticationDetailsSource);
requestMatchers.add(feiShuScanCode.getRequestMatcher());
httpSecurity.apply(feiShuScanCode);
httpSecurity.with(feiShuScanCode,configurer-> {});
//Gitee
@ -215,7 +213,7 @@ public class PortalSecurityConfiguration extends AbstractSecurityConfiguration
.failureHandler(failureHandler)
.authenticationDetailsSource(authenticationDetailsSource);
requestMatchers.add(giteeCode.getRequestMatcher());
httpSecurity.apply(giteeCode);
httpSecurity.with(giteeCode,configurer-> {});
//支付宝
AlipayAuthenticationConfigurer alipayOauth = alipayOauth(identityProviderRepository, userIdpService)
@ -223,7 +221,7 @@ public class PortalSecurityConfiguration extends AbstractSecurityConfiguration
.failureHandler(failureHandler)
.authenticationDetailsSource(authenticationDetailsSource);
requestMatchers.add(alipayOauth.getRequestMatcher());
httpSecurity.apply(alipayOauth);
httpSecurity.with(alipayOauth,configurer-> {});
//RequestMatcher
OrRequestMatcher requestMatcher = new OrRequestMatcher(requestMatchers);
@ -243,7 +241,6 @@ public class PortalSecurityConfiguration extends AbstractSecurityConfiguration
.cors(withCorsConfigurerDefaults())
//会话管理器
.sessionManagement(withSessionManagementConfigurerDefaults());
httpSecurity.addFilterBefore(new LoginRedirectParameterFilter(new IdpRedirectParameterMatcher()), OAuth2AuthorizationRequestRedirectFilter.class);
return httpSecurity.build();
// @formatter:on
}
@ -297,26 +294,19 @@ public class PortalSecurityConfiguration extends AbstractSecurityConfiguration
.successHandler(successHandler)
.failureHandler(failureHandler)
.authenticationDetailsSource(authenticationDetailsSource);
httpSecurity.apply(mailOtpAuthenticationConfigurer);
httpSecurity.with(mailOtpAuthenticationConfigurer,configurer-> {});
//短信验证码登录认证
SmsOtpAuthenticationConfigurer smsAuthenticationConfigurer = smsOtp(userRepository, userDetailsService, otpContextHelp)
.successHandler(successHandler)
.failureHandler(failureHandler)
.authenticationDetailsSource(authenticationDetailsSource);
httpSecurity.apply(smsAuthenticationConfigurer);
httpSecurity.with(smsAuthenticationConfigurer,configurer-> {});
//IDP 绑定用户
IdpBindAuthenticationConfigurer idpBindAuthenticationConfigurer = idpBind(userIdpService, passwordEncoder)
.successHandler(successHandler)
.failureHandler(failureHandler)
.authenticationDetailsSource(authenticationDetailsSource);
httpSecurity.apply(idpBindAuthenticationConfigurer);
//Form 、短信/邮件验证码 授权请求重定向参数过滤器
httpSecurity.addFilterBefore(new LoginRedirectParameterFilter(
new OrRequestMatcher(new AntPathRequestMatcher(FORM_LOGIN),
mailOtpAuthenticationConfigurer.getRequestMatcher(),
smsAuthenticationConfigurer.getRequestMatcher())),
OAuth2AuthorizationRequestRedirectFilter.class);
httpSecurity.with(idpBindAuthenticationConfigurer,configurer-> {});
// @formatter:on
return httpSecurity.build();
}

View File

@ -17,8 +17,8 @@
*/
package cn.topiam.employee.portal.constant;
import static cn.topiam.employee.common.constant.AppConstants.APP_CODE_VARIABLE;
import static cn.topiam.employee.common.constant.AuthorizeConstants.AUTHORIZE_PATH;
import static cn.topiam.employee.common.constant.ProtocolConstants.APP_CODE_VARIABLE;
import static cn.topiam.employee.support.constant.EiamConstants.V1_API_PATH;
/**

View File

@ -18,6 +18,7 @@
package cn.topiam.employee.portal.controller;
import java.io.Serializable;
import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
@ -35,7 +36,8 @@ import lombok.extern.slf4j.Slf4j;
import io.swagger.v3.oas.annotations.media.Schema;
import static cn.topiam.employee.common.constant.SessionConstants.CURRENT_USER;
import static cn.topiam.employee.common.util.ImageAvatarUtils.*;
import static cn.topiam.employee.support.util.ImageAvatarUtils.bufferedImageToBase64;
import static cn.topiam.employee.support.util.ImageAvatarUtils.generateAvatarImg;
/**
*
@ -63,8 +65,8 @@ public class CurrentUserEndpoint {
result.setNickName(user.getNickName());
//头像
if (StringUtils.isEmpty(user.getAvatar())) {
result.setAvatar(bufferedImageToBase64(generateAvatarImg(
StringUtils.defaultString(user.getFullName(), user.getUsername()))));
result.setAvatar(bufferedImageToBase64(
generateAvatarImg(Objects.toString(user.getFullName(), user.getUsername()))));
} else {
result.setAvatar(user.getAvatar());
}

View File

@ -34,7 +34,7 @@ import cn.topiam.employee.portal.constant.PortalConstants;
import cn.topiam.employee.portal.pojo.result.GetAppListResult;
import cn.topiam.employee.support.context.ApplicationContextHelp;
import cn.topiam.employee.support.repository.page.domain.Page;
import static cn.topiam.employee.common.constant.ProtocolConstants.APP_CODE_VARIABLE;
import static cn.topiam.employee.common.constant.AppConstants.APP_CODE_VARIABLE;
import static cn.topiam.employee.common.enums.app.InitLoginType.PORTAL_OR_APP;
/**
@ -53,7 +53,6 @@ public interface AppConverter {
*/
default Page<GetAppListResult> entityConvertToAppListResult(org.springframework.data.domain.Page<AppEntity> list) {
//@formatter:off
Page<GetAppListResult> page = new Page<>();
List<GetAppListResult> results = new ArrayList<>();
for (AppEntity entity : list) {
GetAppListResult result = new GetAppListResult();
@ -85,6 +84,7 @@ public interface AppConverter {
}
results.add(result);
}
Page<GetAppListResult> page = new Page<>();
page.setList(results);
page.setPagination(Page.Pagination.builder()
.total(list.getTotalElements())