goframe 框架
// 数据格式 [{"title":"首页", "ur l":"asdasdasdas", "image_url":"fdgfdgfgfc","list_order":1},{"title":"订单", "url":"asdasdasdas", "image_url":"fdgfdgfgfc","list_order":2},{"title":"个人中心", "url":"asdasdasdas", "image_url":"fdgfdgfgfc","list_order":3}]
var arr g.Array
images := r.GetString("images")
err = json.Unmarshal([]byte(images), &arr)
if err != nil{
return err
}
imgList := g.List{}
for _, v := range arr{
rpcId, err := genId.GetId()
if err != nil{
return nil
}
image := gconv.Map(v)
checkRes := checkImages(image)
if checkRes != nil{
return checkRes
}
imgList = append(imgList, g.Map{
"id": rpcId.NextId,
"slider_id": sliderId,
"title": image["title"],
"list_order": image["list_order"],
"url": image["url"],
"image_url": image["image_url"],
"created_at": gtime.Now().Unix(),
})
}
_, err = tx.Table(slider_image.Table).Data(imgList).Save()
if err != nil{
return err
}
return nil
|
请发表评论