123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package api
- import (
- "assetcenter/conf"
- "assetcenter/db/model"
- "assetcenter/db/repo"
- "time"
- "go.mongodb.org/mongo-driver/bson/primitive"
- "infish.cn/comm"
- )
- func UploadImage(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetImage) (interface{}, error) {
- asset := body
- // source := asset.Source
- asset.Enable = BoolValue(false)
- asset.AssetState = model.AssetState_Succ
- if conf.AppConfig.IsSaveLocal() {
- asset.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 UpdateImageComm(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetImage) (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)
- }
- func UpdateImageSource(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetImage) (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)
- }
|