本文整理汇总了Golang中github.com/jmadan/go-msgstory/util.ReturnData.ToString方法的典型用法代码示例。如果您正苦于以下问题:Golang ReturnData.ToString方法的具体用法?Golang ReturnData.ToString怎么用?Golang ReturnData.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jmadan/go-msgstory/util.ReturnData
的用法示例。
在下文中一共展示了ReturnData.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetMessages
//*************Message Service Methods ***************
func (serv MsgService) GetMessages(convoId string) string {
var data ReturnData.ReturnData
data = Msg.GetMessages(convoId)
if data.Success {
serv.ResponseBuilder().SetResponseCode(200)
} else {
serv.ResponseBuilder().SetResponseCode(400).WriteAndOveride([]byte(data.ToString()))
}
return string(data.ToString())
}
示例2: 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())
}
示例3: 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())
}
示例4: SaveMessage
func (serv MsgService) SaveMessage(posted, convoId string) {
var data ReturnData.ReturnData
var str []string
str = strings.Split(posted, "=")
msg := Msg.Message{}
err := json.Unmarshal([]byte(str[1]), &msg)
if err != nil {
log.Println(err.Error())
serv.ResponseBuilder().SetResponseCode(400).WriteAndOveride(nil)
return
} else {
data = msg.SaveMessage(convoId)
}
if data.Success {
serv.ResponseBuilder().SetResponseCode(201).Write([]byte(data.ToString()))
} else {
serv.ResponseBuilder().SetResponseCode(400).WriteAndOveride([]byte(data.ToString()))
}
}
示例5: 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())
}
示例6: CreateConversation
//*************Conversation Service Methods ***********
func (serv ConversationService) CreateConversation(posted string) {
var returnData ReturnData.ReturnData
var formData []string
formData = strings.Split(posted, "=")
conv := Conversation.Conversation{}
err := json.Unmarshal([]byte(formData[1]), &conv)
if err != nil {
log.Println("conversation marshelling error>>>>>" + err.Error())
serv.ResponseBuilder().SetResponseCode(400).WriteAndOveride([]byte(err.Error()))
return
} else {
returnData, _ = conv.CreateConversation()
}
if returnData.Success {
serv.ResponseBuilder().SetResponseCode(201).Write([]byte(returnData.ToString()))
} else {
serv.ResponseBuilder().SetResponseCode(400).WriteAndOveride([]byte(returnData.ToString()))
}
}
示例7: RegisterUser
//*************User Service Methods ***************
func (serv UserService) RegisterUser(posted string) {
type newUser struct {
Name string `json:"name" bson:"name"`
Email string `json:"email" bson:"email"`
Handle string `json:"handle" bson:"handle"`
Password string `json:"password" bson:"password"`
PhoneNumber string `json:"phone" bson:"phone"`
}
var data ReturnData.ReturnData
var formData []string
formData = strings.Split(posted, "=")
user := User.User{}
tempUser := newUser{}
err := json.Unmarshal([]byte(formData[1]), &tempUser)
if err != nil {
log.Println(err.Error())
serv.ResponseBuilder().SetResponseCode(400).WriteAndOveride(nil)
return
} else {
user_id := User.CreateUserLogin(tempUser.Email, tempUser.Password)
user.UserId, _ = strconv.Atoi(user_id)
user.Name = tempUser.Name
user.Email = tempUser.Email
user.Handle = tempUser.Handle
user.PhoneNumber = tempUser.PhoneNumber
data = user.CreateUser()
}
if data.Success {
serv.ResponseBuilder().SetResponseCode(201).Write([]byte(data.ToString()))
} else {
serv.ResponseBuilder().SetResponseCode(400).WriteAndOveride([]byte(data.ToString()))
}
}