sun-pc 6 months ago
parent
commit
0d866ee417
5 changed files with 16 additions and 29 deletions
  1. 11 16
      src/api/api.go
  2. 2 6
      src/app.yaml
  3. 0 4
      src/client/main.go
  4. 1 0
      src/conf/app.go
  5. 2 3
      src/main.go

+ 11 - 16
src/api/api.go

@@ -4,26 +4,18 @@ import (
 	"context"
 	"fmt"
 	"work-device/conf"
-	"work-device/db"
 	"work-device/db/repo"
 
 	"github.com/gin-contrib/cors"
 	"github.com/gin-contrib/sessions"
 	"github.com/gin-contrib/sessions/cookie"
 	"github.com/gin-gonic/gin"
-	"github.com/go-redis/redis/v8"
-)
-
-const (
-	SKU3DADMIN    = "sku3d-admin"
-	SKU3DUSER     = "sku3d-user"
-	SKU3DDESIGNER = "sku3d-designer"
 )
 
 type Service struct {
-	Gin            *gin.Engine
-	Mongo          *db.MongoDB
-	Redis          *redis.Client
+	Gin *gin.Engine
+	// Mongo          *db.MongoDB
+	// Redis          *redis.Client
 	Port           int32
 	DebugUserId    string
 	DebugUserPhone string
@@ -43,13 +35,15 @@ type ApiSession struct {
 
 func (api *ApiSession) CreateRepoCtx() *repo.RepoSession {
 	return &repo.RepoSession{
-		Ctx:    context.Background(),
-		Client: api.Svc.Mongo,
-		Redis:  api.Svc.Redis,
+		Ctx: context.Background(),
+		// Client: api.Svc.Mongo,
+		// Redis:  api.Svc.Redis,
 	}
 }
 
-func NewHttpService(app *conf.AppConf, dbMongo *db.MongoDB, redisClient *redis.Client) *Service {
+// func NewHttpService(app *conf.AppConf, dbMongo *db.MongoDB, redisClient *redis.Client) *Service {
+
+func NewHttpService(app *conf.AppConf) *Service {
 
 	engine := gin.Default()
 
@@ -64,7 +58,8 @@ func NewHttpService(app *conf.AppConf, dbMongo *db.MongoDB, redisClient *redis.C
 
 	jwt := NewUitlsJwt(app)
 
-	s := &Service{Conf: app, Redis: redisClient, JWT: jwt, Gin: engine, Mongo: dbMongo, Port: app.Port, DebugUserId: app.Debug.UserId, DebugUserPhone: app.Debug.UserPhone, DebugUserRole: app.Debug.UserRole}
+	// s := &Service{Conf: app, Redis: redisClient, JWT: jwt, Gin: engine, Mongo: dbMongo, Port: app.Port, DebugUserId: app.Debug.UserId, DebugUserPhone: app.Debug.UserPhone, DebugUserRole: app.Debug.UserRole}
+	s := &Service{Conf: app, JWT: jwt, Gin: engine, Port: app.Port, DebugUserId: app.Debug.UserId, DebugUserPhone: app.Debug.UserPhone, DebugUserRole: app.Debug.UserRole}
 
 	RegRouters(s)
 

+ 2 - 6
src/app.yaml

@@ -11,16 +11,12 @@ nats:
   #url: nats://127.0.0.1:14223
   maxReconnect: 1000
   reconnDelaySecond: 5
-  renderStreamTopic: sku3drender-req-stream#sku3drender.request#sku3drender-queue
   
 log:
-  fileName: sku3d-admin.log
+  fileName: work-device.log
   level: 1
-  serviceName: sku3dweb
+  serviceName: work-device
 
-mongo: 
-  dsn: mongodb://root:root@124.71.139.24:27033/sku3d?authSource=admin
-  Database: sku3d
 
 debug: 
   userId: test

+ 0 - 4
src/client/main.go

@@ -40,10 +40,6 @@ func Connect() {
 
 // 创建连接的时候执行
 func DoClientConnectedBegin(conn ziface.IConnection) {
-	//设置两个链接属性,在连接创建之后
-	conn.SetProperty("Name", "刘丹冰")
-	conn.SetProperty("Home", "https://yuque.com/aceld")
-
 	// 获取配置/发送消息到服务端,注册workdevice
 	system := conf.AppConfig.System
 

+ 1 - 0
src/conf/app.go

@@ -120,6 +120,7 @@ func NewAppConf(filePath string) (*AppConf, error) {
 	}
 
 	fmt.Println("Env NATS=>", nats)
+	AppConfig = c
 
 	return c, nil
 }

+ 2 - 3
src/main.go

@@ -6,7 +6,6 @@ import (
 	"work-device/bus"
 	"work-device/client"
 	"work-device/conf"
-	"work-device/db"
 	"work-device/log"
 
 	"go.uber.org/dig"
@@ -22,8 +21,8 @@ func BuildApp() *dig.Container {
 		return conf.NewAppConf(*confFile)
 	})
 	_ = app.Provide(bus.NewNatsBus)
-	_ = app.Provide(db.NewMongoDB)
-	_ = app.Provide(db.NewRedisClient)
+	// _ = app.Provide(db.NewMongoDB)
+	// _ = app.Provide(db.NewRedisClient)
 	_ = app.Provide(api.NewHttpService)
 
 	return app