智慧食堂
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

hdl_suggested_feedback.go 4.0 KiB

10 mesi fa
10 mesi fa
10 mesi fa
10 mesi fa
10 mesi fa
10 mesi fa
10 mesi fa
10 mesi fa
10 mesi fa
10 mesi fa
10 mesi fa
10 mesi fa
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. package hdl
  2. import (
  3. enum2 "applet/app/admin/enum"
  4. "applet/app/admin/lib/validate"
  5. "applet/app/admin/md"
  6. "applet/app/admin/svc"
  7. "applet/app/db"
  8. "applet/app/e"
  9. "github.com/gin-gonic/gin"
  10. "time"
  11. )
  12. func SuggestedFeedbackList(c *gin.Context) {
  13. var req md.SuggestedFeedbackListReq
  14. err := c.ShouldBindJSON(&req)
  15. if err != nil {
  16. err = validate.HandleValidateErr(err)
  17. err1 := err.(e.E)
  18. e.OutErr(c, err1.Code, err1.Error())
  19. return
  20. }
  21. sess := db.Db.Desc("suggested_feedback.id")
  22. if req.StartCreateAt != "" {
  23. sess.And("suggested_feedback.create_at >= ?", req.StartCreateAt)
  24. }
  25. if req.EndCreateAt != "" {
  26. sess.And("suggested_feedback.create_at <= ?", req.EndCreateAt)
  27. }
  28. if req.State == 1 {
  29. sess.And("suggested_feedback.reply_date !=\"\" ")
  30. }
  31. if req.State == 2 {
  32. sess.And("suggested_feedback.reply_date =\"\" ")
  33. }
  34. if req.Name != "" {
  35. sess.And("user_identity.name like ?", "%"+req.Name+"%")
  36. }
  37. if req.Phone != "" {
  38. sess.And("user.phone like ?", "%"+req.Phone+"%")
  39. }
  40. admin := svc.GetUser(c)
  41. if admin.IsSuperAdministrator != enum2.IsSuperAdministratorTure {
  42. adminWithEnterpriseDb := db.AdminWithEnterpriseDb{}
  43. adminWithEnterpriseDb.Set()
  44. adminWithEnterprise, err1 := adminWithEnterpriseDb.FindAdminWithEnterprise(admin.AdmId)
  45. if err1 != nil {
  46. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  47. return
  48. }
  49. var enterPriseIds []int
  50. for _, v1 := range *adminWithEnterprise {
  51. enterPriseIds = append(enterPriseIds, v1.EnterpriseId)
  52. }
  53. if len(enterPriseIds) == 0 {
  54. return
  55. }
  56. sess.In("suggested_feedback.enterprise_id", enterPriseIds)
  57. }
  58. var m []*db.SuggestedFeedbackWithUserIdentity
  59. count, err := sess.
  60. Join("LEFT", "user_identity", "suggested_feedback.user_identity_id = user_identity.id").
  61. Join("LEFT", "enterprise", "enterprise.id = user_identity.enterprise_id").
  62. Join("LEFT", "user", "user.id = user_identity.uid").
  63. Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m)
  64. if err != nil {
  65. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  66. return
  67. }
  68. var resp []md.SuggestedFeedbackListResp
  69. for _, v := range m {
  70. kind := 2
  71. if v.SuggestedFeedback.ReplyDate != "" {
  72. kind = 1
  73. }
  74. resp = append(resp, md.SuggestedFeedbackListResp{
  75. Id: v.SuggestedFeedback.Id,
  76. EnterpriseId: v.Enterprise.Id,
  77. EnterpriseName: v.Enterprise.Name,
  78. Uid: v.User.Id,
  79. UserIdentityId: v.UserIdentity.Id,
  80. UserIdentityKind: v.UserIdentity.Kind,
  81. UserIdentityName: v.UserIdentity.Name,
  82. Phone: v.User.Phone,
  83. Nickname: v.User.Nickname,
  84. Content: v.SuggestedFeedback.Content,
  85. Kind: kind,
  86. ReplyContent: v.SuggestedFeedback.ReplyContent,
  87. ReplyDate: v.SuggestedFeedback.ReplyDate,
  88. CreateAt: v.SuggestedFeedback.CreateAt,
  89. UpdateAt: v.SuggestedFeedback.UpdateAt,
  90. })
  91. }
  92. e.OutSuc(c, map[string]interface{}{
  93. "list": resp,
  94. "total": count,
  95. "kind_list": []map[string]interface{}{
  96. {
  97. "name": "已回复",
  98. "value": 1,
  99. },
  100. {
  101. "name": "未回复",
  102. "value": 2,
  103. },
  104. },
  105. }, nil)
  106. return
  107. }
  108. func SuggestedFeedbackReply(c *gin.Context) {
  109. var req md.ReplySuggestedFeedbackReq
  110. err := c.ShouldBindJSON(&req)
  111. if err != nil {
  112. err = validate.HandleValidateErr(err)
  113. err1 := err.(e.E)
  114. e.OutErr(c, err1.Code, err1.Error())
  115. return
  116. }
  117. suggestedFeedbackDb := db.SuggestedFeedbackDb{}
  118. suggestedFeedbackDb.Set()
  119. suggestedFeedback, err := suggestedFeedbackDb.GetSuggestedFeedback(req.Id)
  120. if err != nil {
  121. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  122. return
  123. }
  124. if suggestedFeedback == nil {
  125. e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
  126. return
  127. }
  128. now := time.Now()
  129. suggestedFeedback.ReplyContent = req.ReplyContent
  130. suggestedFeedback.ReplyDate = now.Format("2006-01-02 15:04:05")
  131. suggestedFeedback.UpdateAt = now.Format("2006-01-02 15:04:05")
  132. _, err = suggestedFeedbackDb.SuggestedFeedbackUpdate(suggestedFeedback, "reply_date", "reply_content", "update_at")
  133. if err != nil {
  134. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  135. return
  136. }
  137. e.OutSuc(c, "success", nil)
  138. return
  139. }