书写前端接口

This commit is contained in:
hoteas
2021-12-12 04:22:30 +08:00
parent 7b85da4c7f
commit 9482404265
5 changed files with 77 additions and 17 deletions
+4 -4
View File
@@ -126,12 +126,12 @@ var materialCtr = Ctr{
page = 1
}
if pageSize <= 0 {
pageSize = 20
pageSize = 10
}
leftJoin := Map{"[><]admin": "material.admin_id=admin.id"}
columnStr := "sn,name,img,count,used,saved,admin_id,admin.name AS admin_name,modify_time,state"
where := Map{"state": 0, "ORDER": "modify_time DESC"}
count := that.Db.Count("material", "id", where)
columnStr := "material.id,material.sn,material.name,material.img,material.count,material.used,material.saved,material.admin_id,admin.name AS admin_name,material.modify_time,material.state"
where := Map{"ORDER": "modify_time DESC"}
count := that.Db.Count("material", where)
reData := that.Db.Page(page, pageSize).
PageSelect("material", leftJoin, columnStr, where)
+8 -4
View File
@@ -141,20 +141,24 @@ var material_inoutCtr = Ctr{
}
page := ObjToInt(that.Req.FormValue("page"))
pageSize := ObjToInt(that.Req.FormValue("pageSize"))
materialId := ObjToInt(that.Req.FormValue("id"))
if page < 1 {
page = 1
}
if pageSize <= 0 {
pageSize = 20
pageSize = 10
}
columnStr := "sn,material.name,img,count,saved,admin_id,admin.name AS admin_name,modify_time,state"
columnStr := "material_inout.id,material_inout.material_id,material_inout.sn,material.name,material_inout.img,material_inout.count,material_inout.saved,material_inout.admin_id,admin.name AS admin_name,material_inout.modify_time,material_inout.state"
leftJoin := Map{"[><]material": "material_inout.material_id=material.id",
"[><]admin": "material_inout.admin_id=admin.id",
}
where := Map{"ORDER": "modify_time DESC"}
count := that.Db.Count("material_inout", "id", where)
if materialId != 0 {
where["material_id"] = materialId
}
count := that.Db.Count("material_inout", where)
reData := that.Db.Page(page, pageSize).
PageSelect("material_inout", leftJoin, columnStr, where)
+5 -5
View File
@@ -105,16 +105,16 @@ var productCtr = Ctr{
page = 1
}
if pageSize <= 0 {
pageSize = 20
pageSize = 10
}
leftJoin := Map{"[><]admin": "product.admin_id=admin.id"}
columnStr := "sn,name,img,count,used,saved,spot_check_saved,admin_id,admin.name AS admin_name,modify_time,state"
where := Map{"state": 0, "ORDER": "modify_time DESC"}
count := that.Db.Count("product", "id", where)
columnStr := "product.id,product.sn,product.name,product.img,product.count,product.used,product.saved,product.spot_check_count,product.admin_id,admin.name AS admin_name,product.modify_time,product.state"
where := Map{"ORDER": "modify_time DESC"}
count := that.Db.Count("product", where)
reData := that.Db.Page(page, pageSize).
PageSelect("product", leftJoin, columnStr, where)
that.Display(0, Map{"product": count, "data": reData})
that.Display(0, Map{"count": count, "data": reData})
},
}
+13 -4
View File
@@ -98,20 +98,29 @@ var product_spot_checkCtr = Ctr{
}
page := ObjToInt(that.Req.FormValue("page"))
pageSize := ObjToInt(that.Req.FormValue("pageSize"))
productId := ObjToInt(that.Req.FormValue("id"))
if page < 1 {
page = 1
}
if pageSize <= 0 {
pageSize = 20
pageSize = 10
}
columnStr := "sn,product.name,img,count,saved,admin_id,admin.name AS admin_name,modify_time,state"
columnStr := "product_spot_check.id,product_spot_check.product_id,product_spot_check.sn,product.name,product_spot_check.img,product_spot_check.admin_id,admin.name AS admin_name,product_spot_check.modify_time,product_spot_check.state"
leftJoin := Map{"[><]product": "product_spot_check.product_id=product.id",
"[><]admin": "product_spot_check.admin_id=admin.id",
}
where := Map{"ORDER": "modify_time DESC"}
count := that.Db.Count("product_spot_check", "id", where)
where := Map{"ORDER": "id DESC"}
if productId != 0 {
where["product_id"] = productId
}
count := that.Db.Count("product_spot_check", where)
reData := that.Db.Page(page, pageSize).
PageSelect("product_spot_check", leftJoin, columnStr, where)