beego / bee

Bee is a tool for helping develop with beego app framework.
Apache License 2.0
1.45k stars 922 forks source link

bee generate 导出的模板修改改进 #765

Open leewckk opened 3 years ago

leewckk commented 3 years ago

文件路径: generate/g_model.go line : 178 ,func GetAll{{modelName}}(query map[string]string, fields []string, sortby []string, order []string,offset int64, limit int64) (ml []interface{}, err error)

建议修改成func GetAll{{modelName}}(query map[string]interface{}, fields []string, sortby []string, order []string,offset int64, limit int64) (ml []interface{}, err error) , 否则通过query来查询date/datetime类型的数据字段时会无法查询。

flycash commented 3 years ago

可否给个例子。我看起来的确是用interface会更合适一点。

leewckk commented 3 years ago

可否给个例子。我看起来的确是用interface会更合适一点。 type User struct { Id int64 orm:"auto;pk" Birth time.Time `orm:"type(datetime)" }

query := make(map[string]interface{}) query["birth__gt"] = anytime /// 这种情况SQL是OK的 result, err := GetAllUser(query,nil, nil, nil, 0, 0)

query := make(map[string]string) query["birth__lt"] = "anytime" /// 这种情况SQL检索有可能失败 result, err := GetAllUser(query,nil, nil, nil, 0, 0)

flycash commented 3 years ago

我大概理解了。这个问题根源不在bee工具,而在beego,我先确认一下beego是否能够支持interface{}