當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ReturnData.Status方法代碼示例

本文整理匯總了Golang中github.com/jmadan/go-msgstory/util.ReturnData.Status方法的典型用法代碼示例。如果您正苦於以下問題:Golang ReturnData.Status方法的具體用法?Golang ReturnData.Status怎麽用?Golang ReturnData.Status使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/jmadan/go-msgstory/util.ReturnData的用法示例。


在下文中一共展示了ReturnData.Status方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: SaveMessage

func (msg *Message) SaveMessage(conversationId string) RD.ReturnData {
	returnData := RD.ReturnData{}
	dbSession := Connection.GetDBSession()
	dbSession.SetMode(mgo.Monotonic, true)
	dataBase := strings.SplitAfter(os.Getenv("MONGOHQ_URL"), "/")
	c := dbSession.DB(dataBase[3]).C("conversation")
	msg.CreatedOn = time.Now()

	err := c.Update(bson.M{"_id": bson.ObjectIdHex(conversationId)}, bson.M{
		"$push": bson.M{"messages": bson.M{
			"_id":         bson.NewObjectId(),
			"msg_text":    msg.MsgText,
			"user_id":     msg.UserId,
			"user_handle": msg.UserHandle,
			"created_on":  msg.CreatedOn,
		}}})

	if err != nil {
		log.Println(err.Error())
		returnData.ErrorMsg = err.Error()
		returnData.Success = false
		returnData.Status = "422"
	} else {
		jsonData := []byte("{}")
		returnData.Success = true
		returnData.JsonData = jsonData
		returnData.Status = "201"
	}
	return returnData
}
開發者ID:jmadan,項目名稱:go-msgstory,代碼行數:30,代碼來源:message.go

示例2: SaveUserMetaData

func (u *UserMetaData) SaveUserMetaData() RD.ReturnData {
	returnData := RD.ReturnData{}
	dbSession := Connection.GetDBSession()
	dbSession.SetMode(mgo.Monotonic, true)
	dataBase := strings.SplitAfter(os.Getenv("MONGOHQ_URL"), "/")
	c := dbSession.DB(dataBase[3]).C("jove")

	u.Id = bson.NewObjectId()
	u.Created_on = time.Now()

	err := c.Insert(u)
	if err != nil {
		log.Print(err.Error())
		returnData.ErrorMsg = err.Error()
		returnData.Success = false
		returnData.Status = "422"
	} else {
		returnData.Success = true
		jsonData, _ := json.Marshal(&u)
		returnData.JsonData = jsonData
		returnData.Status = "201"
	}

	return returnData
}
開發者ID:jmadan,項目名稱:go-msgstory,代碼行數:25,代碼來源:usermetadata.go

示例3: GetDialoguesForLocation

func GetDialoguesForLocation(locationId string) RD.ReturnData {
	returnData := RD.ReturnData{}
	dbSession := Connection.GetDBSession()
	dbSession.SetMode(mgo.Monotonic, true)
	dataBase := strings.SplitAfter(os.Getenv("MONGOHQ_URL"), "/")
	c := dbSession.DB(dataBase[3]).C("Dialogue")

	res := []Dialogue{}
	err := c.Find(bson.M{"venue.fourid": locationId}).All(&res)
	if err != nil {
		log.Println("Found Nothing Or Something went wrong fetching the Dialogue")
		returnData.ErrorMsg = err.Error()
		returnData.Status = "400"
		returnData.Success = false
	} else {
		log.Println(res)
		returnData.ErrorMsg = "All is well"
		returnData.Status = "200"
		returnData.Success = true
		jsonRes, _ := json.Marshal(res)
		returnData.JsonData = jsonRes
		log.Println(string(jsonRes))
	}
	return returnData
}
開發者ID:jmadan,項目名稱:go-msgstory,代碼行數:25,代碼來源:dialogue.go

示例4: CreateConversation

func (conv *Conversation) CreateConversation() (RD.ReturnData, Conversation) {
	returnData := RD.ReturnData{}
	dbSession := Connection.GetDBSession()
	dbSession.SetMode(mgo.Monotonic, true)
	dataBase := strings.SplitAfter(os.Getenv("MONGOHQ_URL"), "/")
	c := dbSession.DB(dataBase[3]).C("conversation")
	conv.Id = bson.NewObjectId()
	conv.Created_On = time.Now()
	conv.Is_Approved = true

	err := c.Insert(&conv)
	if err != nil {
		log.Print(err.Error())
		returnData.ErrorMsg = err.Error()
		returnData.Success = false
		returnData.Status = "422"
	} else {

		returnData.Success = true
		jsonData, _ := json.Marshal(&conv)
		returnData.JsonData = jsonData
		returnData.Status = "201"
	}

	return returnData, *conv
}
開發者ID:jmadan,項目名稱:go-msgstory,代碼行數:26,代碼來源:conversation.go

示例5: GetConversationsForLocation

func (serv ConversationService) GetConversationsForLocation(locationId string) string {
	var data ReturnData.ReturnData
	response, err := Conversation.GetConversationsForLocation(locationId)
	if err != nil {
		data.ErrorMsg = err.Error()
		data.Status = "400"
		data.Success = false
		serv.ResponseBuilder().SetResponseCode(400).WriteAndOveride([]byte(data.ToString()))
	} else {
		data.Status = "200"
		data.Success = true
		data.JsonData = response
		serv.ResponseBuilder().SetResponseCode(200)
	}

	return string(data.ToString())
}
開發者ID:jmadan,項目名稱:go-msgstory,代碼行數:17,代碼來源:main.go

示例6: GetUser

func (serv UserService) GetUser(userid string) string {
	var response string
	var err error
	var data ReturnData.ReturnData
	response, err = User.GetUserById(userid)
	if err != nil {
		data.Status = "400"
		data.Success = false
		data.ErrorMsg = err.Error()
		serv.ResponseBuilder().SetResponseCode(200)
	} else {
		data.ErrorMsg = "All is well"
		data.Status = "200"
		data.Success = true
		data.JsonData = []byte(response)
		serv.ResponseBuilder().SetResponseCode(400).WriteAndOveride([]byte(data.ToString()))
	}

	return string(data.ToString())
}
開發者ID:jmadan,項目名稱:go-msgstory,代碼行數:20,代碼來源:main.go

示例7: GetMessage

func (serv MsgService) GetMessage(msgId string) string {
	var data ReturnData.ReturnData
	data.Success = true
	data.JsonData = []byte("Get Message call")
	data.Status = "200"
	if data.Success {
		serv.ResponseBuilder().SetResponseCode(200)
	} else {
		serv.ResponseBuilder().SetResponseCode(400).WriteAndOveride([]byte(data.ToString()))
	}
	return string(data.ToString())
}
開發者ID:jmadan,項目名稱:go-msgstory,代碼行數:12,代碼來源:main.go

示例8: DeleteConversation

func DeleteConversation(conversationId string) RD.ReturnData {
	returnData := RD.ReturnData{}
	dbSession := Connection.GetDBSession()
	dbSession.SetMode(mgo.Monotonic, true)
	dataBase := strings.SplitAfter(os.Getenv("MONGOHQ_URL"), "/")
	c := dbSession.DB(dataBase[3]).C("conversation")

	err := c.Remove(bson.ObjectIdHex(conversationId))
	// err := c.Find(bson.M{"venue.fourid": locationId}).One(&res)
	if err != nil {
		log.Println("Found Nothing. Something went wrong fetching the Conversation document")
		log.Println(err)
		returnData.ErrorMsg = err.Error()
		returnData.Status = "400"
		returnData.Success = false
	} else {
		returnData.ErrorMsg = "All is well"
		returnData.Status = "200"
		returnData.Success = true
		returnData.JsonData = nil
	}
	return returnData
}
開發者ID:jmadan,項目名稱:go-msgstory,代碼行數:23,代碼來源:conversation.go

示例9: CreateDialogue

func (D *Dialogue) CreateDialogue() (RD.ReturnData, Dialogue) {
	returnData := RD.ReturnData{}
	dbSession := Connection.GetDBSession()
	dbSession.SetMode(mgo.Monotonic, true)
	dataBase := strings.SplitAfter(os.Getenv("MONGOHQ_URL"), "/")
	c := dbSession.DB(dataBase[3]).C("Dialogue")
	D.Id = bson.NewObjectId()
	D.CreatedOn = time.Now()
	D.IsApproved = true

	err := c.Insert(&D)
	if err != nil {
		log.Print(err.Error())
		returnData.ErrorMsg = err.Error()
		returnData.Success = false
		returnData.Status = "422"
	} else {
		returnData.Success = true
		returnData.JsonData = []byte(D.DialogueToJSON())
		returnData.Status = "201"
	}

	return returnData, *D
}
開發者ID:jmadan,項目名稱:go-msgstory,代碼行數:24,代碼來源:dialogue.go

示例10: DeleteDialogue

func (D *Dialogue) DeleteDialogue() RD.ReturnData {
	returnData := RD.ReturnData{}
	dbSession := Connection.GetDBSession()
	dbSession.SetMode(mgo.Monotonic, true)
	dataBase := strings.SplitAfter(os.Getenv("MONGOHQ_URL"), "/")
	c := dbSession.DB(dataBase[3]).C("Dialogue")

	// err := c.Remove(bson.ObjectIdHex(DialogueId))
	err := c.Remove(D.Id)

	if err != nil {
		log.Println("Found Nothing. Something went wrong fetching the Dialogue document")
		log.Println(err)
		returnData.ErrorMsg = err.Error()
		returnData.Status = "400"
		returnData.Success = false
	} else {
		returnData.ErrorMsg = "All is well"
		returnData.Status = "200"
		returnData.Success = true
		returnData.JsonData = nil
	}
	return returnData
}
開發者ID:jmadan,項目名稱:go-msgstory,代碼行數:24,代碼來源:dialogue.go

示例11: GetMessages

func GetMessages(conversationId string) RD.ReturnData {
	returnData := RD.ReturnData{}
	dbSession := Connection.GetDBSession()
	dbSession.SetMode(mgo.Monotonic, true)
	dataBase := strings.SplitAfter(os.Getenv("MONGOHQ_URL"), "/")
	c := dbSession.DB(dataBase[3]).C("conversation")

	Msgs := []Message{}
	m := Messages{}
	err := c.Find(bson.M{"_id": bson.ObjectIdHex(conversationId)}).Select(bson.M{"messages": 1}).One(&m)
	if err != nil {
		log.Println(err.Error())
		returnData.ErrorMsg = err.Error()
		returnData.Success = false
		returnData.Status = "422"
	} else {
		log.Println(Msgs)
		jsonData, _ := json.Marshal(&m)
		returnData.Success = true
		returnData.JsonData = jsonData
		returnData.Status = "201"
	}
	return returnData
}
開發者ID:jmadan,項目名稱:go-msgstory,代碼行數:24,代碼來源:message.go


注:本文中的github.com/jmadan/go-msgstory/util.ReturnData.Status方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。