Skip to content

Commit

Permalink
Fix the exist name check and rename the as to sp
Browse files Browse the repository at this point in the history
  • Loading branch information
hwchiu committed Jun 22, 2018
1 parent 707cc52 commit 713eb4f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/entity/storage_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ type StorageProvider struct {
ID bson.ObjectId `bson:"_id,omitempty" json:"id"`
Type string `bson:"type" json:"type"`
DisplayName string `bson:"displayName" json:"displayName"`
CreatedAt *time.Time `bson:"createdAt,omitempty" json:"createdAt,omitempty"`
NFSStorageProvider
CreatedAt *time.Time `bson:"createdAt,omitempty" json:"createdAt,omitempty"`
}

//GetCollection - get model mongo collection name.
Expand Down
6 changes: 3 additions & 3 deletions src/server/handler_storage_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

func CreateStorageProvider(ctx *web.Context) {
as, req, resp := ctx.ServiceProvider, ctx.Request, ctx.Response
sp, req, resp := ctx.ServiceProvider, ctx.Request, ctx.Response

storageProvider := entity.StorageProvider{}
if err := req.ReadEntity(&storageProvider); err != nil {
Expand All @@ -22,11 +22,11 @@ func CreateStorageProvider(ctx *web.Context) {
return
}

session := as.Mongo.NewSession()
session := sp.Mongo.NewSession()
defer session.Close()
// Check whether this displayname has been used
query := bson.M{"displayName": storageProvider.DisplayName}
count, err := session.Count(entity.NetworkCollectionName, query)
count, err := session.Count(entity.StorageProviderCollectionName, query)
if err != nil && err.Error() != mgo.ErrNotFound.Error() {
logger.Error(err)
response.InternalServerError(req.Request, resp.ResponseWriter, err)
Expand Down

0 comments on commit 713eb4f

Please sign in to comment.