123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- package api
- import (
- "errors"
- "spu3d/bus"
- "spu3d/db/repo"
- "github.com/gin-gonic/gin"
- "infish.cn/comm"
- )
- // spu3d-tree中资源
- func Asset(r *GinRouter) {
- r.POSTJWT("/asset/category", AssetCategory)
- r.POSTJWT("/asset/list", AssetList)
- }
- type TreeQueryDbCategoryReq struct {
- DefineCollection string //box
- DbName string //spu3d-tree
- UserId string
- AssetScope string // spu3d
- }
- func AssetCategory(c *gin.Context, apictx *ApiSession) (interface{}, error) {
- var req TreeQueryDbCategoryReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- return nil, errors.New("参数错误!")
- }
- cates := comm.DbCategory{}
- err = bus.NatsCenter.RequestPackApi("tree.category.query", &req, &cates, &comm.RequestOptions{
- DeployPack: "spu3dtree",
- })
- return cates, err
- }
- type TreeListReq struct {
- DbName string
- Collection string
- Page int
- Size int
- Project []string
- Query map[string]interface{}
- }
- func AssetList(c *gin.Context, apictx *ApiSession) (interface{}, error) {
- var req TreeListReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- return nil, errors.New("参数错误!")
- }
- out := &repo.PageResult{}
- err = bus.NatsCenter.RequestPackApi("tree.asset.list", &req, &out, &comm.RequestOptions{
- DeployPack: "spu3dtree",
- })
- return out, err
- }
|