2025-05-07 18:25:31 +08:00

28 lines
538 B
Go

package domain
import (
"admin/apps/game/domain/entity"
"admin/apps/game/domain/repo"
"gorm.io/gorm"
)
type CDKeyService struct {
repo repo.ICDKeyRepo
}
func NewCDKeyService(db *gorm.DB) *CDKeyService {
return &CDKeyService{repo: repo.NewCDKeyRepo(db)}
}
func (svc *CDKeyService) AddCount(id int, delta int) (int, error) {
et, err := svc.repo.AddCount(id, delta)
if err != nil {
return 0, err
}
return et.GetCount(), nil
}
func (svc *CDKeyService) Get(id int) (*entity.CDKey, bool, error) {
return svc.repo.GetByID(id)
}