sun-pc 5 달 전
부모
커밋
4048cc26a8
3개의 변경된 파일1개의 추가작업 그리고 108개의 파일을 삭제
  1. 0 99
      src/api/material.go
  2. 0 6
      src/api/router.go
  3. 1 3
      src/db/model/cate.go

+ 0 - 99
src/api/material.go

@@ -1,99 +0,0 @@
-package api
-
-import (
-	"encoding/json"
-	"errors"
-	"fmt"
-	"os"
-
-	"moutai/db/model"
-	"moutai/db/repo"
-
-	"github.com/gin-gonic/gin"
-	"go.mongodb.org/mongo-driver/bson"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-func CreateMaterial(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-	material := &model.Material{}
-	err := c.ShouldBindJSON(&material)
-	if err != nil {
-		return nil, err
-	}
-
-	return repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionMaterials, &material)
-}
-
-func DeleteMaterial(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	_id := c.Param("id")
-	id, _ := primitive.ObjectIDFromHex(_id)
-	if id.IsZero() {
-		return nil, errors.New("id错误")
-	}
-	return repo.RepoDeleteDoc(apictx.CreateRepoCtx(), repo.CollectionMaterials, _id)
-}
-
-func MaterialList(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	page, size, query := UtilQueryPageSize(c)
-	if v, ok := query["name"]; ok {
-		name := v.(string)
-		if len(name) > 0 {
-			delete(query, "name")
-			query["attributes.name"] = bson.M{"$regex": name, "$options": "$i"}
-		}
-	}
-
-	result, err := repo.RepoPageSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
-		CollectName: repo.CollectionMaterials,
-		Page:        page,
-		Size:        size,
-		Query:       query,
-	})
-
-	return result, err
-}
-
-func UpdateMaterial(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-	material := &model.Material{}
-	err := c.ShouldBindJSON(&material)
-	if err != nil {
-		return nil, err
-	}
-	if material.Id.IsZero() {
-		return nil, errors.New("id错误")
-	}
-
-	return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionMaterials, material.Id.Hex(), material)
-}
-
-func MaterialInsert(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	// 读取json文件
-	jsonData, err := os.ReadFile("api/datalist/11卡证背景.json")
-	if err != nil {
-		return nil, fmt.Errorf("failed to read JSON file: %v", err)
-	}
-
-	var jsonMaterials []*model.Material
-	if err := json.Unmarshal(jsonData, &jsonMaterials); err != nil {
-		return nil, fmt.Errorf("failed to parse JSON: %v", err)
-	}
-	fmt.Println("total:", len(jsonMaterials))
-	count := 0
-	// 转换为model.Material结构并插入数据库
-	for _, m := range jsonMaterials {
-		m.Id = primitive.NewObjectID()
-		m.Type = 11
-		id, err := repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionMaterials, m)
-		if err != nil {
-			fmt.Println(err)
-		} else {
-			fmt.Println(id)
-			count++
-
-		}
-	}
-
-	return count, nil
-}

+ 0 - 6
src/api/router.go

@@ -81,12 +81,6 @@ func RegRouters(svc *Service) {
 	moutai.GETJWT("/sort/prev", SortPrev)
 	moutai.GETJWT("/sort/next", SortNext)
 
-	// !素材管理(非moutai项目接口,下阶段迁移)
-	moutai.POSTJWT("/material/create", CreateMaterial)
-	moutai.POSTJWT("/material/delete/:id", DeleteMaterial)
-	moutai.GET("/material/list", MaterialList)
-	moutai.POSTJWT("/material/update", UpdateMaterial)
-
 }
 
 func Logger() gin.HandlerFunc {

+ 1 - 3
src/db/model/cate.go

@@ -10,9 +10,7 @@ type Catgory struct {
 	Id   primitive.ObjectID `bson:"_id,omitempty" json:"_id,omitempty"`
 	Name string             `bson:"name,omitempty" json:"name,omitempty"`
 	// 分类类型: 图片/视频/vr...
-	Type   string `bson:"type,omitempty" json:"type,omitempty"`
-	TypeId int    `bson:"typeId,omitempty" json:"typeId,omitempty"`
-
+	Type       string    `bson:"type,omitempty" json:"type,omitempty"`
 	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime,omitempty"`
 	UpdateTime time.Time `bson:"updateTime,omitempty" json:"updateTime,omitempty"`
 }