mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-11 01:36:37 +08:00
fix(risk_control,message_gateway): fix SQL LIKE escape syntax and use UserService contract
This commit is contained in:
@@ -19,6 +19,8 @@ var (
|
||||
cacheSvc contracts.CacheService
|
||||
taskMu sync.RWMutex
|
||||
taskSvc contracts.TaskService
|
||||
userMu sync.RWMutex
|
||||
userSvc contracts.UserService
|
||||
)
|
||||
|
||||
// SetDBServiceForTest injects a DBService for tests. Production wiring must use Apply.
|
||||
@@ -44,6 +46,12 @@ func setTaskService(s contracts.TaskService) {
|
||||
taskSvc = s
|
||||
}
|
||||
|
||||
func setUserService(s contracts.UserService) {
|
||||
userMu.Lock()
|
||||
defer userMu.Unlock()
|
||||
userSvc = s
|
||||
}
|
||||
|
||||
func getDB(ctx context.Context) *gorm.DB {
|
||||
if c, ok := ctx.(*core.Context); ok && c != nil {
|
||||
if s, err := core.Inject[contracts.DBService](c); err == nil && s != nil {
|
||||
@@ -76,3 +84,14 @@ func getTaskService() contracts.TaskService {
|
||||
defer taskMu.RUnlock()
|
||||
return taskSvc
|
||||
}
|
||||
|
||||
func getUserService(ctx context.Context) contracts.UserService {
|
||||
if c, ok := ctx.(*core.Context); ok && c != nil {
|
||||
if s, err := core.Inject[contracts.UserService](c); err == nil && s != nil {
|
||||
return s
|
||||
}
|
||||
}
|
||||
userMu.RLock()
|
||||
defer userMu.RUnlock()
|
||||
return userSvc
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user