stop_subaccount.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 WrapStopSubAccountHandler(ctx *gin.Context) {
  11. handler := newStopSubAccount(ctx)
  12. BaseRun(handler)
  13. }
  14. type StopSubAccountHandler struct {
  15. ctx *gin.Context
  16. req *http_model.StopSubAccountRequest
  17. resp *http_model.CommonResponse
  18. }
  19. func (s StopSubAccountHandler) getContext() *gin.Context {
  20. return s.ctx
  21. }
  22. func (s StopSubAccountHandler) getResponse() interface{} {
  23. return s.resp
  24. }
  25. func (s StopSubAccountHandler) getRequest() interface{} {
  26. return s.req
  27. }
  28. func (s StopSubAccountHandler) run() {
  29. data := http_model.StopSubAccountRequest{}
  30. data = *s.req
  31. res, err := db.StopSubAccount(s.ctx, &data)
  32. if err != nil {
  33. logrus.Errorf("[StopSubAccountHandler] call StopSubAccount err:%+v\n", err)
  34. util.HandlerPackErrorResp(s.resp, consts.ErrorInternal, "")
  35. logrus.Info("StopSubAccountHandler fail,req:%+v", s.req)
  36. return
  37. }
  38. s.resp.Message = "成功停用岗位"
  39. s.resp.Data = res
  40. }
  41. func (s StopSubAccountHandler) checkParam() error {
  42. return nil
  43. }
  44. func newStopSubAccount(ctx *gin.Context) *StopSubAccountHandler {
  45. return &StopSubAccountHandler{
  46. ctx: ctx,
  47. req: http_model.NewStopSubAccountRequest(),
  48. resp: http_model.NewStopSubAccountResponse(),
  49. }
  50. }