From 9ec597f26c41370e4debb42fd5b34d59efc31e7f Mon Sep 17 00:00:00 2001 From: hoteas Date: Sat, 11 Dec 2021 23:53:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B9=A6=E5=86=99=E5=89=8D=E7=AB=AF=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/app/init.go | 1 + example/app/produce_product.go | 46 ++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 example/app/produce_product.go diff --git a/example/app/init.go b/example/app/init.go index 7beb783..23c0e5b 100644 --- a/example/app/init.go +++ b/example/app/init.go @@ -14,6 +14,7 @@ var Project = Proj{ "sms": Sms, "material": materialCtr, "material_inout": material_inoutCtr, + "produce_product": produce_productCtr, } //生成随机码的4位随机数 diff --git a/example/app/produce_product.go b/example/app/produce_product.go new file mode 100644 index 0000000..5cb7a73 --- /dev/null +++ b/example/app/produce_product.go @@ -0,0 +1,46 @@ +package app + +import ( + . "../../../hotime" + . "../../../hotime/common" +) + +var produce_productCtr = Ctr{ + "info": func(that *Context) { + adminID := that.Session("id").ToInt() + + if adminID == 0 { + that.Display(2, "登录失效,请重新登录") + return + } + + id := ObjToInt(that.Req.FormValue("id")) + sn := that.Req.FormValue("sn") + if id == 0 && sn == "" { + that.Display(3, "请求参数不足,请检查参数") + return + } + + where := Map{} + if id != 0 { + where["id"] = id + } else { + where["sn"] = sn + } + + re := that.Db.Get("produce_product", + + Map{"[><]product": "product_spot_check.product_id=product.id", + "[><]produce": "product_spot_check.produce_id=produce.id", + }, + "id,img,product_id,product.name AS product_name,admin_id,"+ + "modify_time,state,rule,produce_id,produce.name AS produce_name", where) + + if re == nil { + that.Display(4, "找不到对应信息") + return + } + + that.Display(0, re) + }, +}