123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- package api
- import (
- "assetcenter/conf"
- "assetcenter/db/model"
- "assetcenter/db/repo"
- "time"
- "go.mongodb.org/mongo-driver/bson/primitive"
- "infish.cn/comm"
- )
- func UploadMaterial(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetMat) (interface{}, error) {
- asset := body
- // source := asset.Source
- asset.Enable = BoolValue(false)
- asset.AssetState = model.AssetState_Succ
- if conf.AppConfig.IsSaveLocal() {
- body.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl)
- }
- 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 *comm.AssetDbConf, body *comm.AssetMatGroup) (interface{}, error) {
- asset := body
- // source := asset.Source
- asset.Enable = BoolValue(false)
- asset.AssetState = model.AssetState_Succ
- if conf.AppConfig.IsSaveLocal() {
- body.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl)
- }
- 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 *comm.AssetDbConf, body *comm.AssetMatGroup) (interface{}, error) {
- asset := body
- asset.UpdateTime = time.Now()
- id := asset.Id.Hex()
- asset.Id = primitive.NilObjectID
- if conf.AppConfig.IsSaveLocal() {
- body.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl)
- }
- collectionName := dbConf.AssetConf.Collection
- return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset)
- }
- func UpdateMaterialComm(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetMat) (interface{}, error) {
- asset := body
- asset.UpdateTime = time.Now()
- id := asset.Id.Hex()
- asset.Id = primitive.NilObjectID
- if conf.AppConfig.IsSaveLocal() {
- body.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl)
- }
- collectionName := dbConf.AssetConf.Collection
- return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset)
- }
- func UpdateMaterialSource(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetMat) (interface{}, error) {
- asset := body
- asset.UpdateTime = time.Now()
- id := asset.Id.Hex()
- asset.Id = primitive.NilObjectID
- if conf.AppConfig.IsSaveLocal() {
- body.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl)
- }
- collectionName := dbConf.AssetConf.Collection
- return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset)
- }
- func ProcessMat(apictx *ApiSession, dbConf *comm.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!")
- }
|