Browse Source

project: 项目框架重新整理

Yi 1 year ago
parent
commit
8cc174aebe
9 changed files with 95 additions and 724 deletions
  1. 1 0
      .gitignore
  2. 2 2
      README.md
  3. 1 1
      cmd/http.go
  4. 4 3
      config/app.go
  5. 2 0
      dep/dep.go
  6. 22 10
      go.mod
  7. 61 706
      go.sum
  8. 1 1
      main.go
  9. 1 1
      store/kptstore/rw_store.go

+ 1 - 0
.gitignore

@@ -46,3 +46,4 @@ _testmain.go
 .idea/
 bin/
 .vscode/
+logger

+ 2 - 2
README.md

@@ -1,6 +1,6 @@
-# kpt-demo
+# kpt-event
 
-kpt-demo - 科湃腾后台事件驱动系统
+kpt-event - 科湃腾后台事件驱动系统
 
 ## Requirements
 

+ 1 - 1
cmd/http.go

@@ -6,7 +6,7 @@ import (
 	"kpt-event/dep"
 	"kpt-event/http"
 
-	log "gitee.com/xuyiping_admin/pkg/logger"
+	log "gitee.com/xuyiping_admin/pkg/logger/zaplog"
 
 	"github.com/spf13/cobra"
 )

+ 4 - 3
config/app.go

@@ -1,12 +1,13 @@
 package config
 
 import (
+	"go.uber.org/zap"
 	"os"
 	"strings"
 	"sync"
 
 	"gitee.com/xuyiping_admin/pkg/di"
-	log "gitee.com/xuyiping_admin/pkg/logger"
+	"gitee.com/xuyiping_admin/pkg/logger/zaplog"
 )
 
 const AppName = "kptEvent"
@@ -32,6 +33,7 @@ type AppConfig struct {
 // StoreSetting 数据库配置
 type StoreSetting struct {
 	// 开启 SyDb SQL 记录
+	DriverName      string `yaml:"driver_name" json:"driver_name"`
 	ShowSQL         bool   `yaml:"show_sql" env:"STORE_SHOW_SQL"`
 	KptEventDSNRW   string `yaml:"kpt_event_rw" env:"LINGO_COURSE_DSN_RW"`
 	KptEventDSNMigr string `yaml:"kpt_event_migr" env:"LINGO_COURSE_DSN_MIGR"`
@@ -50,14 +52,13 @@ func init() {
 		switch appEnv {
 		default:
 			err = Initialize("app.test.yaml", cfg)
-			log.SetLevel(log.ErrorLevel)
 		case "development":
 			err = Initialize("app.develop.yaml", cfg)
 		case "production":
 			err = Initialize("app.production.yaml", cfg)
 		}
 		if err != nil {
-			log.Fatalf("%+v", err)
+			zaplog.Error("%+v", zap.Any("project init", err))
 		}
 		options = cfg
 	})

+ 2 - 0
dep/dep.go

@@ -2,6 +2,7 @@ package dep
 
 import (
 	"kpt-event/config"
+	"kpt-event/store/kptstore"
 
 	"gitee.com/xuyiping_admin/pkg/di"
 )
@@ -20,5 +21,6 @@ func Options() []di.HubOption {
 		// 基础依赖
 		config.Module,
 		// store
+		kptstore.Module,
 	}
 }

+ 22 - 10
go.mod

@@ -3,48 +3,60 @@ module kpt-event
 go 1.17
 
 require (
+	gitee.com/xuyiping_admin/pkg v0.0.0-20231218082641-aac597b8a015
 	github.com/getsentry/sentry-go v0.23.0
 	github.com/gin-contrib/cors v1.4.0
 	github.com/gin-contrib/gzip v0.0.6
 	github.com/gin-contrib/requestid v0.0.6
 	github.com/gin-gonic/gin v1.9.0
-	github.com/google/go-cmp v0.5.9
-	github.com/jinzhu/copier v0.3.5
 	github.com/mitchellh/mapstructure v1.5.0
-	github.com/sirupsen/logrus v1.9.3
-	github.com/spf13/cobra v1.6.1
+	github.com/spf13/cobra v1.7.0
 	github.com/spf13/viper v1.14.0
-	github.com/stretchr/testify v1.8.4
-	go.uber.org/dig v1.17.0
+	go.uber.org/dig v1.15.0
+	go.uber.org/zap v1.24.0
+	gorm.io/driver/mysql v1.5.1
+	gorm.io/gorm v1.25.2
 )
 
 require (
-	gitee.com/xuyiping_admin/pkg v0.0.0-20230816061144-c1f079802584 // indirect
-	github.com/davecgh/go-spew v1.1.1 // indirect
+	github.com/bytedance/sonic v1.9.1 // indirect
+	github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
 	github.com/fsnotify/fsnotify v1.6.0 // indirect
+	github.com/gabriel-vasile/mimetype v1.4.2 // indirect
 	github.com/gin-contrib/sse v0.1.0 // indirect
 	github.com/go-playground/locales v0.14.1 // indirect
 	github.com/go-playground/universal-translator v0.18.1 // indirect
 	github.com/go-playground/validator/v10 v10.14.0 // indirect
+	github.com/go-sql-driver/mysql v1.7.0 // indirect
 	github.com/goccy/go-json v0.10.2 // indirect
 	github.com/google/uuid v1.3.0 // indirect
 	github.com/hashicorp/hcl v1.0.0 // indirect
-	github.com/inconshreveable/mousetrap v1.0.1 // indirect
+	github.com/inconshreveable/mousetrap v1.1.0 // indirect
+	github.com/jinzhu/inflection v1.0.0 // indirect
+	github.com/jinzhu/now v1.1.5 // indirect
 	github.com/json-iterator/go v1.1.12 // indirect
+	github.com/klauspost/cpuid/v2 v2.2.4 // indirect
 	github.com/leodido/go-urn v1.2.4 // indirect
+	github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible // indirect
+	github.com/lestrrat-go/strftime v1.0.6 // indirect
 	github.com/magiconair/properties v1.8.7 // indirect
 	github.com/mattn/go-isatty v0.0.19 // indirect
 	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
 	github.com/modern-go/reflect2 v1.0.2 // indirect
 	github.com/pelletier/go-toml v1.9.5 // indirect
 	github.com/pelletier/go-toml/v2 v2.0.8 // indirect
-	github.com/pmezard/go-difflib v1.0.0 // indirect
+	github.com/pkg/errors v0.9.1 // indirect
+	github.com/sirupsen/logrus v1.9.3 // indirect
 	github.com/spf13/afero v1.9.2 // indirect
 	github.com/spf13/cast v1.5.0 // indirect
 	github.com/spf13/jwalterweatherman v1.1.0 // indirect
 	github.com/spf13/pflag v1.0.5 // indirect
 	github.com/subosito/gotenv v1.4.1 // indirect
+	github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
 	github.com/ugorji/go/codec v1.2.11 // indirect
+	go.uber.org/atomic v1.9.0 // indirect
+	go.uber.org/multierr v1.8.0 // indirect
+	golang.org/x/arch v0.3.0 // indirect
 	golang.org/x/crypto v0.9.0 // indirect
 	golang.org/x/net v0.10.0 // indirect
 	golang.org/x/sys v0.8.0 // indirect

File diff suppressed because it is too large
+ 61 - 706
go.sum


+ 1 - 1
main.go

@@ -7,7 +7,7 @@ package main
 import (
 	"kpt-event/cmd"
 
-	log "gitee.com/xuyiping_admin/pkg/logger"
+	log "gitee.com/xuyiping_admin/pkg/logger/zaplog"
 )
 
 func main() {

+ 1 - 1
store/kptstore/rw_store.go

@@ -1,7 +1,7 @@
 package kptstore
 
 import (
-	"kpt-tmr-group/config"
+	"kpt-event/config"
 	"time"
 
 	"gitee.com/xuyiping_admin/pkg/logger/logrus"

Some files were not shown because too many files changed in this diff