1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- package api
- import (
- "assetcenter/bus"
- "assetcenter/conf"
- "assetcenter/db/repo"
- funcgraph "assetcenter/funcGraph"
- "time"
- "go.mongodb.org/mongo-driver/bson/primitive"
- "infish.cn/comm"
- )
- func UpdateAssetPackageComm(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetPackage) (interface{}, error) {
- asset := body
- asset.UpdateTime = time.Now()
- if conf.AppConfig.IsSaveLocal() {
- asset.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl)
- }
- id := asset.Id.Hex()
- asset.Id = primitive.NilObjectID
- collectionName := dbConf.AssetConf.Collection
- return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset)
- }
- type OsgConvRequest struct {
- AssetId string `json:"assetId"`
- DbId string `json:"dbId"`
- Table string `json:"table"`
- MeshUrl string `json:"meshUrl"`
- LocalPath string `json:"localPath"`
- WkDir string `json:"wkDir"`
- }
- func UploadAssetPackage(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetPackage) (interface{}, error) {
- asset := body
- asset.Enable = BoolValue(false)
- body.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl)
- transTask := asset.TransTask
- shadowTask := asset.ShadowTask
- if comm.TransTaskIsNotEmpty(transTask) {
- // 转换文件存在,更新状态
- asset.Source = nil
- }
- 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
- }
- url, err := bus.NatsCenter.RequestConfig("bus-network")
- if err != nil {
- return nil, err
- }
- if comm.TransTaskIsNotEmpty(transTask) {
- // 模型转换
- funcgraph.OsgConvRequest(transTask.File.Url, assetId, dbConf.Db.Name, dbConf.AssetConf.Collection, url)
- }
- if comm.ShadowIsNotEmpty(shadowTask) {
- // 阴影转换
- funcgraph.CreateShadow(shadowTask.File.Url, assetId, dbConf.Db.Name, dbConf.AssetConf.Collection, 15, 512, url)
- }
- return assetId, err
- }
- func UpdateAssetPackageSource(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetPackage) (interface{}, error) {
- asset := body
- asset.UpdateTime = time.Now()
- id := asset.Id.Hex()
- asset.Id = primitive.NilObjectID
- if conf.AppConfig.IsSaveLocal() {
- asset.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl)
- }
- collectionName := dbConf.AssetConf.Collection
- return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset)
- }
|