File tree Expand file tree Collapse file tree 1 file changed +2
-8
lines changed
Expand file tree Collapse file tree 1 file changed +2
-8
lines changed Original file line number Diff line number Diff line change @@ -4,13 +4,11 @@ import (
44 "fmt"
55 "github.com/RomiChan/syncx"
66 "github.com/jinzhu/gorm"
7- "sync"
87)
98
109var (
1110 migratedGroups = syncx.Map [string , bool ]{} // key: string, value: bool
1211 tableHooks []tableHook
13- hooksMtx sync.RWMutex
1412)
1513
1614type tableHook func (gid int64 ) error
@@ -44,21 +42,17 @@ func ensureAuctionInfo(gid int64) error {
4442
4543// registerTableHook 注册钩子
4644func registerTableHook (h ... tableHook ) {
47- hooksMtx .Lock ()
48- defer hooksMtx .Unlock ()
4945 tableHooks = append (tableHooks , h ... )
5046}
5147
5248// TableFor 大写是为了防止数据操作哪里有问题留个保底可以在zbp的项目里直接改
5349func TableFor (gid int64 , prefix string ) * Model {
54- // 先执行钩子
55- hooksMtx .RLock ()
50+ // 先跑钩子
5651 for _ , h := range tableHooks {
5752 if err := h (gid ); err != nil {
58- panic (fmt .Sprintf ("执行表钩子失败 : %v" , err ))
53+ panic (fmt .Sprintf ("执行钩子失败 : %v" , err ))
5954 }
6055 }
61- hooksMtx .RUnlock ()
6256
6357 tableName := fmt .Sprintf ("group_%d_%s_info" , gid , prefix )
6458 return & Model {db .Table (tableName )}
You can’t perform that action at this time.
0 commit comments