uniugm/admin/apps/game/server/ctl_common_rest.go
2025-04-18 17:43:08 +08:00

43 lines
1.0 KiB
Go

package server
import (
"admin/apps/game/model/dto"
"admin/internal/context"
)
func (ctl *controller) CommonList(ctx *context.WebContext, restfulResourceName string, params *dto.CommonListReq) {
list, err := ctl.svc.CommonList(ctx, restfulResourceName, params)
if err != nil {
ctx.Fail(err)
return
}
ctx.Ok(list)
}
func (ctl *controller) CommonPost(ctx *context.WebContext, restfulResourceName string, params *dto.CommonDtoValues) {
newObj, err := ctl.svc.CommonPost(ctx, restfulResourceName, *params)
if err != nil {
ctx.Fail(err)
return
}
ctx.Ok(newObj)
}
func (ctl *controller) CommonPut(ctx *context.WebContext, restfulResourceName string, params *dto.CommonDtoValues) {
newObj, err := ctl.svc.CommonPut(ctx, restfulResourceName, *params)
if err != nil {
ctx.Fail(err)
return
}
ctx.Ok(newObj)
}
func (ctl *controller) CommonDelete(ctx *context.WebContext, restfulResourceName string, id int) {
err := ctl.svc.CommonDelete(ctx, restfulResourceName, id)
if err != nil {
ctx.Fail(err)
return
}
ctx.Ok(nil)
}