This commit is contained in:
孟帅
2024-04-22 23:08:40 +08:00
parent 82483bd7b9
commit e144b12580
445 changed files with 17457 additions and 6708 deletions

View File

@@ -9,6 +9,7 @@ import (
"context"
"errors"
"fmt"
"github.com/gogf/gf/v2/frame/g"
"hash/fnv"
"hotgo/internal/model"
"strconv"
@@ -40,6 +41,7 @@ func GetOptionsById(ctx context.Context, id int64) (opts []*model.Option, err er
}
for _, v := range GetAllFunc() {
g.Log().Warningf(ctx, "GetAllFunc GetOptionsById v:%v, %v", v.Id, v.Key)
if v.Id == id {
return LoadFuncOptions(ctx, v)
}
@@ -49,6 +51,24 @@ func GetOptionsById(ctx context.Context, id int64) (opts []*model.Option, err er
return
}
// GetTypeById 通过类型ID获取内置选项类型
func GetTypeById(ctx context.Context, id int64) (typ string, err error) {
for _, v := range GetAllEnums() {
if v.Id == id {
return v.Key, nil
}
}
for _, v := range GetAllFunc() {
if v.Id == id {
return v.Key, nil
}
}
err = NotExistKeyError
return
}
// GenIdHash 生成字典id
func GenIdHash(str string, t int64) int64 {
prefix := 10000 * t

View File

@@ -56,9 +56,7 @@ func RegisterEnums(key, label string, opts []*model.Option) {
func SaveEnums(key, label string, opts []*model.Option) {
eLock.Lock()
defer eLock.Unlock()
if _, ok := enumsOptions[key]; ok {
delete(enumsOptions, key)
}
delete(enumsOptions, key)
RegisterEnums(key, label, opts)
}

View File

@@ -67,9 +67,7 @@ func RegisterFunc(key, label string, fun FuncDict, cache ...bool) {
func SaveFunc(key, label string, fun FuncDict, cache ...bool) {
fLock.Lock()
defer fLock.Unlock()
if _, ok := funcOptions[key]; ok {
delete(funcOptions, key)
}
delete(funcOptions, key)
RegisterFunc(key, label, fun, cache...)
}