delete_ks.go 1.5 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 WrapDeleteauthorizationHandler(ctx *gin.Context) {
  11. handler := newDeleteKsauthorizationHandler(ctx)
  12. BaseRun(handler)
  13. }
  14. type DeleteKsauthorizationHandler struct {
  15. ctx *gin.Context
  16. req *http_model.DeleteKsauthorizationRequest
  17. resp *http_model.CommonResponse
  18. }
  19. func (c DeleteKsauthorizationHandler) getContext() *gin.Context { return c.ctx }
  20. func (c DeleteKsauthorizationHandler) getResponse() interface{} { return c.resp }
  21. func (c DeleteKsauthorizationHandler) getRequest() interface{} {
  22. return c.req
  23. }
  24. func (c DeleteKsauthorizationHandler) run() {
  25. data := http_model.DeleteKsauthorizationRequest{}
  26. data = *c.req
  27. err := db.DeleteKsauthorization(c.ctx, &data)
  28. if err != nil {
  29. logrus.Errorf("[DeleteKsauthorizationHandler] call DeleteKsauthorization err:%+v\n", err)
  30. util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
  31. logrus.Info("DeleteKsauthorizationHandler fail,req:%+v", c.req)
  32. return
  33. }
  34. c.resp.Message = "成功删除授权"
  35. c.resp.Status = consts.ErrorSuccess
  36. }
  37. func (c DeleteKsauthorizationHandler) checkParam() error {
  38. return nil
  39. }
  40. func newDeleteKsauthorizationHandler(ctx *gin.Context) *DeleteKsauthorizationHandler {
  41. return &DeleteKsauthorizationHandler{
  42. ctx: ctx,
  43. req: http_model.NewDeleteKsauthorizationRequest(),
  44. resp: http_model.NewDeleteKsauthorizationResponse(),
  45. }
  46. }