Browse Source

first

master
chenyang 11 months ago
parent
commit
e1580ceca4
  1. 19
      app/api/category/category.go
  2. 62
      app/api/category/v1/category.go
  3. 15
      app/api/collect/v1/collect.go
  4. 5
      app/controller/category/category.go
  5. 15
      app/controller/category/category_new.go
  6. 14
      app/controller/category/category_v1_batch_delete.go
  7. 14
      app/controller/category/category_v1_create.go
  8. 14
      app/controller/category/category_v1_delete.go
  9. 14
      app/controller/category/category_v1_get_list.go
  10. 14
      app/controller/category/category_v1_update.go
  11. 50
      app/logic/category/category.go
  12. 51
      app/logic/collect/collect.go
  13. 5
      app/logic/logic.go
  14. 44
      app/service/category.go

19
app/api/category/category.go

@ -0,0 +1,19 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package category
import (
"context"
"xgit.pub/module/cms/app/api/category/v1"
)
type ICategoryV1 interface {
GetList(ctx context.Context, req *v1.GetListReq) (res *v1.GetListRes, err error)
Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error)
Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error)
Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error)
BatchDelete(ctx context.Context, req *v1.BatchDeleteReq) (res *v1.BatchDeleteRes, err error)
}

62
app/api/category/v1/category.go

@ -0,0 +1,62 @@
package v1
import (
"github.com/gogf/gf/v2/frame/g"
"xgit.pub/st52/xcore/dto"
)
// GetTreeReq 获取分类树请求参数
type GetTreeReq struct {
g.Meta `path:"/category/tree" method:"post" summary:"获取树" tags:"分类"`
}
// GetTreeRes 获取分类树返回参数
type GetTreeRes struct {
Data interface{} `json:"data"`
}
// GetListReq 获取分类列表
type GetListReq struct {
g.Meta `path:"/category/list" method:"post" summary:"获取列表" tags:"分类"`
Key string `json:"key"`
dto.PageReq
}
// GetListRes 获取分类列表返回参数
type GetListRes struct {
dto.PageRes
}
// CreateReq 创建分类请求参数
type CreateReq struct {
g.Meta `path:"/category/create" method:"post" summary:"创建" tags:"分类"`
}
// CreateRes 创建分类返回参数
type CreateRes struct{}
// UpdateReq 更新分类请求参数
type UpdateReq struct {
g.Meta `path:"/category/update" method:"post" summary:"更新" tags:"分类"`
}
// UpdateRes 更新分类返回参数
type UpdateRes struct{}
// DeleteReq 删除分类请求参数
type DeleteReq struct {
g.Meta `path:"/category/delete" method:"post" summary:"删除" tags:"分类"`
Id uint `json:"id"`
}
// DeleteRes 删除分类返回参数
type DeleteRes struct{}
// BatchDeleteReq 批量删除分类请求参数
type BatchDeleteReq struct {
g.Meta `path:"/category/batch/delete" method:"post" summary:"批量删除" tags:"分类"`
Ids []uint `json:"ids"`
}
// BatchDeleteRes 批量删除分类返回参数
type BatchDeleteRes struct{}

15
app/api/collect/v1/collect.go

@ -63,7 +63,7 @@ type DeleteRes struct{}
// BatchDeleteReq 批量删除请求参数
type BatchDeleteReq struct {
g.Meta `path:"/collect/delete/batch" method:"post" summary:"批量删除" tags:"采集"`
g.Meta `path:"/collect/batch/delete" method:"post" summary:"批量删除" tags:"采集"`
Ids []uint `json:"ids"`
}
@ -77,4 +77,15 @@ type GetReq struct {
}
// GetRes 获取返回参数
type GetRes struct{}
type GetRes struct {
Id uint `json:"id" ` //
Name string `json:"name" ` // 资源名
Url string `json:"url" ` //
Param string `json:"param" ` // 参数
Model uint `json:"model" ` // 类型
Opt uint `json:"opt" ` // 操作方式
Filter int `json:"filter" ` // 过滤模式
FilterForm string `json:"filter_form" ` //
SyncPic uint `json:"sync_pic" ` // 同步图片 全局 2 开启 1 关闭0
Class string `json:"class" ` // 扩展分类 逗号,分隔
}

5
app/controller/category/category.go

@ -0,0 +1,5 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package category

15
app/controller/category/category_new.go

@ -0,0 +1,15 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package category
import (
"xgit.pub/module/cms/app/api/category"
)
type ControllerV1 struct{}
func NewV1() category.ICategoryV1 {
return &ControllerV1{}
}

14
app/controller/category/category_v1_batch_delete.go

@ -0,0 +1,14 @@
package category
import (
"context"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"xgit.pub/module/cms/app/api/category/v1"
)
func (c *ControllerV1) BatchDelete(ctx context.Context, req *v1.BatchDeleteReq) (res *v1.BatchDeleteRes, err error) {
return nil, gerror.NewCode(gcode.CodeNotImplemented)
}

14
app/controller/category/category_v1_create.go

@ -0,0 +1,14 @@
package category
import (
"context"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"xgit.pub/module/cms/app/api/category/v1"
)
func (c *ControllerV1) Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) {
return nil, gerror.NewCode(gcode.CodeNotImplemented)
}

14
app/controller/category/category_v1_delete.go

@ -0,0 +1,14 @@
package category
import (
"context"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"xgit.pub/module/cms/app/api/category/v1"
)
func (c *ControllerV1) Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error) {
return nil, gerror.NewCode(gcode.CodeNotImplemented)
}

14
app/controller/category/category_v1_get_list.go

@ -0,0 +1,14 @@
package category
import (
"context"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"xgit.pub/module/cms/app/api/category/v1"
)
func (c *ControllerV1) GetList(ctx context.Context, req *v1.GetListReq) (res *v1.GetListRes, err error) {
return nil, gerror.NewCode(gcode.CodeNotImplemented)
}

14
app/controller/category/category_v1_update.go

@ -0,0 +1,14 @@
package category
import (
"context"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"xgit.pub/module/cms/app/api/category/v1"
)
func (c *ControllerV1) Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error) {
return nil, gerror.NewCode(gcode.CodeNotImplemented)
}

50
app/logic/category/category.go

@ -0,0 +1,50 @@
package category
import (
"context"
v1 "xgit.pub/module/cms/app/api/category/v1"
"xgit.pub/module/cms/app/service"
)
type sCategory struct {
}
func init() {
Category := New()
service.RegisterCategory(Category)
}
func New() *sCategory {
return &sCategory{}
}
// GetTree 获取树
func (s *sCategory) GetTree(ctx context.Context, req *v1.GetTreeReq) (res *v1.GetTreeRes, err error) {
return
}
// GetList 获取列表
func (s *sCategory) GetList(ctx context.Context, req *v1.GetListReq) (res *v1.GetListRes, err error) {
return
}
// Create 创建
func (s *sCategory) Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) {
return
}
// Update 更新
func (s *sCategory) Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error) {
return
}
// Delete 删除
func (s *sCategory) Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error) {
return
}
// BatchDelete 批量删除
func (s *sCategory) BatchDelete(ctx context.Context, req *v1.BatchDeleteReq) (res *v1.BatchDeleteRes, err error) {
return
}

51
app/logic/collect/collect.go

@ -2,7 +2,12 @@ package collect
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/util/gconv"
v1 "xgit.pub/module/cms/app/api/collect/v1"
"xgit.pub/module/cms/app/dao"
"xgit.pub/module/cms/app/model/entity"
"xgit.pub/module/cms/app/service"
)
@ -20,30 +25,76 @@ func New() *sCollect {
// GetList 获取列表
func (s *sCollect) GetList(ctx context.Context, req *v1.GetListReq) (res *v1.GetListRes, err error) {
res = &v1.GetListRes{}
tx := dao.Collect.Ctx(ctx)
if req.Key != "" {
tx = tx.WhereLike(dao.Collect.Columns().Name, "%"+req.Key+"%")
}
res.Total, err = tx.Count()
if err != nil {
return
}
if req.Order == "" {
tx = tx.OrderDesc(dao.Collect.Columns().Id)
}
var list []*entity.Collect
err = tx.Page(req.Page, req.PageSize).Scan(&list)
return
}
// Get 获取详情
func (s *sCollect) Get(ctx context.Context, req *v1.GetReq) (res *v1.GetRes, err error) {
if req.Id < 1 {
err = gerror.New("id is empty")
return
}
err = dao.Collect.Ctx(ctx).Where(dao.Collect.Columns().Id, req.Id).Scan(&res)
return
}
// Create 创建
func (s *sCollect) Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) {
err = dao.Collect.Ctx(ctx).Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
_, err = dao.Collect.Ctx(ctx).Insert(&req)
return err
})
return
}
// Update 更新
func (s *sCollect) Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error) {
err = dao.Collect.Ctx(ctx).Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
if req.Id < 1 {
return gerror.New("id is empty")
}
maps := gconv.Map(req)
_, err = dao.Collect.Ctx(ctx).Data(
maps).Where(dao.Collect.Columns().Id, req.Id).Update()
return err
})
return
}
// Delete 删除
func (s *sCollect) Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error) {
err = dao.Collect.Ctx(ctx).Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
if req.Id < 1 {
return gerror.New("id is empty")
}
_, err = dao.Collect.Ctx(ctx).Where(dao.Collect.Columns().Id, req.Id).Delete()
return err
})
return
}
// BatchDelete 批量删除
func (s *sCollect) BatchDelete(ctx context.Context, req *v1.BatchDeleteReq) (res *v1.BatchDeleteRes, err error) {
err = dao.Collect.Ctx(ctx).Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
if len(req.Ids) < 1 {
return gerror.New("ids is empty")
}
_, err = dao.Collect.Ctx(ctx).WhereIn(dao.Collect.Columns().Id, req.Ids).Delete()
return err
})
return
}

5
app/logic/logic.go

@ -1 +1,6 @@
package logic
import (
_ "xgit.pub/module/cms/app/logic/category"
_ "xgit.pub/module/cms/app/logic/collect"
)

44
app/service/category.go

@ -0,0 +1,44 @@
// ================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// You can delete these comments if you wish manually maintain this interface file.
// ================================================================================
package service
import (
"context"
v1 "xgit.pub/module/cms/app/api/category/v1"
)
type (
ICategory interface {
// GetTree 获取树
GetTree(ctx context.Context, req *v1.GetTreeReq) (res *v1.GetTreeRes, err error)
// GetList 获取列表
GetList(ctx context.Context, req *v1.GetListReq) (res *v1.GetListRes, err error)
// Create 创建
Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error)
// Update 更新
Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error)
// Delete 删除
Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error)
// BatchDelete 批量删除
BatchDelete(ctx context.Context, req *v1.BatchDeleteReq) (res *v1.BatchDeleteRes, err error)
}
)
var (
localCategory ICategory
)
func Category() ICategory {
if localCategory == nil {
panic("implement not found for interface ICategory, forgot register?")
}
return localCategory
}
func RegisterCategory(i ICategory) {
localCategory = i
}
Loading…
Cancel
Save