示例#1
0
//创建一个投诉的回复
func (cpr *ComplaintReplytor) CreateComplaintReply(mapComplainReply map[string]interface{}, user *models.User) (replyId, jobId uint, err error) {

	defer func() {
		if err != nil {
			utils.GetLog().Error("services.complainReply.Create : error : %s, ", err.Error())
		} else {
			utils.GetLog().Debug("services.complainReply.Create : debug : mapComplainReply=%s", utils.Sdump(mapComplainReply))
		}
	}()
	var complainReply models.JobComplaintReply
	complainReply.Message = mapComplainReply["Desc"].(string)

	var complainId uint
	switch v := mapComplainReply["Complain_id"].(type) {
	case int:
		complainId = uint(v)
	case string:
		tmp, _ := strconv.Atoi(v)
		complainId = uint(tmp)
	}
	filter := make(map[string]interface{})
	filter["Id"] = complainId
	complians, _ := GetOneComplain(filter)
	complainReply.Complaint = &models.JobComplaint{Id: complainId}
	complainReply.User = user

	cpr.complain = *complians
	var repId int64
	repId, err = models.GetDB().Insert(&complainReply)

	if err != nil {
		utils.GetLog().Debug("services.complianReply.Create : debug : job=%s", utils.Sdump(complainReply))
		return
	}
	replyId = uint(repId)
	jobId = uint(complians.Job.Id)
	return
}
示例#2
0
func (cpr ComplaintReplytor) GetTableName() string {
	j := models.JobComplaintReply{}
	return j.TableName()
}