feat: 接入商务用户资料和全局统计偏好
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package business
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kra/internal/biz/business"
|
||||
"kra/internal/service/dto"
|
||||
)
|
||||
|
||||
type PreferenceUsecase interface {
|
||||
Current(context.Context) (*business.UserPreference, error)
|
||||
UpdateCurrent(context.Context, business.UserPreference) error
|
||||
}
|
||||
|
||||
type UserPreferenceService struct{ uc PreferenceUsecase }
|
||||
|
||||
func NewUserPreferenceService(uc *business.UserPreferenceUsecase) *UserPreferenceService {
|
||||
return &UserPreferenceService{uc: uc}
|
||||
}
|
||||
|
||||
func (s *UserPreferenceService) Current(ctx context.Context) (*dto.UserPreferenceResponse, error) {
|
||||
pref, err := s.uc.Current(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &dto.UserPreferenceResponse{IncludeSubPromote: pref.IncludeSubPromote, IDCardDedup: pref.IDCardDedup}, nil
|
||||
}
|
||||
|
||||
func (s *UserPreferenceService) UpdateCurrent(ctx context.Context, req *dto.UserPreferenceRequest) error {
|
||||
if req == nil || req.IncludeSubPromote == nil || req.IDCardDedup == nil {
|
||||
return business.ErrPreferenceRequired
|
||||
}
|
||||
return s.uc.UpdateCurrent(ctx, business.UserPreference{IncludeSubPromote: *req.IncludeSubPromote, IDCardDedup: *req.IDCardDedup})
|
||||
}
|
||||
Reference in New Issue
Block a user