当前位置: 首页>>代码示例>>Golang>>正文


Golang services.Service类代码示例

本文整理汇总了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
}
开发者ID:jharlap,项目名称:beego-mgo,代码行数:27,代码来源:buoyService.go

示例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
}
开发者ID:ZloiBubr,项目名称:beego-mgo,代码行数:16,代码来源:serviceTests.go

示例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
}
开发者ID:ZloiBubr,项目名称:beego-mgo,代码行数:20,代码来源:buoyService.go

示例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
}
开发者ID:ZloiBubr,项目名称:beego-mgo,代码行数:22,代码来源:buoyService.go

示例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
}
开发者ID:jharlap,项目名称:beego-mgo,代码行数:23,代码来源:buoyService.go

示例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
}
开发者ID:pmljm,项目名称:beego-mgo,代码行数:23,代码来源:buoyService.go

示例7: Finish

func Finish(service *services.Service) {
	service.Finish()

	tracelog.COMPLETED(service.UserId, "Finish")
}
开发者ID:jharlap,项目名称:beego-mgo,代码行数:5,代码来源:serviceTests.go

示例8: Finish

// Finish is called after controllers are called.
func Finish(service *services.Service) {
	service.Finish()

	log.Completed(service.UserID, "Finish")
}
开发者ID:ZloiBubr,项目名称:beego-mgo,代码行数:6,代码来源:serviceTests.go


注:本文中的github.com/goinggo/beego-mgo/services.Service类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。