decode.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package service
  2. import (
  3. "context"
  4. "net/http"
  5. "git.chuangxin1.com/csacred/toolkit/binding"
  6. "git.chuangxin1.com/csacred/toolkit/example/cuser/define"
  7. )
  8. // DecodeGetUserProfileRequest 用户基本信息请求处理
  9. func DecodeGetUserProfileRequest(_ context.Context, r *http.Request) (interface{}, error) {
  10. var request define.FormID
  11. if err := binding.Bind(r, &request); err != nil {
  12. return nil, err
  13. }
  14. return request, nil
  15. }
  16. // DecodeGetUserListRequest 用户列表信息请求处理
  17. func DecodeGetUserListRequest(_ context.Context, r *http.Request) (interface{}, error) {
  18. var request define.FormUser
  19. if err := binding.Bind(r, &request); err != nil {
  20. return nil, err
  21. }
  22. return request, nil
  23. }
  24. // DecodePostUserSignInRequest 用户登录
  25. func DecodePostUserSignInRequest(ctx context.Context, r *http.Request) (interface{}, error) {
  26. var request define.FormUserSignIn
  27. if err := binding.Bind(r, &request); err != nil {
  28. return nil, err
  29. }
  30. return request, nil
  31. }
  32. // DecodePostUserChangePwdRequest 用户修改密码
  33. func DecodePostUserChangePwdRequest(ctx context.Context, r *http.Request) (interface{}, error) {
  34. var request define.FormUserChangePwd
  35. if err := binding.Bind(r, &request); err != nil {
  36. return nil, err
  37. }
  38. return request, nil
  39. }