package admin

import (
	"context"

	"bindbox-game/internal/pkg/logger"
	"bindbox-game/internal/repository/mysql"
	"bindbox-game/internal/repository/mysql/dao"
	"bindbox-game/internal/repository/mysql/model"
)

type Service interface {
	Login(ctx context.Context, in LoginInput) (LoginResult, error)
	Create(ctx context.Context, in CreateInput) error
	Modify(ctx context.Context, id int, in ModifyInput) error
	Delete(ctx context.Context, ids []int32) error
	List(ctx context.Context, in ListInput) (items []*model.Admin, total int64, err error)
}

type service struct {
	logger  logger.CustomLogger
	readDB  *dao.Query
	writeDB *dao.Query
}

func New(l logger.CustomLogger, db mysql.Repo) Service {
	return &service{
		logger:  l,
		readDB:  dao.Use(db.GetDbR()),
		writeDB: dao.Use(db.GetDbW()),
	}
}
