77 lines
5.0 KiB
Java
77 lines
5.0 KiB
Java
package com.baiyue.auth.dto;
|
|
|
|
import jakarta.validation.constraints.NotBlank;
|
|
import jakarta.validation.constraints.NotNull;
|
|
import jakarta.validation.constraints.NotEmpty;
|
|
import jakarta.validation.constraints.Size;
|
|
import jakarta.validation.constraints.Pattern;
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.util.Set;
|
|
|
|
/** 账号安全及内部账号管理契约。 */
|
|
public final class AccountManagementDtos {
|
|
private AccountManagementDtos() { }
|
|
|
|
public record ChangePasswordRequest(@NotBlank String oldPassword,
|
|
@NotBlank @Size(min = 8, max = 64)
|
|
@Pattern(regexp = "^(?=.*[A-Za-z])(?=.*\\d).+$", message = "密码必须同时包含字母和数字") String newPassword) { }
|
|
public record ForcedPasswordChangeRequest(
|
|
@NotBlank @Size(min = 8, max = 64)
|
|
@Pattern(regexp = "^(?=.*[A-Za-z])(?=.*\\d).+$", message = "密码必须同时包含字母和数字")
|
|
String newPassword) { }
|
|
public record CreateAccountRequest(@NotNull Long accountId,
|
|
@NotBlank @Pattern(regexp = "^[A-Za-z][A-Za-z0-9_.@-]{3,63}$") String username,
|
|
@Pattern(regexp = "^1[3-9]\\d{9}$") String phone,
|
|
@NotBlank @Size(min = 8, max = 64)
|
|
@Pattern(regexp = "^(?=.*[A-Za-z])(?=.*\\d).+$", message = "密码必须同时包含字母和数字") String password,
|
|
@NotBlank String displayName, @NotNull Long tenantId,
|
|
@NotNull Long membershipId,
|
|
@Pattern(regexp = "MERCHANT|PLATFORM", message = "应用端只能是 MERCHANT 或 PLATFORM")
|
|
String appCode,
|
|
@Pattern(regexp = "ACTIVE|DISABLED", message = "账号状态只能是 ACTIVE 或 DISABLED")
|
|
String accountStatus) {
|
|
public CreateAccountRequest(Long accountId, String username, String password, String displayName,
|
|
Long tenantId, Long membershipId, String appCode) {
|
|
this(accountId, username, null, password, displayName, tenantId, membershipId, appCode, "ACTIVE");
|
|
}
|
|
public CreateAccountRequest(Long accountId, String username, String password, String displayName,
|
|
Long tenantId, Long membershipId, String appCode, String accountStatus) {
|
|
this(accountId, username, null, password, displayName, tenantId, membershipId, appCode, accountStatus);
|
|
}
|
|
}
|
|
public record ChangeLoginIdentifiersRequest(
|
|
@NotBlank @Pattern(regexp = "^[A-Za-z][A-Za-z0-9_.@-]{3,63}$") String username,
|
|
@NotBlank @Pattern(regexp = "^1[3-9]\\d{9}$") String phone,
|
|
@NotBlank String currentPassword) { }
|
|
public record UpdateAccountPhoneRequest(
|
|
@Pattern(regexp = "^1[3-9]\\d{9}$") String phone) { }
|
|
public record UpdateAccountProfileRequest(@NotBlank @Size(max = 64) String displayName) { }
|
|
public record UpdateAccountStatusRequest(@NotBlank String status) { }
|
|
public record RevokeAccountSessionsRequest(
|
|
@NotEmpty @Size(max = 500) Set<@NotNull Long> accountIds) {
|
|
public RevokeAccountSessionsRequest {
|
|
accountIds = Set.copyOf(accountIds);
|
|
}
|
|
}
|
|
public record ResetPasswordRequest(@NotBlank @Size(min = 8, max = 64)
|
|
@Pattern(regexp = "^(?=.*[A-Za-z])(?=.*\\d).+$", message = "密码必须同时包含字母和数字") String newPassword,
|
|
Boolean forceChangePassword) {
|
|
public boolean forceChange() { return Boolean.TRUE.equals(forceChangePassword); }
|
|
}
|
|
public record ResetPasswordOptions(boolean forceChangePassword) { }
|
|
public record ImpersonationTicketRequest(@NotNull Long targetAuthUserId, @NotNull Long tenantId,
|
|
@NotNull Long membershipId, @NotNull Long actorUserId,
|
|
@NotNull Long actorMembershipId, @NotBlank String reason) { }
|
|
public record ImpersonationTicketResponse(String code, String ticketId, long expiresIn) { }
|
|
public record ImpersonationExchangeRequest(@NotBlank String code) { }
|
|
public record UpdateAccountScopeRequest(@NotNull Long tenantId, @NotNull Long membershipId,
|
|
@NotBlank @Pattern(regexp = "MERCHANT|PLATFORM") String appCode) { }
|
|
public record AccountSummary(Long accountId, String username, String phone, String displayName, String status,
|
|
LocalDateTime lastLoginAt, Long tenantId, Long membershipId, String appCode) {
|
|
public AccountSummary(Long accountId, String username, String displayName, String status) {
|
|
this(accountId, username, null, displayName, status, null, null, null, null);
|
|
}
|
|
}
|
|
}
|