kuaishouauthorization.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package handler
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/sirupsen/logrus"
  5. "youngee_m_api/consts"
  6. "youngee_m_api/db"
  7. "youngee_m_api/model/http_model"
  8. "youngee_m_api/util"
  9. )
  10. func WrapAuthkuaishouHandler(ctx *gin.Context) {
  11. handler := newAuthkuaishouHandler(ctx)
  12. BaseRun(handler)
  13. }
  14. type AuthkuaishouHandler struct {
  15. ctx *gin.Context
  16. req *http_model.AuthkuaishouRequest
  17. resp *http_model.CommonResponse
  18. }
  19. func (c AuthkuaishouHandler) getContext() *gin.Context { return c.ctx }
  20. func (c AuthkuaishouHandler) getResponse() interface{} { return c.resp }
  21. func (c AuthkuaishouHandler) getRequest() interface{} {
  22. return c.req
  23. }
  24. func (c AuthkuaishouHandler) run() {
  25. data := http_model.AuthkuaishouRequest{}
  26. data = *c.req
  27. err := db.Authkuaishou(c.ctx, &data)
  28. if err != nil {
  29. logrus.Errorf("[AuthkuaishouHandler] call Authkuaishou err:%+v\n", err)
  30. util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
  31. logrus.Info("AuthkuaishouHandler fail,req:%+v", c.req)
  32. return
  33. }
  34. c.resp.Message = "成功创建授权账号"
  35. }
  36. func (c AuthkuaishouHandler) checkParam() error {
  37. return nil
  38. }
  39. func newAuthkuaishouHandler(ctx *gin.Context) *AuthkuaishouHandler {
  40. return &AuthkuaishouHandler{
  41. ctx: ctx,
  42. req: http_model.NewAuthkuaishouRequest(),
  43. resp: http_model.NewAuthkuaishouResponse(),
  44. }
  45. }