增加限制条件
This commit is contained in:
parent
22d00739ff
commit
8cf54ce25b
11
code.go
11
code.go
@ -62,7 +62,9 @@ var TptProject = Proj{
|
|||||||
}
|
}
|
||||||
|
|
||||||
link := strings.Replace(column.GetString("name"), "_id", "", -1)
|
link := strings.Replace(column.GetString("name"), "_id", "", -1)
|
||||||
|
if link == "parent" {
|
||||||
|
link = that.RouterString[1]
|
||||||
|
}
|
||||||
re[link] = that.Db.Get(column.GetString("link"), seStr, Map{"id": v})
|
re[link] = that.Db.Get(column.GetString("link"), seStr, Map{"id": v})
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -106,7 +108,6 @@ var TptProject = Proj{
|
|||||||
hotimeName := that.RouterString[0]
|
hotimeName := that.RouterString[0]
|
||||||
inData := that.MakeCodeRouter[hotimeName].Edit(that.RouterString[1], that.Req)
|
inData := that.MakeCodeRouter[hotimeName].Edit(that.RouterString[1], that.Req)
|
||||||
|
|
||||||
|
|
||||||
if inData == nil {
|
if inData == nil {
|
||||||
that.Display(3, "没有找到要更新的数据")
|
that.Display(3, "没有找到要更新的数据")
|
||||||
return
|
return
|
||||||
@ -188,6 +189,7 @@ var TptProject = Proj{
|
|||||||
|
|
||||||
for _, v := range reData {
|
for _, v := range reData {
|
||||||
v.RangeSort(func(k string, v1 interface{}) (isEnd bool) {
|
v.RangeSort(func(k string, v1 interface{}) (isEnd bool) {
|
||||||
|
|
||||||
//如果有table字段则代为link
|
//如果有table字段则代为link
|
||||||
if v["table"] != nil && v["table_id"] != nil {
|
if v["table"] != nil && v["table_id"] != nil {
|
||||||
|
|
||||||
@ -203,11 +205,12 @@ var TptProject = Proj{
|
|||||||
}
|
}
|
||||||
|
|
||||||
column := that.MakeCodeRouter[hotimeName].TableColumns[that.RouterString[1]][k]
|
column := that.MakeCodeRouter[hotimeName].TableColumns[that.RouterString[1]][k]
|
||||||
|
|
||||||
if column == nil {
|
if column == nil {
|
||||||
return true
|
return isEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
if column["list"] != false && column["name"] == "parent_id" && column.GetString("link") != "" {
|
if (column["list"] == nil || column["list"] == true) && column["name"] == "parent_id" && column.GetString("link") != "" {
|
||||||
|
|
||||||
parentC := that.Db.Get(column.GetString("link"), column.GetString("value"), Map{"id": v.GetCeilInt(k)})
|
parentC := that.Db.Get(column.GetString("link"), column.GetString("value"), Map{"id": v.GetCeilInt(k)})
|
||||||
v[column.GetString("link")+"_"+column.GetString("name")+"_"+column.GetString("value")] = ""
|
v[column.GetString("link")+"_"+column.GetString("name")+"_"+column.GetString("value")] = ""
|
||||||
|
@ -598,7 +598,7 @@ func (that *MakeCode) Info(table string, userData Map, db *db.HoTimeDB) (string,
|
|||||||
//初始化ruleData
|
//初始化ruleData
|
||||||
if ruleData == nil {
|
if ruleData == nil {
|
||||||
ruleData = Map{}
|
ruleData = Map{}
|
||||||
for _, v := range that.TableColumns["admin"] {
|
for _, v := range that.TableColumns[that.FileConfig.GetString("table")] {
|
||||||
if v.GetString("link") != "" &&
|
if v.GetString("link") != "" &&
|
||||||
v.GetString("name") != "parent_id" &&
|
v.GetString("name") != "parent_id" &&
|
||||||
userData.Get(v.GetString("name")) != nil {
|
userData.Get(v.GetString("name")) != nil {
|
||||||
@ -814,7 +814,7 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
|
|||||||
//初始化ruleData
|
//初始化ruleData
|
||||||
if ruleData == nil {
|
if ruleData == nil {
|
||||||
ruleData = Map{}
|
ruleData = Map{}
|
||||||
for _, v := range that.TableColumns["admin"] {
|
for _, v := range that.TableColumns[that.FileConfig.GetString("table")] {
|
||||||
if v.GetString("link") != "" &&
|
if v.GetString("link") != "" &&
|
||||||
v.GetString("name") != "parent_id" &&
|
v.GetString("name") != "parent_id" &&
|
||||||
userData.Get(v.GetString("name")) != nil {
|
userData.Get(v.GetString("name")) != nil {
|
||||||
@ -885,15 +885,32 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//日期类型
|
//日期类型
|
||||||
if searchItemName == "daterange" && v.GetString("type") == "time" {
|
if searchItemName == "daterange" {
|
||||||
|
if v.GetString("type") == "unixtime" {
|
||||||
//fmt.Println(req.Form["daterange"])
|
//fmt.Println(req.Form["daterange"])
|
||||||
if len(req.Form["daterange"]) == 1 {
|
if len(req.Form["daterange"]) == 1 {
|
||||||
daterange[table+"."+v.GetString("name")+"[<]"] = req.FormValue("daterange")
|
daterange[table+"."+v.GetString("name")+"[<]"] = req.FormValue("daterange")
|
||||||
} else {
|
} else if len(req.Form["daterange"]) == 2 {
|
||||||
|
|
||||||
daterange[table+"."+v.GetString("name")+"[<>]"] = ObjToSlice(req.Form["daterange"])
|
daterange[table+"."+v.GetString("name")+"[<>]"] = ObjToSlice(req.Form["daterange"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if v.GetString("type") == "time" {
|
||||||
|
//fmt.Println(req.Form["daterange"])
|
||||||
|
|
||||||
|
if len(req.Form["daterange"]) == 1 {
|
||||||
|
t := time.Unix(ObjToCeilInt64(req.FormValue("daterange")), 0).Format("2006-01-02 15:04:05")
|
||||||
|
|
||||||
|
daterange[table+"."+v.GetString("name")+"[<]"] = t
|
||||||
|
|
||||||
|
} else if len(req.Form["daterange"]) == 2 {
|
||||||
|
t1 := time.Unix(ObjToCeilInt64(req.Form["daterange"][0]), 0).Format("2006-01-02 15:04:05")
|
||||||
|
t2 := time.Unix(ObjToCeilInt64(req.Form["daterange"][1]), 0).Format("2006-01-02 15:04:05")
|
||||||
|
daterange[table+"."+v.GetString("name")+"[<>]"] = Slice{t1, t2}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if searchItem.GetString("name") == "sort" {
|
if searchItem.GetString("name") == "sort" {
|
||||||
@ -944,11 +961,11 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(daterange) > 1 {
|
if len(daterange) > 1 {
|
||||||
//if data["AND"] == nil {
|
if data == nil || len(data) == 0 {
|
||||||
|
data = Map{"OR": daterange}
|
||||||
|
} else {
|
||||||
data = Map{"AND": Map{"AND": data, "OR": daterange}}
|
data = Map{"AND": Map{"AND": data, "OR": daterange}}
|
||||||
//}else{
|
}
|
||||||
// data = Map{"AND": Map{"AND": data, "OR": daterange}}
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(data) > 1 {
|
if len(data) > 1 {
|
||||||
|
@ -47,15 +47,18 @@ func getCode() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//认证公共方案
|
//认证公共方案
|
||||||
func auth(that *Context, phone, companyName string) error {
|
func auth(that *Context, phone, companyName, userName string) error {
|
||||||
|
|
||||||
user := that.Db.Get("user", "id,phone,salesman_id,company_id,provider_id", Map{"id": that.Session("user_id").ToCeilInt()})
|
user := that.Db.Get("user", "id,phone,salesman_id,company_id,provider_id,name", Map{"id": that.Session("user_id").ToCeilInt()})
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return errors.New("找不到用户")
|
return errors.New("找不到用户")
|
||||||
}
|
}
|
||||||
|
company := that.Db.Get("company", "name,id", Map{"id": user.GetCeilInt("company_id")})
|
||||||
|
if company == nil {
|
||||||
|
return errors.New("找不到企业")
|
||||||
|
}
|
||||||
//手机号与原来的不同则进行绑定
|
//手机号与原来的不同则进行绑定
|
||||||
if phone != user.GetString("phone") {
|
if phone != user.GetString("phone") || companyName != company.GetString("name") || user.GetString("name") != userName {
|
||||||
//微信验证成功
|
//微信验证成功
|
||||||
if that.Session("wechat_phone").ToStr() == phone {
|
if that.Session("wechat_phone").ToStr() == phone {
|
||||||
that.Db.Update("user", Map{"phone": phone}, Map{"id": user.GetCeilInt("id")})
|
that.Db.Update("user", Map{"phone": phone}, Map{"id": user.GetCeilInt("id")})
|
||||||
@ -67,7 +70,7 @@ func auth(that *Context, phone, companyName string) error {
|
|||||||
|
|
||||||
return errors.New("验证码错误")
|
return errors.New("验证码错误")
|
||||||
} else {
|
} else {
|
||||||
that.Db.Update("user", Map{"phone": phone}, Map{"id": user.GetCeilInt("id")})
|
that.Db.Update("user", Map{"phone": phone, "name": userName}, Map{"id": user.GetCeilInt("id")})
|
||||||
if user.GetCeilInt("company_id") != 0 {
|
if user.GetCeilInt("company_id") != 0 {
|
||||||
that.Db.Update("company", Map{"phone": phone}, Map{"id": user.GetCeilInt("company_id")})
|
that.Db.Update("company", Map{"phone": phone}, Map{"id": user.GetCeilInt("company_id")})
|
||||||
}
|
}
|
||||||
@ -76,7 +79,7 @@ func auth(that *Context, phone, companyName string) error {
|
|||||||
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
company := that.Db.Get("company", "name,id", Map{"id": user.GetCeilInt("company_id")})
|
//company := that.Db.Get("company", "name,id", Map{"id": user.GetCeilInt("company_id")})
|
||||||
if company != nil {
|
if company != nil {
|
||||||
that.Db.Update("company", Map{"name": companyName}, Map{"id": company.GetCeilInt64("id")})
|
that.Db.Update("company", Map{"name": companyName}, Map{"id": company.GetCeilInt64("id")})
|
||||||
if user.GetCeilInt64("salesman_id") != 0 {
|
if user.GetCeilInt64("salesman_id") != 0 {
|
||||||
|
@ -17,12 +17,13 @@ var OrderCtr = Ctr{
|
|||||||
providerId := ObjToInt(that.Req.FormValue("provider_id"))
|
providerId := ObjToInt(that.Req.FormValue("provider_id"))
|
||||||
phone := that.Req.FormValue("phone")
|
phone := that.Req.FormValue("phone")
|
||||||
companyName := that.Req.FormValue("company_name")
|
companyName := that.Req.FormValue("company_name")
|
||||||
if providerId == 0 || len(phone) != 11 || len(companyName) < 4 {
|
userName := that.Req.FormValue("user_name")
|
||||||
|
if providerId == 0 || len(phone) != 11 || len(companyName) < 4 || len(userName) < 2 {
|
||||||
that.Display(3, "请求参数异常")
|
that.Display(3, "请求参数异常")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := auth(that, phone, companyName)
|
err := auth(that, phone, companyName, userName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
that.Display(3, err.Error())
|
that.Display(3, err.Error())
|
||||||
return
|
return
|
||||||
|
@ -65,8 +65,14 @@ var UpanCtr = Ctr{
|
|||||||
|
|
||||||
phone := that.Req.FormValue("phone")
|
phone := that.Req.FormValue("phone")
|
||||||
companyName := that.Req.FormValue("company_name")
|
companyName := that.Req.FormValue("company_name")
|
||||||
|
userName := that.Req.FormValue("user_name")
|
||||||
|
|
||||||
|
if len(phone) != 11 || len(companyName) < 4 || len(userName) < 2 {
|
||||||
|
that.Display(3, "请求参数异常")
|
||||||
|
return
|
||||||
|
}
|
||||||
//验证不成功则反馈
|
//验证不成功则反馈
|
||||||
err := auth(that, phone, companyName)
|
err := auth(that, phone, companyName, userName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
that.Display(3, err.Error())
|
that.Display(3, err.Error())
|
||||||
|
@ -18,7 +18,8 @@ var VipOrderCtr = Ctr{
|
|||||||
|
|
||||||
phone := that.Req.FormValue("phone")
|
phone := that.Req.FormValue("phone")
|
||||||
companyName := that.Req.FormValue("company_name")
|
companyName := that.Req.FormValue("company_name")
|
||||||
if len(phone) != 11 || len(companyName) < 4 {
|
userName := that.Req.FormValue("user_name")
|
||||||
|
if len(phone) != 11 || len(companyName) < 4 || len(userName) < 2 {
|
||||||
that.Display(3, "请求参数异常")
|
that.Display(3, "请求参数异常")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -37,7 +38,8 @@ var VipOrderCtr = Ctr{
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := auth(that, phone, companyName)
|
err := auth(that, phone, companyName, userName)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
that.Display(3, err.Error())
|
that.Display(3, err.Error())
|
||||||
return
|
return
|
||||||
|
@ -2,6 +2,7 @@ package provider
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
. "code.hoteas.com/golang/hotime"
|
. "code.hoteas.com/golang/hotime"
|
||||||
|
"code.hoteas.com/golang/hotime/common"
|
||||||
"code.hoteas.com/golang/hotime/dri/ddsms"
|
"code.hoteas.com/golang/hotime/dri/ddsms"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -20,6 +21,12 @@ var Sms = Ctr{
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
salesman := that.Db.Get("salesman", "id", common.Map{"phone": phone})
|
||||||
|
if salesman == nil {
|
||||||
|
that.Display(3, "你还不是企服人员,请联系管理员")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
code := getCode()
|
code := getCode()
|
||||||
that.Session("phone", phone)
|
that.Session("phone", phone)
|
||||||
that.Session("code", code)
|
that.Session("code", code)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user