初始化项目框架,完成部分接口开发
This commit is contained in:
5
internal/controller/category/category.go
Normal file
5
internal/controller/category/category.go
Normal file
@ -0,0 +1,5 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package category
|
||||
15
internal/controller/category/category_new.go
Normal file
15
internal/controller/category/category_new.go
Normal file
@ -0,0 +1,15 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package category
|
||||
|
||||
import (
|
||||
"server/api/category"
|
||||
)
|
||||
|
||||
type ControllerV1 struct{}
|
||||
|
||||
func NewV1() category.ICategoryV1 {
|
||||
return &ControllerV1{}
|
||||
}
|
||||
22
internal/controller/category/category_v1_category_add.go
Normal file
22
internal/controller/category/category_v1_category_add.go
Normal file
@ -0,0 +1,22 @@
|
||||
package category
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/category/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) CategoryAdd(ctx context.Context, req *v1.CategoryAddReq) (res *v1.CategoryAddRes, err error) {
|
||||
out, err := service.Category().Create(ctx, &model.CategoryAddIn{
|
||||
Name: req.Name,
|
||||
Type: req.Type,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.CategoryAddRes{
|
||||
Success: out.Success,
|
||||
}, nil
|
||||
}
|
||||
21
internal/controller/category/category_v1_category_del.go
Normal file
21
internal/controller/category/category_v1_category_del.go
Normal file
@ -0,0 +1,21 @@
|
||||
package category
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/category/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) CategoryDel(ctx context.Context, req *v1.CategoryDelReq) (res *v1.CategoryDelRes, err error) {
|
||||
out, err := service.Category().Delete(ctx, &model.CategoryDelIn{
|
||||
Id: req.Id,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.CategoryDelRes{
|
||||
Success: out.Success,
|
||||
}, nil
|
||||
}
|
||||
23
internal/controller/category/category_v1_category_edit.go
Normal file
23
internal/controller/category/category_v1_category_edit.go
Normal file
@ -0,0 +1,23 @@
|
||||
package category
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/category/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) CategoryEdit(ctx context.Context, req *v1.CategoryEditReq) (res *v1.CategoryEditRes, err error) {
|
||||
out, err := service.Category().Update(ctx, &model.CategoryEditIn{
|
||||
Id: req.Id,
|
||||
Name: req.Name,
|
||||
Type: req.Type,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.CategoryEditRes{
|
||||
Success: out.Success,
|
||||
}, nil
|
||||
}
|
||||
25
internal/controller/category/category_v1_category_list.go
Normal file
25
internal/controller/category/category_v1_category_list.go
Normal file
@ -0,0 +1,25 @@
|
||||
package category
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/category/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) CategoryList(ctx context.Context, req *v1.CategoryListReq) (res *v1.CategoryListRes, err error) {
|
||||
out, err := service.Category().List(ctx, &model.CategoryListIn{
|
||||
Name: req.Name,
|
||||
Page: req.Page,
|
||||
Size: req.Size,
|
||||
Type: req.Type,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.CategoryListRes{
|
||||
List: out.List,
|
||||
Total: out.Total,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user