1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- package api
- import (
- "mats/db/model"
- "mats/db/repo"
- "time"
- "go.mongodb.org/mongo-driver/bson/primitive"
- "infish.cn/comm"
- )
- func UploadMaterial(apictx *ApiSession, dbConf *model.AssetDbConf, body *comm.AssetMat) (interface{}, error) {
- asset := body
- // source := asset.Source
- asset.Enable = BoolValue(false)
- asset.AssetState = model.AssetState_Succ
- asset.CreateTime = time.Now()
- asset.UpdateTime = time.Now()
- collectionName := dbConf.AssetConf.Collection
- return repo.RepoDbAddDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, asset)
- }
- func UploadMaterialGroup(apictx *ApiSession, dbConf *model.AssetDbConf, body *comm.AssetMatGroup) (interface{}, error) {
- asset := body
- // source := asset.Source
- asset.Enable = BoolValue(false)
- asset.AssetState = model.AssetState_Succ
- asset.CreateTime = time.Now()
- asset.UpdateTime = time.Now()
- collectionName := dbConf.AssetConf.Collection
- return repo.RepoDbAddDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, asset)
- }
- func UpdateMaterialGroup(apictx *ApiSession, dbConf *model.AssetDbConf, body *comm.AssetMatGroup) (interface{}, error) {
- asset := body
- asset.UpdateTime = time.Now()
- id := asset.Id.Hex()
- asset.Id = primitive.NilObjectID
- collectionName := dbConf.AssetConf.Collection
- return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset)
- }
- func UpdateMaterialComm(apictx *ApiSession, dbConf *model.AssetDbConf, body *comm.AssetMat) (interface{}, error) {
- asset := body
- asset.UpdateTime = time.Now()
- id := asset.Id.Hex()
- asset.Id = primitive.NilObjectID
- collectionName := dbConf.AssetConf.Collection
- return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset)
- }
- func UpdateMaterialSource(apictx *ApiSession, dbConf *model.AssetDbConf, body *model.AssetMat) (interface{}, error) {
- asset := body
- asset.UpdateTime = time.Now()
- id := asset.Id.Hex()
- asset.Id = primitive.NilObjectID
- collectionName := dbConf.AssetConf.Collection
- return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset)
- }
- func ProcessMat(apictx *ApiSession, dbConf *model.AssetDbConf, id string) (interface{}, error) {
- // mesh := &model.AssetMat{}
- // ok, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
- // Db: dbConf.DbName,
- // CollectName: dbConf.AssetConf.Collection,
- // Query: repo.Map{"_id": id},
- // Project: []string{"source.file"},
- // }, mesh)
- // if err != nil {
- // return nil, err
- // }
- // if !ok {
- // return nil, NewError("hdr已删除!")
- // }
- // err = bus.NatsCenter.HdrAssetProcessReq(dbConf.DbName, dbConf.AssetConf.Collection, id, mesh.Source.File.Url)
- // assetState := model.AssetState_Waiting
- // if err != nil {
- // assetState = model.AssetState_Failed
- // }
- // update := bson.M{"$set": bson.M{"assetState": assetState}}
- // return repo.RepoUpdateSetDbDocProps(apictx.CreateRepoCtx(), dbConf.DbName, dbConf.AssetConf.Collection, id, update)
- return nil, NewError("no impl!")
- }
|