[fix] widget table bind model bug
This commit is contained in:
parent
63f9e6574d
commit
d489feb99b
3 changed files with 27 additions and 7 deletions
|
|
@ -122,7 +122,7 @@ var startCmd = &cobra.Command{
|
|||
err := studio.Start(config.Conf)
|
||||
if err != nil {
|
||||
fmt.Println(color.RedString(L("Fatal: %s"), err.Error()))
|
||||
os.Exit(1)
|
||||
os.Exit(2)
|
||||
}
|
||||
}()
|
||||
defer studio.Stop()
|
||||
|
|
@ -157,7 +157,7 @@ var startCmd = &cobra.Command{
|
|||
err := service.Start()
|
||||
if err != nil {
|
||||
fmt.Println(color.RedString(L("Fatal: %s"), err.Error()))
|
||||
os.Exit(1)
|
||||
os.Exit(3)
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package model
|
|||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/yaoapp/gou"
|
||||
"github.com/yaoapp/kun/log"
|
||||
|
|
@ -21,6 +22,7 @@ func Load(cfg config.Config) error {
|
|||
// LoadFrom 从特定目录加载
|
||||
func LoadFrom(dir string, prefix string) error {
|
||||
|
||||
messages := []string{}
|
||||
if share.DirNotExists(dir) {
|
||||
return fmt.Errorf("%s does not exists", dir)
|
||||
}
|
||||
|
|
@ -31,11 +33,19 @@ func LoadFrom(dir string, prefix string) error {
|
|||
_, err := gou.LoadModelReturn(string(content), name)
|
||||
if err != nil {
|
||||
log.With(log.F{"root": root, "file": filename}).Error(err.Error())
|
||||
return
|
||||
messages = append(messages, err.Error())
|
||||
}
|
||||
})
|
||||
|
||||
return err
|
||||
if err != nil {
|
||||
messages = append(messages, err.Error())
|
||||
}
|
||||
|
||||
if len(messages) > 0 {
|
||||
return fmt.Errorf("[Model] %s", strings.Join(messages, ";"))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadBuildIn 从制品中读取
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/yaoapp/gou"
|
||||
"github.com/yaoapp/kun/log"
|
||||
"github.com/yaoapp/yao/widgets/component"
|
||||
"github.com/yaoapp/yao/widgets/field"
|
||||
)
|
||||
|
|
@ -54,15 +55,24 @@ func (fields *FieldsDSL) BindModel(m *gou.Model) error {
|
|||
|
||||
// Index as filter
|
||||
if col.Index || col.Unique || col.Primary {
|
||||
|
||||
filterField, err := trans.Filter(col.Type, data)
|
||||
if err != nil && !field.IsNotFound(err) {
|
||||
return err
|
||||
}
|
||||
if _, has := fields.Filter[filterField.Key]; !has {
|
||||
fields.Filter[tableField.Key] = *filterField
|
||||
fields.filterMap[col.Name] = fields.Filter[tableField.Key]
|
||||
|
||||
if filterField == nil {
|
||||
log.Warn("[Fields.BindModel] %s.%s (%s) No matching filters found", m.Name, col.Name, col.Type)
|
||||
}
|
||||
|
||||
if filterField != nil {
|
||||
if _, has := fields.Filter[filterField.Key]; !has {
|
||||
fields.Filter[tableField.Key] = *filterField
|
||||
fields.filterMap[col.Name] = fields.Filter[tableField.Key]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue