完善服务端材质渲染(未测试),删除profile表中不必要的isActive字段及相关接口
This commit is contained in:
@@ -77,18 +77,12 @@ func (s *profileService) Create(ctx context.Context, userID int64, name string)
|
||||
UserID: userID,
|
||||
Name: name,
|
||||
RSAPrivateKey: privateKey,
|
||||
IsActive: true,
|
||||
}
|
||||
|
||||
if err := s.profileRepo.Create(ctx, profile); err != nil {
|
||||
return nil, fmt.Errorf("创建档案失败: %w", err)
|
||||
}
|
||||
|
||||
// 设置活跃状态
|
||||
if err := s.profileRepo.SetActive(ctx, profileUUID, userID); err != nil {
|
||||
return nil, fmt.Errorf("设置活跃状态失败: %w", err)
|
||||
}
|
||||
|
||||
// 清除用户的 profile 列表缓存
|
||||
s.cacheInv.OnCreate(ctx, s.cacheKeys.ProfileList(userID))
|
||||
|
||||
@@ -220,34 +214,6 @@ func (s *profileService) Delete(ctx context.Context, uuid string, userID int64)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *profileService) SetActive(ctx context.Context, uuid string, userID int64) error {
|
||||
// 获取档案并验证权限
|
||||
profile, err := s.profileRepo.FindByUUID(ctx, uuid)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return ErrProfileNotFound
|
||||
}
|
||||
return fmt.Errorf("查询档案失败: %w", err)
|
||||
}
|
||||
|
||||
if profile.UserID != userID {
|
||||
return ErrProfileNoPermission
|
||||
}
|
||||
|
||||
if err := s.profileRepo.SetActive(ctx, uuid, userID); err != nil {
|
||||
return fmt.Errorf("设置活跃状态失败: %w", err)
|
||||
}
|
||||
|
||||
if err := s.profileRepo.UpdateLastUsedAt(ctx, uuid); err != nil {
|
||||
return fmt.Errorf("更新使用时间失败: %w", err)
|
||||
}
|
||||
|
||||
// 清除该用户所有 profile 的缓存(因为活跃状态改变了)
|
||||
s.cacheInv.BatchInvalidate(ctx, s.cacheKeys.ProfilePattern(userID))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *profileService) CheckLimit(ctx context.Context, userID int64, maxProfiles int) error {
|
||||
count, err := s.profileRepo.CountByUserID(ctx, userID)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user