add_new_friend_handler.go 866 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package contact
  2. import (
  3. "net/http"
  4. "github.com/zeromicro/go-zero/rest/httpx"
  5. "wechat-api/internal/logic/contact"
  6. "wechat-api/internal/svc"
  7. "wechat-api/internal/types"
  8. )
  9. // swagger:route post /contact/addNewFriend contact AddNewFriend
  10. //
  11. //
  12. //
  13. // Parameters:
  14. // + name: body
  15. // require: true
  16. // in: body
  17. // type: AddNewFriendReq
  18. //
  19. // Responses:
  20. // 200: BaseMsgResp
  21. func AddNewFriendHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  22. return func(w http.ResponseWriter, r *http.Request) {
  23. var req types.AddNewFriendReq
  24. if err := httpx.Parse(r, &req, true); err != nil {
  25. httpx.ErrorCtx(r.Context(), w, err)
  26. return
  27. }
  28. l := contact.NewAddNewFriendLogic(r.Context(), svcCtx)
  29. resp, err := l.AddNewFriend(&req)
  30. if err != nil {
  31. httpx.ErrorCtx(r.Context(), w, err)
  32. } else {
  33. httpx.OkJsonCtx(r.Context(), w, resp)
  34. }
  35. }
  36. }