forked from golang/hotime
97 lines
2.4 KiB
Go
97 lines
2.4 KiB
Go
package app
|
|
|
|
import (
|
|
. "../../../hotime"
|
|
. "../../../hotime/common"
|
|
"time"
|
|
)
|
|
|
|
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["produce_product.id"] = id
|
|
} else {
|
|
where["produce_product.sn"] = sn
|
|
}
|
|
|
|
re := that.Db.Get("produce_product",
|
|
|
|
Map{"[><]product": "produce_product.product_id=product.id",
|
|
"[><]produce": "produce_product.produce_id=produce.id",
|
|
},
|
|
"produce_product.id,produce_product.product_id,product.name AS product_name,"+
|
|
"produce_product.modify_time,produce_product.state,product.rule_spot_check,produce_product.produce_id,produce.name AS produce_name", where)
|
|
|
|
if re == nil {
|
|
that.Display(4, "找不到对应信息")
|
|
return
|
|
}
|
|
|
|
that.Display(0, re)
|
|
},
|
|
"add": func(that *Context) {
|
|
adminID := that.Session("id").ToInt()
|
|
|
|
if adminID == 0 {
|
|
that.Display(2, "登录失效,请重新登录")
|
|
return
|
|
}
|
|
|
|
sn := that.Req.FormValue("sn")
|
|
product_id := ObjToInt(that.Req.FormValue("product_id"))
|
|
produce_id := ObjToInt(that.Req.FormValue("produce_id"))
|
|
product_line_id := ObjToInt(that.Req.FormValue("product_line_id"))
|
|
state := ObjToInt(that.Req.FormValue("state"))
|
|
rule_check := that.Req.FormValue("rule_check")
|
|
description := that.Req.FormValue("description")
|
|
if sn == "" || rule_check == "" {
|
|
that.Display(3, "参数不足,请补充参数")
|
|
return
|
|
}
|
|
|
|
data := Map{
|
|
|
|
"sn": sn,
|
|
"product_id": product_id,
|
|
"produce_id": produce_id,
|
|
"create_time": time.Now().Unix(),
|
|
"modify_time": time.Now().Unix(),
|
|
}
|
|
|
|
data1 := ObjToMap(data.ToJsonString())
|
|
data1["product_line_id"] = product_line_id
|
|
id := that.Db.Insert("produce_product", data1)
|
|
if id == 0 {
|
|
that.Display(4, "添加新成品失败,请重新添加")
|
|
return
|
|
}
|
|
|
|
//data["id"] = id
|
|
data["rule"] = rule_check
|
|
data["produce_product_id"] = id
|
|
data["state"] = state
|
|
data["description"] = description
|
|
id = that.Db.Insert("product_check", data)
|
|
if id == 0 {
|
|
that.Display(4, "添加质检失败,请重新添加")
|
|
return
|
|
}
|
|
that.Display(0, data)
|
|
},
|
|
}
|