Example #1
0
func Delete(c *gin.Context) {
	protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
	transportFactory := thrift.NewTFramedTransportFactory(thrift.NewTTransportFactory())

	var json model.Person
	c.BindJSON(&json)
	err := service.Delete(transportFactory, protocolFactory, json.ID)
	if err != nil {
		m := fmt.Sprintf("%v", err)
		c.JSON(http.StatusExpectationFailed, util.FailResponse(m))
	} else {
		parse := map[string]interface{}{
			"person": json,
		}
		c.JSON(http.StatusCreated, util.ObjectResponse("success", "", parse))
	}
}
Example #2
0
func Update(c *gin.Context) {
	protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
	transportFactory := thrift.NewTFramedTransportFactory(thrift.NewTTransportFactory())

	var json model.Person
	c.BindJSON(&json)
	person := model.PersonUpdate(json.ID, json.Identity, json.Firstname, json.Middlename, json.Lastname, json.Address, json.Age, json.Active)
	result, err := service.Update(transportFactory, protocolFactory, person)
	if err != nil {
		m := fmt.Sprintf("%v", err)
		c.JSON(http.StatusExpectationFailed, util.FailResponse(m))
	} else {
		parse := map[string]interface{}{
			"person": model.PersonResponse(result),
		}
		c.JSON(http.StatusCreated, util.ObjectResponse("success", "", parse))
	}
}