get_employee_search_handler.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package employee
  2. import (
  3. "net/http"
  4. jwtutils "wechat-api/internal/utils/jwt"
  5. "github.com/zeromicro/go-zero/rest/httpx"
  6. "wechat-api/internal/logic/employee"
  7. "wechat-api/internal/svc"
  8. "wechat-api/internal/types"
  9. )
  10. // swagger:route post /employee/search employee GetEmployeeSearch
  11. //
  12. // Get employee list | 获取Employee列表
  13. //
  14. // Get employee list | 获取Employee列表
  15. //
  16. // Parameters:
  17. // + name: body
  18. // require: true
  19. // in: body
  20. // type: EmployeeListReq
  21. //
  22. // Responses:
  23. // 200: EmployeeListResp
  24. func GetEmployeeSearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  25. return func(w http.ResponseWriter, r *http.Request) {
  26. var req types.EmployeeListReq
  27. if err := httpx.Parse(r, &req, true); err != nil {
  28. httpx.ErrorCtx(r.Context(), w, err)
  29. return
  30. }
  31. tokenStr := jwtutils.StripBearerPrefixFromToken(r.Header.Get("Authorization"))
  32. l := employee.NewGetEmployeeSearchLogic(r.Context(), svcCtx)
  33. resp, err := l.GetEmployeeSearch(&req, tokenStr)
  34. if err != nil {
  35. httpx.ErrorCtx(r.Context(), w, err)
  36. } else {
  37. httpx.OkJsonCtx(r.Context(), w, resp)
  38. }
  39. }
  40. }