aiSearch_v1_like_answer.go 623 B

12345678910111213141516171819202122232425
  1. package aiSearch
  2. import (
  3. "aiChat/api/aiSearch/v1"
  4. "app.yhyue.com/moapp/jybase/encrypt"
  5. "context"
  6. "fmt"
  7. "github.com/gogf/gf/v2/frame/g"
  8. )
  9. func (c *ControllerV1) LikeAnswer(ctx context.Context, req *v1.LikeAnswerReq) (res *v1.LikeAnswerRes, err error) {
  10. id := encrypt.SE.Decode4HexByCheck(fmt.Sprint(req.Cid))
  11. r, err := g.Model("ai_search_chat").Data("like", req.Val).Where("id", id).Update()
  12. if err != nil {
  13. g.Log().Error(ctx, "点赞失败:%s", err)
  14. return nil, err
  15. }
  16. affected, _ := r.RowsAffected()
  17. res = &v1.LikeAnswerRes{
  18. ErrorCode: 0,
  19. ErrorMsg: "",
  20. Data: affected,
  21. }
  22. return res, nil
  23. }