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


Golang ReturnData.ToString方法代码示例

本文整理汇总了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())
}
开发者ID:jmadan,项目名称:go-msgstory,代码行数:11,代码来源:main.go

示例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())
}
开发者ID:jmadan,项目名称:go-msgstory,代码行数:12,代码来源:main.go

示例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())
}
开发者ID:jmadan,项目名称:go-msgstory,代码行数:17,代码来源:main.go

示例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()))
	}
}
开发者ID:jmadan,项目名称:go-msgstory,代码行数:19,代码来源:main.go

示例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())
}
开发者ID:jmadan,项目名称:go-msgstory,代码行数:20,代码来源:main.go

示例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()))
	}

}
开发者ID:jmadan,项目名称:go-msgstory,代码行数:22,代码来源:main.go

示例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()))
	}
}
开发者ID:jmadan,项目名称:go-msgstory,代码行数:37,代码来源:main.go


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