diff --git a/code/config.go b/code/config.go index efc3ff9..96d6a40 100644 --- a/code/config.go +++ b/code/config.go @@ -64,6 +64,7 @@ var ColumnNameType = []ColumnShow{ {"idcard", false, true, true, false, "", false}, {"id", true, false, true, false, "", true}, {"parent_id", true, true, true, false, "", true}, + {"amount", true, true, true, false, "money", true}, {"content", false, false, false, false, "textArea", false}, {"info", false, true, true, false, "textArea", false}, //"sn"{true,true,true,""}, diff --git a/code/makecode.go b/code/makecode.go index 8537282..fdda12b 100644 --- a/code/makecode.go +++ b/code/makecode.go @@ -786,11 +786,16 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db * v.GetString("link") + "." + v.GetString("value") + " AS " + v.GetString("link") + "_" + v.GetString("name") + "_" + v.GetString("value") + "," + if v.GetString("value") == "name" && that.TableColumns[v.GetString("link")]["nickname"] != nil { + reStr += v.GetString("link") + ".nickname AS " + + v.GetString("link") + "_" + v.GetString("name") + "_nickname," + } + if that.TableColumns[v.GetString("link")]["phone"] != nil { - reStr += table + "." + v.GetString("name") + "," + - v.GetString("link") + ".phone AS " + + reStr += v.GetString("link") + ".phone AS " + v.GetString("link") + "_" + v.GetString("name") + "_phone," } + leftJoin["[>]"+v.GetString("link")] = table + "." + v.GetString("name") + "=" + v.GetString("link") + ".id" diff --git a/example/app/init.go b/example/app/init.go index 945f996..a03dbc6 100644 --- a/example/app/init.go +++ b/example/app/init.go @@ -54,6 +54,7 @@ func auth(that *Context, phone, companyName, userName string) error { return errors.New("找不到用户") } company := that.Db.Get("company", "name,id", Map{"id": user.GetCeilInt("company_id")}) + if company == nil { return errors.New("找不到企业") } diff --git a/example/app/user.go b/example/app/user.go index e437b99..0358952 100644 --- a/example/app/user.go +++ b/example/app/user.go @@ -24,6 +24,17 @@ var UserCtr = Ctr{ return } + if user.GetCeilInt("company_id") == 0 { + companyId := that.Db.Insert("company", Map{ + "user_id": user["id"], + "create_time[#]": "now()", + "modify_time[#]": "now()", + "del_flag": 0, + }) + user["company_id"] = companyId + that.Db.Update("user", Map{"company_id": companyId}, Map{"id": user.GetCeilInt("id")}) + } + delete(user, "password") company := that.Db.Get("company", "id,name", Map{"id": user.GetCeilInt("company_id")}) diff --git a/example/app/wechath5.go b/example/app/wechath5.go index 2e2fa08..98805ab 100644 --- a/example/app/wechath5.go +++ b/example/app/wechath5.go @@ -39,6 +39,7 @@ var Wechath5 = Ctr{ userId := 0 defer func() { + //有sn就关联业务员 parentId := ObjToInt(that.Req.FormValue("parent_id")) if parentId == 0 { @@ -83,6 +84,7 @@ var Wechath5 = Ctr{ if user == nil { return } + //用户都有企服人员关联 if user.GetCeilInt("salesman_id") != 0 {