本文整理汇总了Golang中github.com/goinggo/beego-mgo/services.Service类的典型用法代码示例。如果您正苦于以下问题:Golang Service类的具体用法?Golang Service怎么用?Golang Service使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Service类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: FindStation
// FindStation retrieves the specified station
func FindStation(service *services.Service, stationId string) (buoyStation *buoyModels.BuoyStation, err error) {
defer helper.CatchPanic(&err, service.UserId, "FindStation")
tracelog.Started(service.UserId, "FindStation")
queryMap := bson.M{"station_id": stationId}
buoyStation = &buoyModels.BuoyStation{}
err = service.DBAction(Config.Database, "buoy_stations",
func(collection *mgo.Collection) error {
tracelog.Trace(service.UserId, "FindStation", "Query : %s", mongo.ToString(queryMap))
return collection.Find(queryMap).One(buoyStation)
})
if err != nil {
if strings.Contains(err.Error(), "not found") == false {
tracelog.CompletedError(err, service.UserId, "FindStation")
return buoyStation, err
}
err = nil
}
tracelog.Completed(service.UserId, "FindStation")
return buoyStation, err
}
示例2: Prepare
// Prepare is called before controllers are called.
func Prepare() *services.Service {
var service services.Service
// TODO: Add Test User To Environment
service.UserID = "testing"
err := service.Prepare()
if err != nil {
log.Error(err, service.UserID, "Prepare")
return nil
}
log.Trace(service.UserID, "Before", "UserID[%s]", service.UserID)
return &service
}
示例3: FindRegion
// FindRegion retrieves the stations for the specified region
func FindRegion(service *services.Service, region string) ([]buoyModels.BuoyStation, error) {
log.Startedf(service.UserID, "FindRegion", "region[%s]", region)
var buoyStations []buoyModels.BuoyStation
f := func(collection *mgo.Collection) error {
queryMap := bson.M{"region": region}
log.Trace(service.UserID, "FindRegion", "Query : db.buoy_stations.find(%s)", mongo.ToString(queryMap))
return collection.Find(queryMap).All(&buoyStations)
}
if err := service.DBAction(Config.Database, "buoy_stations", f); err != nil {
log.CompletedError(err, service.UserID, "FindRegion")
return nil, err
}
log.Completedf(service.UserID, "FindRegion", "buoyStations%+v", buoyStations)
return buoyStations, nil
}
示例4: FindStation
// FindStation retrieves the specified station
func FindStation(service *services.Service, stationID string) (*buoyModels.BuoyStation, error) {
log.Startedf(service.UserID, "FindStation", "stationID[%s]", stationID)
var buoyStation buoyModels.BuoyStation
f := func(collection *mgo.Collection) error {
queryMap := bson.M{"station_id": stationID}
log.Trace(service.UserID, "FindStation", "MGO : db.buoy_stations.find(%s).limit(1)", mongo.ToString(queryMap))
return collection.Find(queryMap).One(&buoyStation)
}
if err := service.DBAction(Config.Database, "buoy_stations", f); err != nil {
if err != mgo.ErrNotFound {
log.CompletedError(err, service.UserID, "FindStation")
return nil, err
}
}
log.Completedf(service.UserID, "FindStation", "buoyStation%+v", &buoyStation)
return &buoyStation, nil
}
示例5: FindRegion
// FindRegion retrieves the stations for the specified region
func FindRegion(service *services.Service, region string) (buoyStations []*buoyModels.BuoyStation, err error) {
defer helper.CatchPanic(&err, service.UserId, "FindRegion")
tracelog.Started(service.UserId, "FindRegion")
queryMap := bson.M{"region": region}
buoyStations = []*buoyModels.BuoyStation{}
err = service.DBAction(Config.Database, "buoy_stations",
func(collection *mgo.Collection) error {
tracelog.Trace(service.UserId, "FindRegion", "Query : %s", mongo.ToString(queryMap))
return collection.Find(queryMap).All(&buoyStations)
})
if err != nil {
tracelog.CompletedError(err, service.UserId, "FindRegion")
return buoyStations, err
}
tracelog.Completed(service.UserId, "FindRegion")
return buoyStations, err
}
示例6: FindStation
// FindStation retrieves the specified station
func FindStation(service *services.Service, stationId string) (buoyStation *buoyModels.BuoyStation, err error) {
defer helper.CatchPanic(&err, service.UserId, "FindStation")
tracelog.STARTED(service.UserId, "FindStation")
queryMap := bson.M{"station_id": stationId}
tracelog.TRACE(service.UserId, "FindStation", "Query : %s", mongo.ToString(queryMap))
buoyStation = &buoyModels.BuoyStation{}
err = service.DBAction(Config.Database, "buoy_stations",
func(collection *mgo.Collection) error {
return collection.Find(queryMap).One(buoyStation)
})
if err != nil {
tracelog.COMPLETED_ERROR(err, service.UserId, "FindStation")
return buoyStation, err
}
tracelog.COMPLETED(service.UserId, "FindStation")
return buoyStation, err
}
示例7: Finish
func Finish(service *services.Service) {
service.Finish()
tracelog.COMPLETED(service.UserId, "Finish")
}
示例8: Finish
// Finish is called after controllers are called.
func Finish(service *services.Service) {
service.Finish()
log.Completed(service.UserID, "Finish")
}