main.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * @description:
  3. * @Author: CP
  4. * @Date: 2020-08-23 21:32:48
  5. * @FilePath: \construction_management\web\main.go
  6. */
  7. package main
  8. import (
  9. "fmt"
  10. "go.mod/bootstrap"
  11. "go.mod/web/middleware/identity"
  12. "go.mod/web/routes"
  13. "go.mod/web/utils"
  14. //_ "go.mod/web/docs"
  15. "github.com/iris-contrib/swagger/v12" // swagger middleware for Iris
  16. "github.com/iris-contrib/swagger/v12/swaggerFiles" // swagger embed files
  17. )
  18. func newApp() *bootstrap.Bootstrapper {
  19. app := bootstrap.New("工程建设项目系统", "纵横软件")
  20. app.Bootstrap()
  21. app.Configure(identity.Configure, routes.Configure)
  22. return app
  23. }
  24. // @title 工程项目管理系统 API
  25. // @version 1.0
  26. // @description 工程项目管理系统-接口
  27. // @securityDefinitions.apikey ApiKeyAuth
  28. // @in header
  29. // @name X-CSRF-Token
  30. func main() {
  31. // 服务器集群的时候才需要区分这项设置
  32. // 比如:根据服务器的IP、名称、端口号等,或者运行的参数
  33. // if port == 6060 {
  34. // conf.RunningCrontabService = true
  35. // }
  36. app := newApp()
  37. // api接口文档配置
  38. config := &swagger.Config{
  39. URL: "http://localhost:6060/docs/swagger.json", //The url pointing to API definition
  40. }
  41. app.Get("/swagger/{any:path}", swagger.CustomWrapHandler(config, swaggerFiles.Handler))
  42. // 由于新的项目管理服务器的数据库访问权限的问题,这里docker使用了host模式,启动端口需要区分
  43. var port = 6070
  44. debug := utils.GetEnvInfo("DEBUG")
  45. if debug == "uat" {
  46. port = 6060
  47. } else if debug == "qa" || debug == "mbp" {
  48. port = 6060
  49. }
  50. app.Listen(fmt.Sprintf(":%d", port))
  51. }