curd controller优化

This commit is contained in:
JinMao 2022-12-14 20:27:19 +08:00
parent ed6fd06688
commit c7b92fdc04
2 changed files with 3 additions and 8 deletions

View File

@ -1,9 +1,11 @@
package v1
import (
"Gf-Vben/internal/model"
"github.com/gogf/gf/v2/frame/g"
)
type CurdReq struct {
g.Meta `path:"/curd" method:"post" summary:"Curd请求" tags:"Curd"`
model.CurdReq
}

View File

@ -2,11 +2,9 @@ package controller
import (
"Gf-Vben/api/v1"
"Gf-Vben/internal/model"
"Gf-Vben/internal/service"
"Gf-Vben/util"
"context"
"github.com/gogf/gf/v2/frame/g"
)
var (
@ -17,10 +15,5 @@ type cCurd struct {
}
func (cCurd) Curd(ctx context.Context, req *v1.CurdReq) (res *util.JsonRes, err error) {
r := g.RequestFromCtx(ctx)
in := new(model.CurdReq)
if err := r.Parse(&in); err != nil {
return nil, err
}
return service.Curd().Curd(ctx, in)
return service.Curd().Curd(ctx, &req.CurdReq)
}