本文整理匯總了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")
}