repair.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package frontc
  2. import(
  3. "wuyebaoxiuapi/models/frontm"
  4. )
  5. type RepairController struct {
  6. BaseController
  7. }
  8. // 用户报修
  9. func (this *RepairController)Repair() {
  10. this.Prepare()
  11. repair := new(frontm.Repair)
  12. image := this.GetString("image")
  13. repair.School = this.GetString("school")
  14. repair.Position = this.GetString("position")
  15. repair.ApplicantName = this.GetString("applicant_name")
  16. repair.ApplicantPhone = this.GetString("applicant_phone")
  17. repair.ApplicantContent = this.GetString("applicant_content")
  18. repair.Address = this.GetString("address")
  19. repair.ApplicantUserId = this.userInfo.Id
  20. repair.Status = 1
  21. if image == "" {
  22. this.ajaxMsg(MSG_ERR,"请上传图片",nil)
  23. }
  24. if repair.School == "" {
  25. this.ajaxMsg(MSG_ERR,"请填写学校",nil)
  26. }
  27. if repair.Position == "" {
  28. this.ajaxMsg(MSG_ERR,"请填写位置",nil)
  29. }
  30. if repair.ApplicantName == "" {
  31. this.ajaxMsg(MSG_ERR,"请填写保修人的姓名",nil)
  32. }
  33. if repair.ApplicantPhone == "" {
  34. this.ajaxMsg(MSG_ERR,"请填写联系电话",nil)
  35. }
  36. //if false == libs.Validate().IsPhone(repair.ApplicantPhone){
  37. // this.ajaxMsg(MSG_ERR,"请填写正确的联系电话",nil)
  38. //}
  39. id,err := frontm.RepairAdd(repair)
  40. if err != nil {
  41. this.ajaxMsg(MSG_ERR,"系统繁忙,请稍后再试。",nil)
  42. }
  43. data := make(map[string]interface{})
  44. data["image"] = image
  45. data["repairId"] = id
  46. this.addPicture(data)
  47. this.ajaxMsg(MSG_OK,"报修成功",nil)
  48. }