书写前端接口
This commit is contained in:
parent
9ec597f26c
commit
94ae568526
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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})
|
||||
},
|
||||
}
|
||||
|
@ -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)
|
||||
|
||||
|
@ -103,6 +103,53 @@ func main() {
|
||||
context.Display(0, data)
|
||||
return false
|
||||
}
|
||||
//文件上传接口
|
||||
if len(context.RouterString) == 1 && context.RouterString[0] == "qrcode" && context.Req.Method == "POST" {
|
||||
|
||||
//读取网络文件
|
||||
ocr := context.Req.FormValue("ocr")
|
||||
if len(ocr) < 100 {
|
||||
|
||||
context.Display(3, "没有上传文件")
|
||||
return false
|
||||
|
||||
}
|
||||
|
||||
go func() {
|
||||
filePath := context.Config.GetString("filePath")
|
||||
if filePath == "" {
|
||||
filePath = "file/2006/01/02/"
|
||||
}
|
||||
path := time.Now().Format(filePath)
|
||||
e := os.MkdirAll(context.Config.GetString("tpt")+"/"+path, os.ModeDir)
|
||||
if e != nil {
|
||||
return
|
||||
}
|
||||
|
||||
fi, _ := base64.StdEncoding.DecodeString(ocr)
|
||||
filePath = path + common.Md5(common.ObjToStr(common.RandX(100000, 9999999))) + ".jpg"
|
||||
ioutil.WriteFile(context.Config.GetString("tpt")+"/"+filePath, fi, 0666)
|
||||
}()
|
||||
|
||||
re1 := tencent.Qrcode(ocr)
|
||||
data := common.Map{}
|
||||
data["qrcode"] = common.ObjToMap(re1)
|
||||
if data["qrcode"] != nil {
|
||||
lis := data.GetMap("qrcode").GetMap("Response").GetSlice("CodeResults")
|
||||
textList := common.Slice{}
|
||||
for k, _ := range lis {
|
||||
li := lis.GetMap(k).GetString("Url")
|
||||
if li != "" {
|
||||
textList = append(textList, li)
|
||||
}
|
||||
}
|
||||
data["qrcode"] = textList
|
||||
}
|
||||
|
||||
fmt.Println(data.ToJsonString())
|
||||
context.Display(0, data)
|
||||
return false
|
||||
}
|
||||
|
||||
//文件上传接口
|
||||
if len(context.RouterString) == 1 && context.RouterString[0] == "file" && context.Req.Method == "POST" {
|
||||
|
BIN
example/myhs.exe
BIN
example/myhs.exe
Binary file not shown.
Loading…
Reference in New Issue
Block a user