test.go 1.6 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. // 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. }