test.go 1.7 KB

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