增加表关联新建功能,同时修复数据库bug

This commit is contained in:
hoteas 2021-07-07 04:08:40 +08:00
parent 4ad401bafc
commit ada4a926c0
5 changed files with 19 additions and 11 deletions

View File

@ -405,7 +405,7 @@ func (that *Application) crossDomain(context *Context) {
header := context.Resp.Header()
//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-Expose-Headers", "*")
header.Set("Access-Control-Allow-Headers", "X-Requested-With,Content-Type,Access-Token")

View File

@ -87,6 +87,6 @@ var ColumnNameType = []ColumnShow{
{"file", false, true, true, false, "file", false},
{"age", 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},
}

View File

@ -203,7 +203,7 @@ func (that *MakeCode) Db2JSON(name string, path string, db db.HoTimeDB) {
}
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 {
coloum["notUse"] = true
@ -386,11 +386,12 @@ func (that *MakeCode) Db2JSON(name string, path string, db db.HoTimeDB) {
//字段有动词前缀,自动进行解析
prefixColumn := strings.Index(oldTableName, "_")
//sys_org_id oldTableName即为sys此处判断为org表存在
if prefixColumn > -1 && that.TableConfig[oldTableName[prefixColumn+1:]] != nil {
oldTableName = oldTableName[prefixColumn+1:]
}
//如果依然找不到则查询system_org是否存在
if prefixColumn > -1 && that.TableConfig[DefaultMenuParentName+"_"+oldTableName[prefixColumn+1:]] != nil {
oldTableName = DefaultMenuParentName + "_" + oldTableName[prefixColumn+1:]
@ -404,7 +405,7 @@ func (that *MakeCode) Db2JSON(name string, path string, db db.HoTimeDB) {
if prefix > 0 {
//表模块前缀sys_user sys即为前缀 sys_org
tableName = fk[:prefix+1] + oldTableName
if that.TableConfig[tableName] == nil {
if that.TableConfig[tableName] == nil || that.TableConfig[oldTableName] != nil {
//不存在则改为org
tableName = oldTableName
}
@ -486,7 +487,7 @@ func (that *MakeCode) Info(table string) string {
continue
}
if v.Get("info") == nil || v.GetBool("info") {
reStr += v.GetString("name") + ","
reStr += "`" + v.GetString("name") + "`,"
}
}
if len(reStr) != 0 {
@ -502,11 +503,17 @@ func (that *MakeCode) Add(table string, req *http.Request) Map {
continue
}
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
}
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 {

View File

@ -582,11 +582,11 @@ func (that *HoTimeDB) where(data Map) (string, []interface{}) {
}
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
}
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
}

View File

@ -18,6 +18,7 @@ func main() {
appIns := hotime.Init("config/config.json")
//RESTfull接口适配
appIns.SetConnectListener(func(context *hotime.Context) bool {
//文件上传接口
if len(context.RouterString) == 1 && context.RouterString[0] == "file" && context.Req.Method == "POST" {