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