add qygl23t7
This commit is contained in:
@@ -36,14 +36,14 @@ type UserAggregateService interface {
|
||||
GetUserStats(ctx context.Context) (*repositories.UserStats, error)
|
||||
|
||||
// 企业信息管理
|
||||
CreateEnterpriseInfo(ctx context.Context, userID, companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone, enterpriseAddress, enterpriseEmail string) error
|
||||
UpdateEnterpriseInfo(ctx context.Context, userID, companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone, enterpriseAddress, enterpriseEmail string) error
|
||||
CreateEnterpriseInfo(ctx context.Context, userID, companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone, enterpriseAddress string) error
|
||||
UpdateEnterpriseInfo(ctx context.Context, userID, companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone, enterpriseAddress string) error
|
||||
GetUserWithEnterpriseInfo(ctx context.Context, userID string) (*entities.User, error)
|
||||
ValidateEnterpriseInfo(ctx context.Context, userID string) error
|
||||
CheckUnifiedSocialCodeExists(ctx context.Context, unifiedSocialCode string, excludeUserID string) (bool, error)
|
||||
|
||||
// 认证域专用:写入/覆盖企业信息
|
||||
CreateOrUpdateEnterpriseInfo(ctx context.Context, userID, companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone, enterpriseAddress, enterpriseEmail string) error
|
||||
CreateOrUpdateEnterpriseInfo(ctx context.Context, userID, companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone, enterpriseAddress string) error
|
||||
CompleteCertification(ctx context.Context, userID string) error
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ func (s *UserAggregateServiceImpl) LoadUser(ctx context.Context, userID string)
|
||||
|
||||
// 验证业务规则
|
||||
if err := s.ValidateBusinessRules(ctx, &user); err != nil {
|
||||
s.logger.Warn("用户业务规则验证失败",
|
||||
s.logger.Warn("用户业务规则验证失败",
|
||||
zap.String("user_id", userID),
|
||||
zap.Error(err),
|
||||
)
|
||||
@@ -186,7 +186,7 @@ func (s *UserAggregateServiceImpl) LoadUserByPhone(ctx context.Context, phone st
|
||||
|
||||
// 验证业务规则
|
||||
if err := s.ValidateBusinessRules(ctx, user); err != nil {
|
||||
s.logger.Warn("用户业务规则验证失败",
|
||||
s.logger.Warn("用户业务规则验证失败",
|
||||
zap.String("phone", phone),
|
||||
zap.Error(err),
|
||||
)
|
||||
@@ -303,7 +303,7 @@ func (s *UserAggregateServiceImpl) UpdateLoginStats(ctx context.Context, userID
|
||||
// ================ 企业信息管理 ================
|
||||
|
||||
// CreateEnterpriseInfo 创建企业信息
|
||||
func (s *UserAggregateServiceImpl) CreateEnterpriseInfo(ctx context.Context, userID, companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone, enterpriseAddress, enterpriseEmail string) error {
|
||||
func (s *UserAggregateServiceImpl) CreateEnterpriseInfo(ctx context.Context, userID, companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone, enterpriseAddress string) error {
|
||||
s.logger.Debug("创建企业信息", zap.String("user_id", userID))
|
||||
|
||||
// 1. 加载用户聚合根
|
||||
@@ -327,7 +327,7 @@ func (s *UserAggregateServiceImpl) CreateEnterpriseInfo(ctx context.Context, use
|
||||
}
|
||||
|
||||
// 4. 使用聚合根方法创建企业信息
|
||||
err = user.CreateEnterpriseInfo(companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone, enterpriseAddress, enterpriseEmail)
|
||||
err = user.CreateEnterpriseInfo(companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone, enterpriseAddress)
|
||||
if err != nil {
|
||||
return fmt.Errorf("创建企业信息失败: %w", err)
|
||||
}
|
||||
@@ -349,7 +349,7 @@ func (s *UserAggregateServiceImpl) CreateEnterpriseInfo(ctx context.Context, use
|
||||
}
|
||||
|
||||
// UpdateEnterpriseInfo 更新企业信息
|
||||
func (s *UserAggregateServiceImpl) UpdateEnterpriseInfo(ctx context.Context, userID, companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone, enterpriseAddress, enterpriseEmail string) error {
|
||||
func (s *UserAggregateServiceImpl) UpdateEnterpriseInfo(ctx context.Context, userID, companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone, enterpriseAddress string) error {
|
||||
s.logger.Debug("更新企业信息", zap.String("user_id", userID))
|
||||
|
||||
// 1. 加载用户聚合根
|
||||
@@ -373,7 +373,7 @@ func (s *UserAggregateServiceImpl) UpdateEnterpriseInfo(ctx context.Context, use
|
||||
}
|
||||
|
||||
// 4. 使用聚合根方法更新企业信息
|
||||
err = user.UpdateEnterpriseInfo(companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone, enterpriseAddress, enterpriseEmail)
|
||||
err = user.UpdateEnterpriseInfo(companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone, enterpriseAddress)
|
||||
if err != nil {
|
||||
return fmt.Errorf("更新企业信息失败: %w", err)
|
||||
}
|
||||
@@ -394,7 +394,6 @@ func (s *UserAggregateServiceImpl) UpdateEnterpriseInfo(ctx context.Context, use
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
// GetUserWithEnterpriseInfo 获取用户信息(包含企业信息)
|
||||
func (s *UserAggregateServiceImpl) GetUserWithEnterpriseInfo(ctx context.Context, userID string) (*entities.User, error) {
|
||||
s.logger.Debug("获取用户信息(包含企业信息)", zap.String("user_id", userID))
|
||||
@@ -407,7 +406,7 @@ func (s *UserAggregateServiceImpl) GetUserWithEnterpriseInfo(ctx context.Context
|
||||
|
||||
// 验证业务规则
|
||||
if err := s.ValidateBusinessRules(ctx, &user); err != nil {
|
||||
s.logger.Warn("用户业务规则验证失败",
|
||||
s.logger.Warn("用户业务规则验证失败",
|
||||
zap.String("user_id", userID),
|
||||
zap.Error(err),
|
||||
)
|
||||
@@ -437,7 +436,7 @@ func (s *UserAggregateServiceImpl) ValidateEnterpriseInfo(ctx context.Context, u
|
||||
|
||||
// CheckUnifiedSocialCodeExists 检查统一社会信用代码是否存在
|
||||
func (s *UserAggregateServiceImpl) CheckUnifiedSocialCodeExists(ctx context.Context, unifiedSocialCode string, excludeUserID string) (bool, error) {
|
||||
s.logger.Debug("检查统一社会信用代码是否存在",
|
||||
s.logger.Debug("检查统一社会信用代码是否存在",
|
||||
zap.String("unified_social_code", unifiedSocialCode),
|
||||
zap.String("exclude_user_id", excludeUserID),
|
||||
)
|
||||
@@ -455,12 +454,12 @@ func (s *UserAggregateServiceImpl) CheckUnifiedSocialCodeExists(ctx context.Cont
|
||||
}
|
||||
|
||||
if exists {
|
||||
s.logger.Info("统一社会信用代码已存在",
|
||||
s.logger.Info("统一社会信用代码已存在",
|
||||
zap.String("unified_social_code", unifiedSocialCode),
|
||||
zap.String("exclude_user_id", excludeUserID),
|
||||
)
|
||||
} else {
|
||||
s.logger.Debug("统一社会信用代码不存在",
|
||||
s.logger.Debug("统一社会信用代码不存在",
|
||||
zap.String("unified_social_code", unifiedSocialCode),
|
||||
)
|
||||
}
|
||||
@@ -471,20 +470,20 @@ func (s *UserAggregateServiceImpl) CheckUnifiedSocialCodeExists(ctx context.Cont
|
||||
// CreateOrUpdateEnterpriseInfo 认证域专用:写入/覆盖企业信息
|
||||
func (s *UserAggregateServiceImpl) CreateOrUpdateEnterpriseInfo(
|
||||
ctx context.Context,
|
||||
userID, companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone, enterpriseAddress, enterpriseEmail string,
|
||||
userID, companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone, enterpriseAddress string,
|
||||
) error {
|
||||
user, err := s.LoadUser(ctx, userID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("用户不存在: %w", err)
|
||||
}
|
||||
if user.EnterpriseInfo == nil {
|
||||
enterpriseInfo, err := entities.NewEnterpriseInfo(userID, companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone, enterpriseAddress, enterpriseEmail)
|
||||
enterpriseInfo, err := entities.NewEnterpriseInfo(userID, companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone, enterpriseAddress)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
user.EnterpriseInfo = enterpriseInfo
|
||||
} else {
|
||||
err := user.EnterpriseInfo.UpdateEnterpriseInfo(companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone, enterpriseAddress, enterpriseEmail)
|
||||
err := user.EnterpriseInfo.UpdateEnterpriseInfo(companyName, unifiedSocialCode, legalPersonName, legalPersonID, legalPersonPhone, enterpriseAddress)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -504,7 +503,7 @@ func (s *UserAggregateServiceImpl) CompleteCertification(ctx context.Context, us
|
||||
|
||||
// ListUsers 获取用户列表
|
||||
func (s *UserAggregateServiceImpl) ListUsers(ctx context.Context, query *queries.ListUsersQuery) ([]*entities.User, int64, error) {
|
||||
s.logger.Debug("获取用户列表",
|
||||
s.logger.Debug("获取用户列表",
|
||||
zap.Int("page", query.Page),
|
||||
zap.Int("page_size", query.PageSize),
|
||||
)
|
||||
@@ -516,7 +515,7 @@ func (s *UserAggregateServiceImpl) ListUsers(ctx context.Context, query *queries
|
||||
return nil, 0, fmt.Errorf("查询用户列表失败: %w", err)
|
||||
}
|
||||
|
||||
s.logger.Info("用户列表查询成功",
|
||||
s.logger.Info("用户列表查询成功",
|
||||
zap.Int("count", len(users)),
|
||||
zap.Int64("total", total),
|
||||
)
|
||||
@@ -535,7 +534,7 @@ func (s *UserAggregateServiceImpl) GetUserStats(ctx context.Context) (*repositor
|
||||
return nil, fmt.Errorf("查询用户统计信息失败: %w", err)
|
||||
}
|
||||
|
||||
s.logger.Info("用户统计信息查询成功",
|
||||
s.logger.Info("用户统计信息查询成功",
|
||||
zap.Int64("total_users", stats.TotalUsers),
|
||||
zap.Int64("active_users", stats.ActiveUsers),
|
||||
zap.Int64("certified_users", stats.CertifiedUsers),
|
||||
@@ -556,7 +555,7 @@ func (s *UserAggregateServiceImpl) publishDomainEvents(ctx context.Context, user
|
||||
for _, event := range events {
|
||||
// 这里需要将领域事件转换为标准事件格式
|
||||
// 暂时跳过,后续可以完善事件转换逻辑
|
||||
s.logger.Debug("发布领域事件",
|
||||
s.logger.Debug("发布领域事件",
|
||||
zap.String("user_id", user.ID),
|
||||
zap.Any("event", event),
|
||||
)
|
||||
@@ -566,4 +565,4 @@ func (s *UserAggregateServiceImpl) publishDomainEvents(ctx context.Context, user
|
||||
user.ClearDomainEvents()
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user