65 Star 401 Fork 129

admpub/nging

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
dbsaver.go 832 Bytes
Copy Edit Raw Blame History
admpub authored 5 years ago . update
package upload
import (
"io"
uploadClient "github.com/webx-top/client/upload"
modelFile "github.com/admpub/nging/application/model/file"
)
type (
DBSaver func(fileM *modelFile.File, result *uploadClient.Result, reader io.Reader) error
)
var (
dbSavers = map[string]DBSaver{}
DefaultDBSaver = func(fileM *modelFile.File, result *uploadClient.Result, reader io.Reader) error {
return nil
}
)
func DBSaverRegister(key string, dbsaver DBSaver) {
dbSavers[key] = dbsaver
}
func DBSaverUnregister(keys ...string) {
for _, key := range keys {
_, ok := dbSavers[key]
if ok {
delete(dbSavers, key)
}
}
}
func DBSaverGet(key string, defaults ...string) DBSaver {
if dbsaver, ok := dbSavers[key]; ok {
return dbsaver
}
if len(defaults) > 0 {
return DBSaverGet(defaults[0])
}
return DefaultDBSaver
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/admpub/nging.git
git@gitee.com:admpub/nging.git
admpub
nging
nging
v2.1.1

Search