Example #1
0
func getEnquire(req *restful.Request, resp *restful.Response) {
	log.Debug("try to get enquire with id : %s", req.PathParameter("EnquireId"))
	userId, err := strconv.ParseInt(req.Attribute("agsuserid").(string), 10, 64)
	if err != nil {
		resp.WriteError(http.StatusInternalServerError, err)
	}
	id := req.PathParameter("EnquireId")
	e := new(Enquire)
	e.Id = auth.Decode(id)
	ret := dbGetEnquire(e, userId)
	if ret == http.StatusOK {
		e.Id = id
		resp.WriteEntity(e)
	} else {
		resp.WriteErrorString(ret, http.StatusText(ret))
	}
}
Example #2
0
func followupEnquire(req *restful.Request, resp *restful.Response) {
	id := req.PathParameter("EnquireId")

	e := new(Enquire)
	err := req.ReadEntity(&e)
	if err == nil {
		e.EmployeeId, err = strconv.ParseInt(req.Attribute("agsemployeeid").(string), 10, 64)
		e.Id = auth.Decode(id)
		ret := dbFollowupEnquire(e)
		if ret == http.StatusOK {
			resp.WriteHeader(http.StatusCreated)
			e.Id = auth.Encode(e.Id)
			resp.WriteEntity(e)
		} else {
			resp.WriteErrorString(ret, http.StatusText(ret))
		}
	} else {
		resp.WriteError(http.StatusInternalServerError, err)
	}
}