evaluate.go 795 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package controller
  2. import (
  3. v1 "aiChat/api/v1"
  4. "aiChat/internal/model"
  5. "aiChat/utility"
  6. "app.yhyue.com/moapp/jybase/encrypt"
  7. "github.com/gogf/gf/v2/net/ghttp"
  8. )
  9. // Evaluate 点评问答
  10. func Evaluate(r *ghttp.Request) {
  11. final := func() (res v1.CommonRes) {
  12. session, _ := utility.GetSession(r)
  13. if session.AccountId == 0 {
  14. res.ErrorCode = -1
  15. res.ErrorMsg = "未登陆"
  16. return
  17. }
  18. evaluate := r.Get("Evaluate").Int()
  19. id := encrypt.SE.Decode4Hex(r.Get("MessageId").String())
  20. if id == "" {
  21. res.ErrorCode = -1
  22. res.ErrorMsg = "未找到记录"
  23. return
  24. }
  25. err := model.Message.Evaluate(session.AccountId, id, evaluate)
  26. if err != nil {
  27. res.ErrorCode = -1
  28. res.ErrorMsg = "评价异常"
  29. return
  30. }
  31. res.Data = true
  32. return
  33. }()
  34. r.Response.Write(final)
  35. }