control.go 835 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package controller
  2. import (
  3. "ElectronicInvoice/internal/service"
  4. "github.com/gogf/gf/v2/errors/gerror"
  5. "github.com/gogf/gf/v2/frame/g"
  6. "github.com/gogf/gf/v2/net/ghttp"
  7. )
  8. func Control(r *ghttp.Request) {
  9. err := func() error {
  10. switch r.Get("t").String() {
  11. case "mvc": //Mobile verification code 验证码操作
  12. code := r.Get("code").String()
  13. if code == "clear" {
  14. return service.JyInvoiceManager.MobileVerificationClear()
  15. } else {
  16. return service.JyInvoiceManager.MobileVerificationCode(code)
  17. }
  18. case "run": //控制程序暂停
  19. g.Log().Infof(r.Context(), "runing")
  20. default:
  21. return gerror.New("未知操作")
  22. }
  23. return nil
  24. }()
  25. if err != nil {
  26. r.Response.WriteJson(g.Map{
  27. "flag": "fail",
  28. "err": err.Error(),
  29. })
  30. } else {
  31. r.Response.WriteJson(g.Map{
  32. "flag": "success",
  33. })
  34. }
  35. }