xueshaojie 2 سال پیش
والد
کامیت
f12a4ab282
52فایلهای تغییر یافته به همراه35 افزوده شده و 135 حذف شده
  1. 7 7
      .idea/workspace.xml
  2. BIN
      base-gin
  3. 1 21
      conf/conf.go
  4. 0 25
      conf/conf.yaml
  5. 2 2
      controller/getConfig.go
  6. 2 2
      controller/productdefinition.go
  7. 2 1
      go.mod
  8. 2 0
      go.sum
  9. 0 20
      helpers/elastic.go
  10. 3 3
      helpers/mysql.go
  11. 0 15
      helpers/nsq.go
  12. 0 26
      helpers/redis.go
  13. 4 4
      main.go
  14. 1 1
      model/config.go
  15. 0 0
      pkg/gorm/License
  16. 0 0
      pkg/gorm/README.md
  17. 0 0
      pkg/gorm/association.go
  18. 0 0
      pkg/gorm/callback.go
  19. 0 0
      pkg/gorm/callback_create.go
  20. 0 0
      pkg/gorm/callback_delete.go
  21. 0 0
      pkg/gorm/callback_query.go
  22. 0 0
      pkg/gorm/callback_query_preload.go
  23. 0 0
      pkg/gorm/callback_row_query.go
  24. 0 0
      pkg/gorm/callback_save.go
  25. 0 0
      pkg/gorm/callback_update.go
  26. 0 0
      pkg/gorm/dialect.go
  27. 0 0
      pkg/gorm/dialect_common.go
  28. 0 0
      pkg/gorm/dialect_mysql.go
  29. 0 0
      pkg/gorm/dialect_postgres.go
  30. 0 0
      pkg/gorm/dialect_sqlite3.go
  31. 0 0
      pkg/gorm/docker-compose.yml
  32. 0 0
      pkg/gorm/errors.go
  33. 0 0
      pkg/gorm/field.go
  34. 0 0
      pkg/gorm/interface.go
  35. 0 0
      pkg/gorm/join_table_handler.go
  36. 0 0
      pkg/gorm/logger.go
  37. 0 0
      pkg/gorm/main.go
  38. 0 0
      pkg/gorm/model.go
  39. 0 0
      pkg/gorm/model_struct.go
  40. 0 0
      pkg/gorm/naming.go
  41. 0 0
      pkg/gorm/scope.go
  42. 0 0
      pkg/gorm/search.go
  43. 0 0
      pkg/gorm/test_all.sh
  44. 0 0
      pkg/gorm/utils.go
  45. 0 0
      pkg/gorm/wercker.yml
  46. 1 1
      router/http.go
  47. 1 1
      service/testGet.go
  48. 1 1
      utils/base/mysql.go
  49. 3 3
      utils/bootstrap.go
  50. 1 1
      utils/middleware/logger.go
  51. 1 1
      utils/middleware/tracer.go
  52. 3 0
      vendor/modules.txt

+ 7 - 7
.idea/workspace.xml

@@ -1201,7 +1201,7 @@
       <recent name="$PROJECT_DIR$/utils/base" />
     </key>
   </component>
-  <component name="RunManager" selected="Go Build.go build github.com/product-definition (1)">
+  <component name="RunManager" selected="Go Build.go build base-gin (1)">
     <configuration default="true" type="GoApplicationRunConfiguration" factoryName="Go Application">
       <module name="product-definition" />
       <working_directory value="$PROJECT_DIR$" />
@@ -1210,7 +1210,7 @@
       <output_directory value="$PROJECT_DIR$/../../../pkg" />
       <method v="2" />
     </configuration>
-    <configuration name="go build github.com/product-definition (1)" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
+    <configuration name="go build base-gin (1)" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
       <module name="product-definition" />
       <working_directory value="$PROJECT_DIR$" />
       <kind value="FILE" />
@@ -1219,7 +1219,7 @@
       <output_directory value="$PROJECT_DIR$/../../../pkg" />
       <method v="2" />
     </configuration>
-    <configuration name="go build github.com/product-definition" type="GoApplicationRunConfiguration" factoryName="Go Application" nameIsGenerated="true">
+    <configuration name="go build base-gin" type="GoApplicationRunConfiguration" factoryName="Go Application" nameIsGenerated="true">
       <module name="product-definition" />
       <working_directory value="$PROJECT_DIR$" />
       <kind value="DIRECTORY" />
@@ -1229,7 +1229,7 @@
     </configuration>
     <recent_temporary>
       <list>
-        <item itemvalue="Go Build.go build github.com/product-definition (1)" />
+        <item itemvalue="Go Build.go build base-gin (1)" />
       </list>
     </recent_temporary>
   </component>
@@ -1256,11 +1256,11 @@
       <screen x="0" y="25" width="1440" height="801" />
     </state>
     <state x="422" y="54" key="#go_build_/0.25.1440.801@0.25.1440.801" timestamp="1657612831265" />
-    <state x="422" y="61" key="#go_build_github.com/product-definition_(1)" timestamp="1657680872111">
+    <state x="422" y="61" key="#go_build_base-gin_(1)" timestamp="1657680872111">
       <screen x="0" y="25" width="1440" height="801" />
     </state>
-    <state x="422" y="61" key="#go_build_github.com/product-definition_(1)/0.25.1440.801@0.25.1440.801" timestamp="1657680872111" />
-    <state x="422" y="61" key="#go_build_github.com/product-definition_(1)/0.25.1440.804@0.25.1440.804" timestamp="1657678273392" />
+    <state x="422" y="61" key="#go_build_base-gin_(1)/0.25.1440.801@0.25.1440.801" timestamp="1657680872111" />
+    <state x="422" y="61" key="#go_build_base-gin_(1)/0.25.1440.804@0.25.1440.804" timestamp="1657678273392" />
     <state width="555" height="617" key="DebuggerActiveHint" timestamp="1657787027001">
       <screen x="0" y="25" width="1440" height="794" />
     </state>

BIN
base-gin


+ 1 - 21
conf/conf.go

@@ -1,7 +1,7 @@
 package conf
 
 import (
-	"github.com/product-definition/utils/base"
+	"base-gin/utils/base"
 	"gopkg.in/yaml.v2"
 	"io/ioutil"
 	"path"
@@ -12,9 +12,6 @@ import (
 
 type TConf struct {
 	LogLevel string `yaml:"loglevel"`
-	Redis    struct {
-		Addr string `yaml:"addr"`
-	}
 	Mysql struct {
 		Addr         string `yaml:"addr"`
 		User         string `yaml:"user"`
@@ -23,23 +20,6 @@ type TConf struct {
 		MaxIdleConns int    `yaml:"maxidleconns"`
 		MaxOpenConns int    `yaml:"maxopenconns"`
 	}
-	Port string
-	Nsq  struct {
-		Addr        string `yaml:"addr"`
-		MaxAttempts uint16 `yaml:"maxAttempts"`
-	}
-	Task struct {
-		StationTaskCron   string `yaml:"stationTaskCron"`
-		EmptyOffTaskCron  string `yaml:"emptyOffTaskCron"`
-		InvertBoxTaskCron string `yaml:"invertBoxTaskCron"`
-	}
-	Warehouse struct {
-	}
-	Elastic struct {
-		Addr string
-		User string
-		Pass string
-	}
 }
 
 var Conf TConf

+ 0 - 25
conf/conf.yaml

@@ -1,9 +1,5 @@
 loglevel: info
 
-redis:
-  addr: 39.107.60.244:6379
-
-
 mysql:
   addr: 127.0.0.1:3306
   user: root
@@ -11,24 +7,3 @@ mysql:
   database: pms
   maxidleconns: 10
   maxopenconns: 100
-
-
-port: 8081
-
-nsq:
-  addr: 39.107.60.244:4150
-  maxAttempts: 5
-
-task:
-  stationTaskCron: "@every 10s"
-  emptyOffTaskCron: "0 0 10-20 * * ?"
-  invertBoxTaskCron: "@every 60s"
-
-warehouse:
-
-
-elastic:
-  addr: http://39.107.60.244:9200
-  user:
-  pass:
-

+ 2 - 2
controller/getConfig.go

@@ -2,8 +2,8 @@ package controller
 
 import (
 	"github.com/gin-gonic/gin"
-	"github.com/product-definition/service"
-	"github.com/product-definition/utils/base"
+	"base-gin/service"
+	"base-gin/utils/base"
 )
 
 type ConfigParam struct {

+ 2 - 2
controller/productdefinition.go

@@ -3,8 +3,8 @@ package controller
 import (
 	"fmt"
 	"github.com/gin-gonic/gin"
-	"github.com/product-definition/service"
-	"github.com/product-definition/utils/base"
+	"base-gin/service"
+	"base-gin/utils/base"
 )
 
 type Param struct {

+ 2 - 1
go.mod

@@ -1,4 +1,4 @@
-module github.com/product-definition
+module base-gin
 
 go 1.17
 
@@ -6,6 +6,7 @@ require (
 	github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6
 	github.com/gin-gonic/gin v1.8.1
 	github.com/go-sql-driver/mysql v1.6.0
+	github.com/jinzhu/inflection v1.0.0
 	github.com/opentracing/opentracing-go v1.2.0
 	github.com/pkg/errors v0.9.1
 	github.com/sirupsen/logrus v1.8.1

+ 2 - 0
go.sum

@@ -35,6 +35,8 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
 github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
 github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
+github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
+github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
 github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
 github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
 github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=

+ 0 - 20
helpers/elastic.go

@@ -1,20 +0,0 @@
-package helpers
-//
-//import (
-//	"git-pd.megvii-inc.com/slg-service/pms/conf"
-//	"git-pd.megvii-inc.com/srgbase/goframework/base"
-//)
-//
-//var ElasticClient *base.ElasticClient
-//
-//func init() {
-//	var err error
-//	ElasticClient, err = base.NewElasticClient(base.ElasticClientConfig{
-//		Addr:     conf.Conf.Elastic.Addr,
-//		User:     conf.Conf.Elastic.User,
-//		Password: conf.Conf.Elastic.Pass,
-//	})
-//	if err != nil {
-//		base.PanicLogger(nil, err)
-//	}
-//}

+ 3 - 3
helpers/mysql.go

@@ -1,9 +1,9 @@
 package helpers
 
 import (
-	"github.com/product-definition/conf"
-	"github.com/product-definition/utils/base"
-	"gorm"
+	"base-gin/conf"
+	"base-gin/utils/base"
+	"base-gin/pkg/gorm"
 	"time"
 )
 

+ 0 - 15
helpers/nsq.go

@@ -1,15 +0,0 @@
-package helpers
-//
-//import (
-//	"git-pd.megvii-inc.com/slg-service/pms/conf"
-//	"git-pd.megvii-inc.com/slg-service/pms/mq"
-//	"git-pd.megvii-inc.com/srgbase/goframework/base"
-//)
-//
-//var (
-//	PushMsgNsqClient *base.NsqClient
-//)
-//
-//func InitNsq() {
-//	PushMsgNsqClient = base.NewNsqClient(conf.Conf.Nsq.Addr, mq.TopicNamePmsPushMsg)
-//}

+ 0 - 26
helpers/redis.go

@@ -1,26 +0,0 @@
-package helpers
-//
-//import (
-//	"git-pd.megvii-inc.com/slg-service/pms/conf"
-//	"git-pd.megvii-inc.com/srgbase/goframework/base"
-//	"github.com/go-redis/redis"
-//	"time"
-//)
-//
-//var RedisClient *redis.Client
-//
-//func init() {
-//	RedisClient = redis.NewClient(&redis.Options{
-//		Addr:         conf.Conf.Redis.Addr,
-//		DialTimeout:  10 * time.Second,
-//		ReadTimeout:  30 * time.Second,
-//		WriteTimeout: 30 * time.Second,
-//		PoolSize:     100,
-//		PoolTimeout:  30 * time.Second,
-//	})
-//
-//	_, err := RedisClient.Ping().Result()
-//	if err != nil {
-//		base.PanicfLogger(nil, "redis connect error: %v", err)
-//	}
-//}

+ 4 - 4
main.go

@@ -4,10 +4,10 @@ import (
 	"fmt"
 	"github.com/fvbock/endless"
 	"github.com/gin-gonic/gin"
-	"github.com/product-definition/conf"
-	"github.com/product-definition/helpers"
-	"github.com/product-definition/router"
-	"github.com/product-definition/utils"
+	"base-gin/conf"
+	"base-gin/helpers"
+	"base-gin/router"
+	"base-gin/utils"
 )
 func main()  {
 	r := gin.New()

+ 1 - 1
model/config.go

@@ -2,7 +2,7 @@ package models
 
 import (
 	"github.com/gin-gonic/gin"
-	"github.com/product-definition/helpers"
+	"base-gin/helpers"
 )
 
 type Config struct {

+ 0 - 0
vendor/gorm/License → pkg/gorm/License


+ 0 - 0
vendor/gorm/README.md → pkg/gorm/README.md


+ 0 - 0
vendor/gorm/association.go → pkg/gorm/association.go


+ 0 - 0
vendor/gorm/callback.go → pkg/gorm/callback.go


+ 0 - 0
vendor/gorm/callback_create.go → pkg/gorm/callback_create.go


+ 0 - 0
vendor/gorm/callback_delete.go → pkg/gorm/callback_delete.go


+ 0 - 0
vendor/gorm/callback_query.go → pkg/gorm/callback_query.go


+ 0 - 0
vendor/gorm/callback_query_preload.go → pkg/gorm/callback_query_preload.go


+ 0 - 0
vendor/gorm/callback_row_query.go → pkg/gorm/callback_row_query.go


+ 0 - 0
vendor/gorm/callback_save.go → pkg/gorm/callback_save.go


+ 0 - 0
vendor/gorm/callback_update.go → pkg/gorm/callback_update.go


+ 0 - 0
vendor/gorm/dialect.go → pkg/gorm/dialect.go


+ 0 - 0
vendor/gorm/dialect_common.go → pkg/gorm/dialect_common.go


+ 0 - 0
vendor/gorm/dialect_mysql.go → pkg/gorm/dialect_mysql.go


+ 0 - 0
vendor/gorm/dialect_postgres.go → pkg/gorm/dialect_postgres.go


+ 0 - 0
vendor/gorm/dialect_sqlite3.go → pkg/gorm/dialect_sqlite3.go


+ 0 - 0
vendor/gorm/docker-compose.yml → pkg/gorm/docker-compose.yml


+ 0 - 0
vendor/gorm/errors.go → pkg/gorm/errors.go


+ 0 - 0
vendor/gorm/field.go → pkg/gorm/field.go


+ 0 - 0
vendor/gorm/interface.go → pkg/gorm/interface.go


+ 0 - 0
vendor/gorm/join_table_handler.go → pkg/gorm/join_table_handler.go


+ 0 - 0
vendor/gorm/logger.go → pkg/gorm/logger.go


+ 0 - 0
vendor/gorm/main.go → pkg/gorm/main.go


+ 0 - 0
vendor/gorm/model.go → pkg/gorm/model.go


+ 0 - 0
vendor/gorm/model_struct.go → pkg/gorm/model_struct.go


+ 0 - 0
vendor/gorm/naming.go → pkg/gorm/naming.go


+ 0 - 0
vendor/gorm/scope.go → pkg/gorm/scope.go


+ 0 - 0
vendor/gorm/search.go → pkg/gorm/search.go


+ 0 - 0
vendor/gorm/test_all.sh → pkg/gorm/test_all.sh


+ 0 - 0
vendor/gorm/utils.go → pkg/gorm/utils.go


+ 0 - 0
vendor/gorm/wercker.yml → pkg/gorm/wercker.yml


+ 1 - 1
router/http.go

@@ -2,7 +2,7 @@ package router
 
 import (
 	"github.com/gin-gonic/gin"
-	"github.com/product-definition/controller"
+	"base-gin/controller"
 )
 
 func Http(g *gin.Engine) {

+ 1 - 1
service/testGet.go

@@ -2,7 +2,7 @@ package service
 
 import (
 	"github.com/gin-gonic/gin"
-	models "github.com/product-definition/model"
+	models "base-gin/model"
 )
 
 type resTest struct {

+ 1 - 1
utils/base/mysql.go

@@ -6,7 +6,7 @@ import (
 	_ "github.com/go-sql-driver/mysql"
 	"github.com/opentracing/opentracing-go"
 	"github.com/opentracing/opentracing-go/ext"
-	"gorm"
+	"base-gin/pkg/gorm"
 	"time"
 )
 

+ 3 - 3
utils/bootstrap.go

@@ -2,9 +2,9 @@ package utils
 
 import (
 	"github.com/gin-gonic/gin"
-	"github.com/product-definition/utils/base"
-	"github.com/product-definition/utils/middleware"
-	"github.com/product-definition/utils/pprof"
+	"base-gin/utils/base"
+	"base-gin/utils/middleware"
+	"base-gin/utils/pprof"
 )
 
 type BootstrapConf struct {

+ 1 - 1
utils/middleware/logger.go

@@ -3,7 +3,7 @@ package middleware
 import (
 	"encoding/json"
 	"github.com/gin-gonic/gin"
-	"github.com/product-definition/utils/base"
+	"base-gin/utils/base"
 	"math"
 	"time"
 

+ 1 - 1
utils/middleware/tracer.go

@@ -2,7 +2,7 @@ package middleware
 
 import (
 	"github.com/gin-gonic/gin"
-	"github.com/product-definition/utils/base"
+	"base-gin/utils/base"
 	"net/http"
 
 	"github.com/opentracing/opentracing-go"

+ 3 - 0
vendor/modules.txt

@@ -37,6 +37,9 @@ github.com/goccy/go-json/internal/encoder/vm_color_indent
 github.com/goccy/go-json/internal/encoder/vm_indent
 github.com/goccy/go-json/internal/errors
 github.com/goccy/go-json/internal/runtime
+# github.com/jinzhu/inflection v1.0.0
+## explicit
+github.com/jinzhu/inflection
 # github.com/json-iterator/go v1.1.12
 ## explicit; go 1.12
 github.com/json-iterator/go