forked from golang/hotime
增加表关联新建功能,同时修复数据库bug
This commit is contained in:
parent
4ad401bafc
commit
ada4a926c0
@ -405,7 +405,7 @@ func (that *Application) crossDomain(context *Context) {
|
|||||||
|
|
||||||
header := context.Resp.Header()
|
header := context.Resp.Header()
|
||||||
//header.Set("Access-Control-Allow-Origin", "*")
|
//header.Set("Access-Control-Allow-Origin", "*")
|
||||||
header.Set("Access-Control-Allow-Methods", "*")
|
header.Set("Access-Control-Allow-Methods", "GET,POST,OPTIONS,PUT,DELETE")
|
||||||
header.Set("Access-Control-Allow-Credentials", "true")
|
header.Set("Access-Control-Allow-Credentials", "true")
|
||||||
header.Set("Access-Control-Expose-Headers", "*")
|
header.Set("Access-Control-Expose-Headers", "*")
|
||||||
header.Set("Access-Control-Allow-Headers", "X-Requested-With,Content-Type,Access-Token")
|
header.Set("Access-Control-Allow-Headers", "X-Requested-With,Content-Type,Access-Token")
|
||||||
|
@ -87,6 +87,6 @@ var ColumnNameType = []ColumnShow{
|
|||||||
{"file", false, true, true, false, "file", false},
|
{"file", false, true, true, false, "file", false},
|
||||||
{"age", false, true, true, false, "", false},
|
{"age", false, true, true, false, "", false},
|
||||||
{"email", false, true, true, false, "", false},
|
{"email", false, true, true, false, "", false},
|
||||||
{"time", true, false, false, false, "", false},
|
{"time", true, false, true, false, "", false},
|
||||||
{"level", false, false, true, false, "", false},
|
{"level", false, false, true, false, "", false},
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ func (that *MakeCode) Db2JSON(name string, path string, db db.HoTimeDB) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range ColumnNameType {
|
for _, v := range ColumnNameType {
|
||||||
if (v.Strict && coloum.GetString("name") == v.Name) || strings.Contains(coloum.GetString("name"), v.Name) {
|
if (v.Strict && coloum.GetString("name") == v.Name) || (!v.Strict && strings.Contains(coloum.GetString("name"), v.Name)) {
|
||||||
//全部都不需要则不加入
|
//全部都不需要则不加入
|
||||||
if v.Edit == false && v.List == false && v.Info == false {
|
if v.Edit == false && v.List == false && v.Info == false {
|
||||||
coloum["notUse"] = true
|
coloum["notUse"] = true
|
||||||
@ -386,11 +386,12 @@ func (that *MakeCode) Db2JSON(name string, path string, db db.HoTimeDB) {
|
|||||||
|
|
||||||
//字段有动词前缀,自动进行解析
|
//字段有动词前缀,自动进行解析
|
||||||
prefixColumn := strings.Index(oldTableName, "_")
|
prefixColumn := strings.Index(oldTableName, "_")
|
||||||
|
|
||||||
//sys_org_id oldTableName即为sys此处判断为org表存在
|
//sys_org_id oldTableName即为sys此处判断为org表存在
|
||||||
|
|
||||||
if prefixColumn > -1 && that.TableConfig[oldTableName[prefixColumn+1:]] != nil {
|
if prefixColumn > -1 && that.TableConfig[oldTableName[prefixColumn+1:]] != nil {
|
||||||
oldTableName = oldTableName[prefixColumn+1:]
|
oldTableName = oldTableName[prefixColumn+1:]
|
||||||
}
|
}
|
||||||
|
|
||||||
//如果依然找不到则查询system_org是否存在
|
//如果依然找不到则查询system_org是否存在
|
||||||
if prefixColumn > -1 && that.TableConfig[DefaultMenuParentName+"_"+oldTableName[prefixColumn+1:]] != nil {
|
if prefixColumn > -1 && that.TableConfig[DefaultMenuParentName+"_"+oldTableName[prefixColumn+1:]] != nil {
|
||||||
oldTableName = DefaultMenuParentName + "_" + oldTableName[prefixColumn+1:]
|
oldTableName = DefaultMenuParentName + "_" + oldTableName[prefixColumn+1:]
|
||||||
@ -404,7 +405,7 @@ func (that *MakeCode) Db2JSON(name string, path string, db db.HoTimeDB) {
|
|||||||
if prefix > 0 {
|
if prefix > 0 {
|
||||||
//表模块前缀sys_user sys即为前缀 sys_org
|
//表模块前缀sys_user sys即为前缀 sys_org
|
||||||
tableName = fk[:prefix+1] + oldTableName
|
tableName = fk[:prefix+1] + oldTableName
|
||||||
if that.TableConfig[tableName] == nil {
|
if that.TableConfig[tableName] == nil || that.TableConfig[oldTableName] != nil {
|
||||||
//不存在则改为org
|
//不存在则改为org
|
||||||
tableName = oldTableName
|
tableName = oldTableName
|
||||||
}
|
}
|
||||||
@ -486,7 +487,7 @@ func (that *MakeCode) Info(table string) string {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if v.Get("info") == nil || v.GetBool("info") {
|
if v.Get("info") == nil || v.GetBool("info") {
|
||||||
reStr += v.GetString("name") + ","
|
reStr += "`" + v.GetString("name") + "`,"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(reStr) != 0 {
|
if len(reStr) != 0 {
|
||||||
@ -502,11 +503,17 @@ func (that *MakeCode) Add(table string, req *http.Request) Map {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if v.Get("add") == nil || v.GetBool("add") {
|
if v.Get("add") == nil || v.GetBool("add") {
|
||||||
reqValue := req.FormValue(v.GetString("name"))
|
|
||||||
if reqValue == "" {
|
if len(req.Form[v.GetString("name")]) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
data[v.GetString("name")] = reqValue
|
reqValue := req.FormValue(v.GetString("name"))
|
||||||
|
if reqValue == "" && strings.Contains(v.GetString("name"), "id") {
|
||||||
|
data[v.GetString("name")] = nil
|
||||||
|
} else {
|
||||||
|
data[v.GetString("name")] = reqValue
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
|
@ -582,11 +582,11 @@ func (that *HoTimeDB) where(data Map) (string, []interface{}) {
|
|||||||
}
|
}
|
||||||
if x == len(condition) && y == len(vcond) {
|
if x == len(condition) && y == len(vcond) {
|
||||||
|
|
||||||
if reflect.ValueOf(v).Type().String() == "common.Slice" && len(v.(Slice)) == 0 {
|
if v != nil && reflect.ValueOf(v).Type().String() == "common.Slice" && len(v.(Slice)) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if reflect.ValueOf(v).Type().String() == "[]interface {}" && len(v.([]interface{})) == 0 {
|
if v != nil && reflect.ValueOf(v).Type().String() == "[]interface {}" && len(v.([]interface{})) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ func main() {
|
|||||||
appIns := hotime.Init("config/config.json")
|
appIns := hotime.Init("config/config.json")
|
||||||
//RESTfull接口适配
|
//RESTfull接口适配
|
||||||
appIns.SetConnectListener(func(context *hotime.Context) bool {
|
appIns.SetConnectListener(func(context *hotime.Context) bool {
|
||||||
|
|
||||||
//文件上传接口
|
//文件上传接口
|
||||||
if len(context.RouterString) == 1 && context.RouterString[0] == "file" && context.Req.Method == "POST" {
|
if len(context.RouterString) == 1 && context.RouterString[0] == "file" && context.Req.Method == "POST" {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user