2022-09-08 22:00:25 +08:00
|
|
|
package user
|
|
|
|
|
|
|
|
import (
|
2023-07-14 21:47:11 +08:00
|
|
|
"git.0x7f.app/WOJ/woj-server/internal/e"
|
2023-07-15 16:19:49 +08:00
|
|
|
"git.0x7f.app/WOJ/woj-server/internal/misc/log"
|
2023-07-14 21:47:11 +08:00
|
|
|
"git.0x7f.app/WOJ/woj-server/internal/model"
|
2023-07-15 16:19:49 +08:00
|
|
|
"git.0x7f.app/WOJ/woj-server/internal/repo/cache"
|
|
|
|
"git.0x7f.app/WOJ/woj-server/internal/repo/db"
|
|
|
|
"github.com/samber/do"
|
2022-09-08 22:00:25 +08:00
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ Service = (*service)(nil)
|
|
|
|
|
|
|
|
type Service interface {
|
2022-09-20 14:15:21 +08:00
|
|
|
Create(data *CreateData) (*model.User, e.Status)
|
2022-10-22 17:38:39 +08:00
|
|
|
IncrVersion(uid uint) (int64, e.Status)
|
|
|
|
Profile(uid uint) (*model.User, e.Status)
|
2024-01-03 00:54:15 +08:00
|
|
|
ProfileOrCreate(data *CreateData) (*model.User, e.Status)
|
2023-07-15 16:19:49 +08:00
|
|
|
|
|
|
|
HealthCheck() error
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewService(i *do.Injector) (Service, error) {
|
|
|
|
return &service{
|
|
|
|
log: do.MustInvoke[log.Service](i).GetLogger("user"),
|
|
|
|
db: do.MustInvoke[db.Service](i),
|
|
|
|
cache: do.MustInvoke[cache.Service](i),
|
|
|
|
}, nil
|
2022-09-08 22:00:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type service struct {
|
2022-09-17 18:10:06 +08:00
|
|
|
log *zap.Logger
|
2023-07-15 16:19:49 +08:00
|
|
|
db db.Service
|
|
|
|
cache cache.Service
|
2022-09-08 22:00:25 +08:00
|
|
|
}
|
|
|
|
|
2023-07-15 16:19:49 +08:00
|
|
|
func (s *service) HealthCheck() error {
|
|
|
|
return nil
|
2022-09-08 22:00:25 +08:00
|
|
|
}
|