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

This commit is contained in:
hoteas 2021-08-29 06:08:19 +08:00
parent b480659a22
commit e1f4876621
6 changed files with 26 additions and 9 deletions

View File

@ -95,7 +95,8 @@ func (this *CacheMemory) delete(key string) {
key = Substr(key, 0, del)
for k, _ := range this.Map {
if strings.Index(k, key) != -1 {
delete(this.Map, key)
delete(this.Map, k)
}
}

View File

@ -7,8 +7,8 @@ import (
var categoryCtr = Ctr{
"info": func(that *Context) {
//parentId:=ObjToInt(that.Req.FormValue("parent_id"))
parentId := ObjToInt(that.RouterString[2])
parentId := ObjToInt(that.Req.FormValue("id"))
//parentId := ObjToInt(that.RouterString[2])
if parentId == 0 {
parentId = 1
}

View File

@ -12,7 +12,8 @@ var ctg_order_dateCtr = Ctr{
"info": func(that *Context) {
//today:=time.Now().Weekday()
category := that.Db.Get("category", "*", Map{"id": that.RouterString[2]})
id := ObjToInt(that.Req.FormValue("id"))
category := that.Db.Get("category", "*", Map{"id": id})
if category == nil {
that.Display(4, "找不到该类别!")
return
@ -52,8 +53,9 @@ var ctg_order_dateCtr = Ctr{
if day == 6 || day == 7 {
continue
}
fmt.Println(todayAMTime.Unix() + int64(24*60*60*(i+1)))
dayAM := that.Db.Get("ctg_order_date", "*", Map{"AND": Map{"category_id": that.RouterString[2], "date": todayAMTime.Unix() + int64(24*60*60*(i+1))}})
//fmt.Println(todayAMTime.Unix() + int64(24*60*60*(i+1)))
dayAM := that.Db.Get("ctg_order_date", "*", Map{"AND": Map{"category_id": category.GetCeilInt("id"),
"date": todayAMTime.Unix() + int64(24*60*60*(i+1))}})
if dayAM == nil {
dayAM = Map{"name": "9:00-12:00",
"date": todayAMTime.Unix() + int64(24*60*60*(i+1)),
@ -71,8 +73,10 @@ var ctg_order_dateCtr = Ctr{
}
}
dayPM := that.Db.Get("ctg_order_date", "*", Map{"AND": Map{"category_id": that.RouterString[2], "date": todayPMTime.Unix() + int64(24*60*60*(i+1))}})
dayPM := that.Db.Get("ctg_order_date", "*", Map{"AND": Map{"category_id": category.GetCeilInt("id"), "date": todayPMTime.Unix() + int64(24*60*60*(i+1))}})
fmt.Println(that.Db.LastQuery, that.Db.LastData, dayPM, that.Db.LastErr)
if dayPM == nil {
fmt.Println("dasdasdasda")
dayPM = Map{"name": "14:00-16:00",
"date": todayPMTime.Unix() + int64(24*60*60*(i+1)),
"create_time": time.Now().Unix(),

View File

@ -41,6 +41,7 @@ var orderCtr = Ctr{
"category_id": ctgOrderDate.GetCeilInt("category_id"),
"admin_id": 1,
"status": 1,
"name": time.Unix(ctgOrderDate.GetCeilInt64("date"), 0).Format("2006-01-02 ") + ctgOrderDate.GetString("name"),
}
data["id"] = this.Db.Insert("order", data)
@ -59,8 +60,11 @@ var orderCtr = Ctr{
return
}
data := that.Db.Select("order", Map{"[><]user": "order.user_id=user.id",
"[><]category": "order.category_id=category.id"}, "*", Map{"user_id": that.Session("id").ToCeilInt()})
data := that.Db.Select("order", "*", Map{"user_id": that.Session("id").ToCeilInt()})
for _, v := range data {
v["category"] = that.Db.Get("category", "*", Map{"id": v.GetCeilInt("category_id")})
v["parent_category"] = that.Db.Get("category", "id,name", Map{"id": v.GetMap("category").GetCeilInt("parent_id")})
}
that.Display(0, data)
},
}

View File

@ -1,5 +1,9 @@
{
"cache": {
"db": {
"db": false,
"session": true
},
"memory": {
"db": true,
"session": true,

View File

@ -85,6 +85,10 @@ func main() {
}
context.Router[context.RouterString[0]][context.RouterString[1]]["add"](context)
}
if len(context.RouterString) == 3 &&
context.Req.Method == "POST" {
return true
}
//查询单条
if len(context.RouterString) == 3 &&
context.Req.Method == "GET" {