uniugm/admin/apps/game/domain/irestfull.go

32 lines
804 B
Go
Raw Normal View History

2025-04-18 17:17:23 +08:00
package domain
import (
"admin/apps/game/model/dto"
"admin/internal/errcode"
)
type IRestfulEntity interface {
ToCommonDto() *dto.CommonDtoValues
}
type IRestfulResourceSvc interface {
List(pageNo, pageLen int) ([]*dto.CommonDtoFieldDesc, []IRestfulEntity, error)
Post(obj *dto.CommonDtoValues) (IRestfulEntity, error)
Put(obj *dto.CommonDtoValues) (IRestfulEntity, error)
Delete(id int) error
}
var restfulResourceSvcMgr = make(map[string]IRestfulResourceSvc)
func registerRestfulSvc(name string, svc IRestfulResourceSvc) {
restfulResourceSvcMgr[name] = svc
}
func FindRestfulResourceSvc(name string) (IRestfulResourceSvc, error) {
svc, find := restfulResourceSvcMgr[name]
if !find {
return nil, errcode.New(errcode.ServerError, "not found %v restful svc", name)
}
return svc, nil
}