feat kafka 改版 2
This commit is contained in:
@@ -3,6 +3,7 @@ package repository
|
||||
import (
|
||||
"fmt"
|
||||
"git.hlsq.asia/mmorpg/service-common/db/mysql"
|
||||
"git.hlsq.asia/mmorpg/service-user/internal/dao/query"
|
||||
)
|
||||
|
||||
var dbName mysql.DBName = "user_db"
|
||||
@@ -12,6 +13,10 @@ var (
|
||||
userCacheByPhone = "c:user:p:%v"
|
||||
)
|
||||
|
||||
func Query() *query.Query {
|
||||
return query.Use(mysql.GetDB(dbName))
|
||||
}
|
||||
|
||||
func keyCacheBySn(sn string, tableName string) string {
|
||||
return fmt.Sprintf(cacheBySn, tableName, sn)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.hlsq.asia/mmorpg/service-common/db/mysql"
|
||||
"git.hlsq.asia/mmorpg/service-common/db/redis"
|
||||
"git.hlsq.asia/mmorpg/service-user/internal/dao/model"
|
||||
"git.hlsq.asia/mmorpg/service-user/internal/dao/query"
|
||||
@@ -15,10 +14,10 @@ type UserDao struct {
|
||||
cache *redis.CacheClient
|
||||
}
|
||||
|
||||
func NewUserDao(ctx context.Context, cache ...*redis.CacheClient) *UserDao {
|
||||
func NewUserDao(ctx context.Context, query *query.Query, cache ...*redis.CacheClient) *UserDao {
|
||||
dao := &UserDao{
|
||||
ctx: ctx,
|
||||
query: query.Use(mysql.GetDB(dbName)),
|
||||
query: query,
|
||||
}
|
||||
if len(cache) > 0 {
|
||||
dao.cache = cache[0]
|
||||
|
||||
Reference in New Issue
Block a user