stop_subaccount.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. s.resp.Status = consts.ErrorSuccess
  41. }
  42. func (s StopSubAccountHandler) checkParam() error {
  43. return nil
  44. }
  45. func newStopSubAccount(ctx *gin.Context) *StopSubAccountHandler {
  46. return &StopSubAccountHandler{
  47. ctx: ctx,
  48. req: http_model.NewStopSubAccountRequest(),
  49. resp: http_model.NewStopSubAccountResponse(),
  50. }
  51. }