1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- package api
- import (
- "mats/db/model"
- "mats/db/repo"
- funcgraph "mats/funcGraph"
- "time"
- "go.mongodb.org/mongo-driver/bson"
- "go.mongodb.org/mongo-driver/bson/primitive"
- )
- func UpdateAssetPackageComm(apictx *ApiSession, dbConf *model.AssetDbConf, body *model.AssetPackage) (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 UploadAssetPackage(apictx *ApiSession, dbConf *model.AssetDbConf, body *model.AssetPackage) (interface{}, error) {
- asset := body
- asset.Enable = BoolValue(false)
- source := asset.Source.Geoms[0]
- if source == nil || source.Glb.Size < 1 || len(source.Glb.Url) < 1 {
- asset.AssetState = model.AssetState_Empty
- } else {
- asset.AssetState = model.AssetState_Waiting
- }
- asset.CreateTime = time.Now()
- asset.UpdateTime = time.Now()
- collectionName := dbConf.AssetConf.Collection
- assetId, err := repo.RepoDbAddDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, asset)
- if err != nil {
- return nil, err
- }
- if asset.AssetState == model.AssetState_Waiting { //模型转换请求
- // err = bus.NatsCenter.MeshAssetProcessReq(dbConf.Db.Name, dbConf.AssetConf.Collection, assetId, source.Glb.Url, apictx.User.ID)
- // if err != nil {
- // update := bson.M{"$set": bson.M{"assetState": model.AssetState_Failed}}
- // repo.RepoUpdateSetDbDocProps(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, assetId, update)
- // }
- err = funcgraph.OsgConvRequest(source.Glb.Url, assetId, dbConf.Db.Name, dbConf.AssetConf.Collection)
- if err != nil {
- update := bson.M{"$set": bson.M{"assetState": model.AssetState_Failed}}
- repo.RepoUpdateSetDbDocProps(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, assetId, update)
- }
- funcgraph.CreateShadow(source.Glb.Url, assetId, dbConf.Db.Name, dbConf.AssetConf.Collection, 15, 512)
- }
- return assetId, err
- }
- func UpdateAssetPackageSource(apictx *ApiSession, dbConf *model.AssetDbConf, body *model.AssetPackage) (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)
- }
|