uniugm/admin/apps/game/service/service_cdkey.go
2025-05-16 15:17:10 +08:00

35 lines
925 B
Go

package service
import (
"admin/apps/game/domain/entity"
"admin/internal/errcode"
"admin/internal/model/dto"
)
func (svc *Service) GetCDKeyAllKeys(projectId int, id int) (*entity.CDKey, []string, error) {
et, find, err := svc.cdkeySvc.Get(projectId, id)
if err != nil {
return nil, nil, err
}
if !find {
return nil, nil, errcode.New(errcode.ParamsInvalid, "not found cdkey:%v", id)
}
return et, et.GenerateKeys(), nil
}
func (svc *Service) CDKeyAddCount(projectId int, id int, deltaCount int) (int, error) {
return svc.cdkeySvc.AddCount(projectId, id, deltaCount)
}
func (svc *Service) CDKeyUse(params *dto.CDKeyUseReq) (*entity.CDKey, error) {
batchInfo, err := svc.cdkeySvc.CDKeyUse(params)
if err != nil {
return nil, err
}
return batchInfo, nil
}
func (svc *Service) CDKeyUsedHistoryList(projectId, id int) ([]*dto.CDKeyUsedInfo, error) {
return svc.cdkeySvc.GetUsedHistoryList(projectId, id)
}