Reorganize project structure: - backend/cmd/openteam/ — entry point - backend/internal/ — core packages - backend/middleware/ — HTTP middleware - backend/router/ — route setup - backend/wire/ — dependency injection - backend/pkg/ — shared utilities - backend/go.mod, go.sum — Go module files Updated Makefile to work from backend/ directory. Removed old lowercase makefile.
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
"opencatd-open/internal/dao"
|
|
"opencatd-open/internal/store"
|
|
"opencatd-open/pkg/config"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type UserServiceImpl struct {
|
|
cfg *config.Config
|
|
db *gorm.DB
|
|
userRepo *dao.UserDAO
|
|
}
|
|
|
|
func NewUserService(cfg *config.Config, db *gorm.DB, userRepo *dao.UserDAO) *UserServiceImpl {
|
|
return &UserServiceImpl{
|
|
cfg: cfg,
|
|
db: db,
|
|
userRepo: userRepo,
|
|
}
|
|
}
|
|
|
|
func (s *UserServiceImpl) GetByID(ctx context.Context, id uint64) (*store.User, error) {
|
|
return s.userRepo.GetByID(id)
|
|
}
|
|
|
|
func (s *UserServiceImpl) GetByUsername(ctx context.Context, username string) (*store.User, error) {
|
|
return s.userRepo.GetByUsername(username)
|
|
}
|
|
|
|
func (s *UserServiceImpl) List(ctx context.Context, limit, offset int) ([]*store.User, int64, error) {
|
|
return s.userRepo.List(limit, offset)
|
|
}
|
|
|
|
func (s *UserServiceImpl) Create(ctx context.Context, user *store.User) error {
|
|
return s.userRepo.Create(user)
|
|
}
|
|
|
|
func (s *UserServiceImpl) Update(ctx context.Context, user *store.User) error {
|
|
return s.userRepo.Update(user)
|
|
}
|
|
|
|
func (s *UserServiceImpl) Delete(ctx context.Context, id uint64) error {
|
|
return s.userRepo.Delete(id)
|
|
}
|