test.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. DataBatch()
  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. // RouterInit()
  41. // api.ApiInit(svc)
  42. // routers.Init(svc)
  43. }
  44. func logInit() {
  45. log.SetFormatter(&log.TextFormatter{
  46. DisableColors: true,
  47. // FullTimestamp: true,
  48. })
  49. log.SetLevel(log.DebugLevel)
  50. // log.SetReportCaller(true)
  51. // log.SetOutput(os.Stdout)
  52. // p := new(service.Service)
  53. // log.Warnf("log :%v", p)
  54. }
  55. func RouterInit() {
  56. r := gin.New()
  57. r.Use(gin.Recovery())
  58. r.POST("/auth", api.Auth) // 获取登录token
  59. // apiV1 := r.Group("/authdata")
  60. apiV2 := r.Group("/data")
  61. // apiV1.Use(jwt.JWT()) // token 验证
  62. apiV2.POST("/mcs/record", routers.McsControl)
  63. apiV2.GET("/mcs/accounts", routers.McsAccounts)
  64. apiV2.POST("/ExecDataByConfig", api.ExecDataByConfig)
  65. apiV2.POST("/UpdateDataRelation", api.UpdateDataRelation)
  66. apiV2.POST("/PostDataByName", api.PostDataByName)
  67. apiV2.POST("/GetDataByName", api.GetDataByName)
  68. r.Run(":8082")
  69. }