config path

This commit is contained in:
wangchuxiao 2023-02-24 11:06:49 +08:00
parent bb94a7947c
commit 66aaa9b152
3 changed files with 8 additions and 31 deletions

View File

@ -21,7 +21,7 @@ import (
type PersistentConsumerHandler struct { type PersistentConsumerHandler struct {
persistentConsumerGroup *kfk.MConsumerGroup persistentConsumerGroup *kfk.MConsumerGroup
chatLogInterface controller.ChatLogInterface chatLogInterface controller.ChatLogDatabase
} }
func (pc *PersistentConsumerHandler) Init() { func (pc *PersistentConsumerHandler) Init() {

View File

@ -1,50 +1,27 @@
package controller package controller
import ( import (
"OpenIM/pkg/common/db/relation"
relationTb "OpenIM/pkg/common/db/table/relation" relationTb "OpenIM/pkg/common/db/table/relation"
pbMsg "OpenIM/pkg/proto/msg" pbMsg "OpenIM/pkg/proto/msg"
"gorm.io/gorm"
) )
type ChatLogInterface interface { type ChatLogDatabase interface {
CreateChatLog(msg pbMsg.MsgDataToMQ) error CreateChatLog(msg pbMsg.MsgDataToMQ) error
GetChatLog(chatLog *relationTb.ChatLogModel, pageNumber, showNumber int32, contentTypeList []int32) (int64, []relationTb.ChatLogModel, error) GetChatLog(chatLog *relationTb.ChatLogModel, pageNumber, showNumber int32, contentTypeList []int32) (int64, []relationTb.ChatLogModel, error)
} }
func NewChatLogController(db *gorm.DB) ChatLogInterface { func NewChatLogDatabase(chatLogModelInterface relationTb.ChatLogModelInterface) ChatLogDatabase {
return &ChatLogController{database: NewChatLogDataBase(db)} return &ChatLogDataBase{chatLogModel: chatLogModelInterface}
}
type ChatLogController struct {
database ChatLogDataBaseInterface
}
func (c *ChatLogController) CreateChatLog(msg pbMsg.MsgDataToMQ) error {
return c.database.CreateChatLog(msg)
}
func (c *ChatLogController) GetChatLog(chatLog *relationTb.ChatLogModel, pageNumber, showNumber int32, contentTypeList []int32) (int64, []relationTb.ChatLogModel, error) {
return c.database.GetChatLog(chatLog, pageNumber, showNumber, contentTypeList)
}
type ChatLogDataBaseInterface interface {
CreateChatLog(msg pbMsg.MsgDataToMQ) error
GetChatLog(chatLog *relationTb.ChatLogModel, pageNumber, showNumber int32, contentTypeList []int32) (int64, []relationTb.ChatLogModel, error)
} }
type ChatLogDataBase struct { type ChatLogDataBase struct {
chatLogDB relationTb.ChatLogModelInterface chatLogModel relationTb.ChatLogModelInterface
}
func NewChatLogDataBase(db *gorm.DB) ChatLogDataBaseInterface {
return &ChatLogDataBase{chatLogDB: relation.NewChatLog(db)}
} }
func (c *ChatLogDataBase) CreateChatLog(msg pbMsg.MsgDataToMQ) error { func (c *ChatLogDataBase) CreateChatLog(msg pbMsg.MsgDataToMQ) error {
return c.chatLogDB.Create(msg) return c.chatLogModel.Create(msg)
} }
func (c *ChatLogDataBase) GetChatLog(chatLog *relationTb.ChatLogModel, pageNumber, showNumber int32, contentTypeList []int32) (int64, []relationTb.ChatLogModel, error) { func (c *ChatLogDataBase) GetChatLog(chatLog *relationTb.ChatLogModel, pageNumber, showNumber int32, contentTypeList []int32) (int64, []relationTb.ChatLogModel, error) {
return c.chatLogDB.GetChatLog(chatLog, pageNumber, showNumber, contentTypeList) return c.chatLogModel.GetChatLog(chatLog, pageNumber, showNumber, contentTypeList)
} }

View File

@ -17,7 +17,7 @@ type ChatLogGorm struct {
DB *gorm.DB DB *gorm.DB
} }
func NewChatLog(db *gorm.DB) *ChatLogGorm { func NewChatLogGorm(db *gorm.DB) *ChatLogGorm {
return &ChatLogGorm{DB: db} return &ChatLogGorm{DB: db}
} }