Beispiel #1
0
// @Title Post
// @Description create CRMContact
// @Param	body		body 	models.CRMContact	true		"body for CRMContact content"
// @Success 200 {int} models.CRMContact.Id
// @Failure 403 body is empty
// @router / [post]
func (c *CRMContactController) Post() {
	ct := new(models.CRMContact)
	ct.CAdd = c.GetString("CAdd")
	ct.CName = c.GetString("CName")
	ct.CBirthday = c.GetString("CBirthday")
	ct.CCreateDate = time.Now()
	ct.CDepartment = c.GetString("CDepartment")
	ct.CPosition = c.GetString("CPosition")
	ct.CEmail = c.GetString("CEmail")
	ct.CFax = c.GetString("CFax")
	ct.CHobby = c.GetString("CHobby")
	ct.CMob = c.GetString("CMob")
	ct.CQQ = c.GetString("CQQ")
	ct.CSex = c.GetString("CSex")
	ct.CTel = c.GetString("CTel")
	ct.CHobby = c.GetString("CHobby")
	ct.CRemarks = c.GetString("CRemarks")

	if _, err := models.AddCRMContact(ct); err == nil {
		c.Data["json"] = comm.RespJsonRefresh_Close("contactPage")
	} else {
		c.Data["json"] = err.Error()
	}
	c.ServeJson()
	//c.Redirect("/crm/contact/getall",200)
}
Beispiel #2
0
// @Title Update
// @Description update the CRMContact
// @Param	id		path 	string	true		"The id you want to update"
// @Param	body		body 	models.CRMContact	true		"body for CRMContact content"
// @Success 200 {object} models.CRMContact
// @Failure 403 :id is not int
// @router /:id [put]
func (c *CRMContactController) Put() {
	idStr := c.Ctx.Input.Params[":id"]
	id, _ := strconv.Atoi(idStr)
	ct := models.CRMContact{Id: id}

	ct.CAdd = c.GetString("CAdd")
	ct.CName = c.GetString("CName")
	ct.CBirthday = c.GetString("CBirthday")
	ct.CCreateDate = time.Now()
	ct.CDepartment = c.GetString("CDepartment")
	ct.CPosition = c.GetString("CPosition")
	ct.CEmail = c.GetString("CEmail")
	ct.CFax = c.GetString("CFax")
	ct.CHobby = c.GetString("CHobby")
	ct.CMob = c.GetString("CMob")
	ct.CQQ = c.GetString("CQQ")
	ct.CSex = c.GetString("CSex")
	ct.CTel = c.GetString("CTel")
	ct.CHobby = c.GetString("CHobby")
	ct.CRemarks = c.GetString("CRemarks")

	if err := models.UpdateCRMContactById(&ct); err == nil {
		c.Data["json"] = comm.RespJsonRefresh_Close("contactPage")
	} else {
		c.Data["json"] = err.Error()
	}
	c.ServeJson()
}