本文整理匯總了Golang中github.com/goinggo/tracelog.Completedf函數的典型用法代碼示例。如果您正苦於以下問題:Golang Completedf函數的具體用法?Golang Completedf怎麽用?Golang Completedf使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Completedf函數的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: FindUserByName
func FindUserByName(service *services.Service, userName string) (*userModel.UserInfo, error) {
log.Startedf(service.UserID, "FindUserByName", "userName[%s]", userName)
var userInfo userModel.UserInfo
f := func(collection *mgo.Collection) error {
queryMap := bson.M{
"$or": []bson.M{
bson.M{"user_name": userName},
bson.M{"user_email": userName},
bson.M{"user_mobile": userName},
},
}
log.Trace(service.UserID, "FindUserByName", "MGO : db.user_infos.find(%s).limit(1)", mongo.ToString(queryMap))
return collection.Find(queryMap).One(&userInfo)
}
if err := service.DBAction(Config.Database, "user_infos", f); err != nil {
if err != mgo.ErrNotFound {
log.CompletedError(err, service.UserID, "FindUserByName")
return nil, err
}
}
log.Completedf(service.UserID, "FindUserByName", "userInfo%+v", &userInfo)
return &userInfo, nil
}
示例2: Finish
// Finish is called once the baseController method completes.
func (baseController *BaseController) Finish() {
defer func() {
if baseController.MongoSession != nil {
mongo.CloseSession(baseController.UserID, baseController.MongoSession)
baseController.MongoSession = nil
}
}()
log.Completedf(baseController.UserID, "Finish", baseController.Ctx.Request.URL.Path)
}
示例3: UserLogup
func UserLogup(service *services.Service, userInfo userModel.UserInfo) (*userModel.UserInfo, error) {
log.Startedf(service.UserID, "UserLogup", "user[%s]", userInfo.UserName)
f := func(collection *mgo.Collection) error {
log.Trace(service.UserID, "UserLogup", "MGO : db.user_infos.insert(%s)", mongo.ToString(userInfo))
return collection.Insert(&userInfo)
}
if err := service.DBAction(Config.Database, "user_infos", f); err != nil {
if err != mgo.ErrNotFound {
log.CompletedError(err, service.UserID, "UserLogup")
return nil, err
}
}
log.Completedf(service.UserID, "UserLogup", "userInfo%+v", &userInfo)
return &userInfo, nil
}
示例4: SaveFile
func SaveFile(service *services.Service, fileInfo fileModels.FileInfo) (*fileModels.FileInfo, error) {
log.Startedf(service.UserID, "SaveFile", "FileHash[%s]", fileInfo.FileHash)
f := func(collection *mgo.Collection) error {
log.Trace(service.UserID, "SaveFile", "MGO : db.file_infos.insert(%s)", mongo.ToString(fileInfo))
return collection.Insert(&fileInfo)
}
if err := service.DBAction(Config.Database, "file_infos", f); err != nil {
if err != mgo.ErrNotFound {
log.CompletedError(err, service.UserID, "SaveFile")
return nil, err
}
}
log.Completedf(service.UserID, "SaveFile", "fileInfo%+v", &fileInfo)
return &fileInfo, nil
}
示例5: 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
}
示例6: 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
//DBCall 方法
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
}
示例7: FindMsg
func FindMsg(service *services.Service, userID string) (*msgModel.Message, error) {
log.Startedf(service.UserID, "FindMsg", "userID[%s]", userID)
var message msgModel.Message
f := func(collection *mgo.Collection) error {
queryMap := bson.M{"user_id": userID}
log.Trace(service.UserID, "FindMsg", "MGO : db.message.find(%s).limit(1)", mongo.ToString(queryMap))
return collection.Find(queryMap).One(&message)
}
if err := service.DBAction(Config.Database, "message", f); err != nil {
if err != mgo.ErrNotFound {
log.CompletedError(err, service.UserID, "FindMsg")
return nil, err
}
}
log.Completedf(service.UserID, "FindMsg", "message%+v", &message)
return &message, nil
}
示例8: FindFilesByHash
func FindFilesByHash(service *services.Service, hash string) (*fileModels.FileInfo, error) {
var fileInfo fileModels.FileInfo
f := func(collection *mgo.Collection) error {
queryMap := bson.M{"file_hash": hash}
log.Trace(service.UserID, "findFilesByHash", "MGO : db.file_infos.find(%s).limit(1)", mongo.ToString(queryMap))
return collection.Find(queryMap).One(&fileInfo)
}
if err := service.DBAction(Config.Database, "file_infos", f); err != nil {
if err != mgo.ErrNotFound {
log.CompletedError(err, service.UserID, "findFilesByHash")
return nil, err
}
}
log.Completedf(service.UserID, "findFilesByHash", "fileInfo%+v", &fileInfo)
return &fileInfo, nil
}
示例9: FindSettings
func FindSettings(service *services.Service, userID string) (*settingsModel.WinSettings, error) {
log.Startedf(service.UserID, "FindSettings", "userID[%s]", userID)
var winSettings settingsModel.WinSettings
f := func(collection *mgo.Collection) error {
queryMap := bson.M{"user_id": userID}
log.Trace(service.UserID, "FindSettings", "MGO : db.win_settings.find(%s).limit(1)", mongo.ToString(queryMap))
return collection.Find(queryMap).One(&winSettings)
}
if err := service.DBAction(Config.Database, "win_settings", f); err != nil {
if err != mgo.ErrNotFound {
log.CompletedError(err, service.UserID, "FindSettings")
return nil, err
}
}
log.Completedf(service.UserID, "FindSettings", "winSettings%+v", &winSettings)
return &winSettings, nil
}
示例10: FindInfo
func FindInfo(service *services.Service, userID string) (*infoModel.Information, error) {
log.Startedf(service.UserID, "FindInfo", "userID[%s]", userID)
var information infoModel.Information
f := func(collection *mgo.Collection) error {
queryMap := bson.M{"user_id": userID}
log.Trace(service.UserID, "FindInfo", "MGO : db.information.find(%s).limit(1)", mongo.ToString(queryMap))
return collection.Find(queryMap).One(&information)
}
if err := service.DBAction(Config.Database, "information", f); err != nil {
if err != mgo.ErrNotFound {
log.CompletedError(err, service.UserID, "FindInfo")
return nil, err
}
}
log.Completedf(service.UserID, "FindInfo", "information%+v", &information)
return &information, nil
}
示例11: SaveMsg
func SaveMsg(service *services.Service, message msgModel.Message) (*msgModel.Message, error) {
log.Startedf(service.UserID, "SaveMsg", "UserID[%s]", message.CreatedBy)
f := func(collection *mgo.Collection) error {
if len(message.ID) > 0 {
log.Trace(service.UserID, "SaveMsg", "MGO : db.message.update(%s)", mongo.ToString(message))
return collection.Update(bson.M{"_id": message.ID}, &message)
} else {
log.Trace(service.UserID, "SaveMsg", "MGO : db.message.insert(%s)", mongo.ToString(message))
return collection.Insert(&message)
}
}
if err := service.DBAction(Config.Database, "message", f); err != nil {
if err != mgo.ErrNotFound {
log.CompletedError(err, service.UserID, "SaveMsg")
return nil, err
}
}
log.Completedf(service.UserID, "SaveMsg", "message%+v", &message)
return &message, nil
}
示例12: SaveSettings
func SaveSettings(service *services.Service, settings settingsModel.WinSettings) (*settingsModel.WinSettings, error) {
log.Startedf(service.UserID, "SaveSettings", "UserID[%s]", settings.UserID)
f := func(collection *mgo.Collection) error {
if len(settings.ID) > 0 {
log.Trace(service.UserID, "SaveSettings", "MGO : db.win_settings.update(%s)", mongo.ToString(settings))
return collection.Update(bson.M{"_id": settings.ID}, &settings)
} else {
log.Trace(service.UserID, "SaveSettings", "MGO : db.win_settings.insert(%s)", mongo.ToString(settings))
return collection.Insert(&settings)
}
}
if err := service.DBAction(Config.Database, "win_settings", f); err != nil {
if err != mgo.ErrNotFound {
log.CompletedError(err, service.UserID, "SaveSettings")
return nil, err
}
}
log.Completedf(service.UserID, "SaveSettings", "settings%+v", &settings)
return &settings, nil
}
示例13: SaveInfo
func SaveInfo(service *services.Service, information infoModel.Information) (*infoModel.Information, error) {
log.Startedf(service.UserID, "SaveInfo", "UserID[%s]", information.CreatedBy)
f := func(collection *mgo.Collection) error {
if len(information.ID) > 0 {
log.Trace(service.UserID, "SaveInfo", "MGO : db.information.update(%s)", mongo.ToString(information))
return collection.Update(bson.M{"_id": information.ID}, &information)
} else {
log.Trace(service.UserID, "SaveInfo", "MGO : db.information.insert(%s)", mongo.ToString(information))
return collection.Insert(&information)
}
}
if err := service.DBAction(Config.Database, "information", f); err != nil {
if err != mgo.ErrNotFound {
log.CompletedError(err, service.UserID, "SaveInfo")
return nil, err
}
}
log.Completedf(service.UserID, "SaveInfo", "information%+v", &information)
return &information, nil
}