test.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. TestJob()
  18. // TestSap()
  19. // logInit()
  20. // EasBatch()
  21. // DataUpdate()
  22. // RepertoryUpdate()
  23. // Sqlx()
  24. // Xorm()
  25. }
  26. func TestJob() {
  27. service.SapJobInit()
  28. }
  29. func Init() {
  30. var path string
  31. path = "/Users/desire/kptdev/xdmy_mod/cmd/"
  32. flag.Parse()
  33. setting.Setup(path)
  34. dao.Setup()
  35. logging.Setup()
  36. // util.InitWebS(setting.ServerSetting.EasName, setting.ServerSetting.EasPassword, setting.ServerSetting.EasUrl)
  37. logInit()
  38. config.Init(path)
  39. s = service.New(config.Conf)
  40. // routers.SapJobInit(svc)
  41. // RouterInit()
  42. // api.ApiInit(svc)
  43. // routers.Init(svc)
  44. }
  45. func logInit() {
  46. log.SetFormatter(&log.TextFormatter{
  47. DisableColors: true,
  48. // FullTimestamp: true,
  49. })
  50. log.SetLevel(log.DebugLevel)
  51. // log.SetReportCaller(true)
  52. // log.SetOutput(os.Stdout)
  53. // p := new(service.Service)
  54. // log.Warnf("log :%v", p)
  55. }
  56. func RouterInit() {
  57. r := gin.New()
  58. r.Use(gin.Recovery())
  59. r.POST("/auth", api.Auth) // 获取登录token
  60. // apiV1 := r.Group("/authdata")
  61. apiV2 := r.Group("/data")
  62. // apiV1.Use(jwt.JWT()) // token 验证
  63. apiV2.POST("/mcs/record", routers.McsControl)
  64. apiV2.GET("/mcs/accounts", routers.McsAccounts)
  65. apiV2.POST("/ExecDataByConfig", api.ExecDataByConfig)
  66. apiV2.POST("/UpdateDataRelation", api.UpdateDataRelation)
  67. apiV2.POST("/PostDataByName", api.PostDataByName)
  68. apiV2.POST("/GetDataByName", api.GetDataByName)
  69. r.Run(":8082")
  70. }