44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
package user
|
|
|
|
import (
|
|
"Yimaru-Backend/internal/domain"
|
|
"context"
|
|
)
|
|
|
|
func (s *Service) SearchUserByNameOrPhone(ctx context.Context, searchString string, role *int64, companyID *string) ([]domain.User, error) {
|
|
// Search user
|
|
return s.userStore.SearchUserByNameOrPhone(ctx, searchString, role, companyID)
|
|
|
|
}
|
|
func (s *Service) UpdateUser(ctx context.Context, user domain.UpdateUserReq) error {
|
|
// update user
|
|
|
|
newUser := domain.User{
|
|
ID: user.UserID,
|
|
FirstName: user.FirstName.Value,
|
|
LastName: user.LastName.Value,
|
|
NickName: user.NickName.Value,
|
|
Age: user.Age.Value,
|
|
EducationLevel: user.EducationLevel.Value,
|
|
Country: user.Country.Value,
|
|
Region: user.Region.Value,
|
|
Suspended: user.Suspended.Value,
|
|
OrganizationID: user.OrganizationID,
|
|
}
|
|
return s.userStore.UpdateUser(ctx, newUser)
|
|
|
|
}
|
|
|
|
// func (s *Service) UpdateUserCompany(ctx context.Context, id int64, companyID int64) error {
|
|
// // update user
|
|
// return s.userStore.UpdateUserCompany(ctx, id, companyID)
|
|
// }
|
|
|
|
func (s *Service) UpdateUserSuspend(ctx context.Context, id int64, status bool) error {
|
|
// update user
|
|
return s.userStore.UpdateUserSuspend(ctx, id, status)
|
|
}
|
|
func (s *Service) GetUserByID(ctx context.Context, id int64) (domain.User, error) {
|
|
return s.userStore.GetUserByID(ctx, id)
|
|
}
|