delete_account.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 WrapDeleteAccountHandler(ctx *gin.Context) {
  11. handler := newDeleteAccountHandler(ctx)
  12. BaseRun(handler)
  13. }
  14. type DeleteAccount struct {
  15. ctx *gin.Context
  16. req *http_model.DeleteAccountRequest
  17. resp *http_model.CommonResponse
  18. }
  19. func (d DeleteAccount) getContext() *gin.Context {
  20. return d.ctx
  21. }
  22. func (d DeleteAccount) getResponse() interface{} {
  23. return d.resp
  24. }
  25. func (d DeleteAccount) getRequest() interface{} {
  26. return d.req
  27. }
  28. func (d DeleteAccount) run() {
  29. err := db.DeleteAccount(d.ctx, d.req.PlatformID, d.req.PlatformNickname, d.req.TalentId)
  30. if err != nil {
  31. logrus.Errorf("[DeleteAccountHandler] call Delete err:%+v\n", err)
  32. util.HandlerPackErrorResp(d.resp, consts.ErrorInternal, "")
  33. logrus.Info("DeleteAccount fail,req:%+v", d.req)
  34. return
  35. }
  36. d.resp.Message = "解绑成功"
  37. }
  38. func (d DeleteAccount) checkParam() error {
  39. return nil
  40. }
  41. func newDeleteAccountHandler(ctx *gin.Context) *DeleteAccount {
  42. return &DeleteAccount{
  43. ctx: ctx,
  44. req: http_model.NewDeleteAccountRequest(),
  45. resp: http_model.NewDeleteAccountResponse(),
  46. }
  47. }