feat: customer list

This commit is contained in:
fernanda-one
2024-08-15 11:01:55 +07:00
parent 1a9d04a2d9
commit 21f8d170fa
9 changed files with 234 additions and 1 deletions
+1
View File
@@ -80,6 +80,7 @@ type User interface {
Create(ctx mycontext.Context, userReq *entity.User) (*entity.User, error)
CreateWithTx(ctx mycontext.Context, tx *gorm.DB, userReq *entity.User) (*entity.User, error)
GetAll(ctx mycontext.Context, search entity.UserSearch) ([]*entity.User, int, error)
GetAllCustomer(ctx mycontext.Context, search entity.CustomerSearch) ([]*entity.Customer, int, error)
Update(ctx mycontext.Context, id int64, userReq *entity.User) (*entity.User, error)
UpdateWithTx(ctx mycontext.Context, tx *gorm.DB, req *entity.User) (*entity.User, error)
GetByID(ctx mycontext.Context, id int64) (*entity.User, error)
+11
View File
@@ -86,6 +86,17 @@ func (s *UserService) GetAll(ctx mycontext.Context, search entity.UserSearch) ([
return users.ToUserList(), total, nil
}
func (s *UserService) GetAllCustomer(ctx mycontext.Context, search entity.CustomerSearch) ([]*entity.Customer, int, error) {
users, total, err := s.repo.GetAllCustomer(ctx, search)
if err != nil {
logger.ContextLogger(ctx).Error("error when get all users", zap.Error(err))
return nil, 0, err
}
return users.ToCustomerList(), total, nil
}
func (s *UserService) GetByID(ctx mycontext.Context, id int64) (*entity.User, error) {
userDB, err := s.repo.GetUserByID(ctx, id)
if err != nil {