test.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package test
  2. import (
  3. // "flag"
  4. "flag"
  5. "github.com/gin-gonic/gin"
  6. log "github.com/sirupsen/logrus"
  7. "kpt.xdmy/apiserver/config"
  8. "kpt.xdmy/apiserver/dao"
  9. "kpt.xdmy/apiserver/routers"
  10. "kpt.xdmy/apiserver/routers/api"
  11. "kpt.xdmy/apiserver/service"
  12. "kpt.xdmy/pkg/logging"
  13. "kpt.xdmy/pkg/setting"
  14. )
  15. var s *service.Service
  16. func Test() {
  17. TestSap()
  18. // logInit()
  19. // EasBatch()
  20. // DataUpdate()
  21. // RepertoryUpdate()
  22. // Sqlx()
  23. // Xorm()
  24. }
  25. func Init() {
  26. var path string
  27. path = "/Users/desire/kptdev/xdmy_mod/cmd/"
  28. flag.Parse()
  29. setting.Setup(path)
  30. dao.Setup()
  31. logging.Setup()
  32. // util.InitWebS(setting.ServerSetting.EasName, setting.ServerSetting.EasPassword, setting.ServerSetting.EasUrl)
  33. logInit()
  34. config.Init(path)
  35. s = service.New(config.Conf)
  36. // routers.SapJobInit(svc)
  37. // RouterInit()
  38. // api.ApiInit(svc)
  39. // routers.Init(svc)
  40. }
  41. func logInit() {
  42. log.SetFormatter(&log.TextFormatter{
  43. DisableColors: true,
  44. // FullTimestamp: true,
  45. })
  46. log.SetLevel(log.DebugLevel)
  47. // log.SetReportCaller(true)
  48. // log.SetOutput(os.Stdout)
  49. // p := new(service.Service)
  50. // log.Warnf("log :%v", p)
  51. }
  52. func RouterInit() {
  53. r := gin.New()
  54. r.Use(gin.Recovery())
  55. r.POST("/auth", api.Auth) // 获取登录token
  56. // apiV1 := r.Group("/authdata")
  57. apiV2 := r.Group("/data")
  58. // apiV1.Use(jwt.JWT()) // token 验证
  59. apiV2.POST("/mcs/record", routers.McsControl)
  60. apiV2.GET("/mcs/accounts", routers.McsAccounts)
  61. apiV2.POST("/ExecDataByConfig", api.ExecDataByConfig)
  62. apiV2.POST("/UpdateDataRelation", api.UpdateDataRelation)
  63. apiV2.POST("/PostDataByName", api.PostDataByName)
  64. apiV2.POST("/GetDataByName", api.GetDataByName)
  65. r.Run(":8082")
  66. }