本文整理匯總了Golang中github.com/eaciit/webtemplate/helper.HandleError函數的典型用法代碼示例。如果您正苦於以下問題:Golang HandleError函數的具體用法?Golang HandleError怎麽用?Golang HandleError使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了HandleError函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetSelectorConfigs
func (t *SelectorController) GetSelectorConfigs(r *knot.WebContext) interface{} {
r.Config.OutputType = knot.OutputJson
configFilepath := t.AppViewsPath + "data/selector.json"
if _, err := os.Stat(configFilepath); err != nil {
if os.IsNotExist(err) {
os.Create(configFilepath)
} else {
return helper.Result(false, nil, err.Error())
}
}
connection, err := helper.LoadConfig(configFilepath)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
defer connection.Close()
cursor, err := connection.NewQuery().Select("*").Cursor(nil)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
defer cursor.Close()
dataSource, err := cursor.Fetch(nil, 0, false)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
if len(dataSource.Data) > 0 {
return helper.Result(true, dataSource.Data, "")
}
return helper.Result(true, []interface{}{}, "")
}
示例2: ReoderPanel
func (t *DesignerController) ReoderPanel(r *knot.WebContext) interface{} {
r.Config.OutputType = knot.OutputJson
payload := map[string]interface{}{}
err := r.GetForms(&payload)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
_id := payload["_id"].(string)
order := strings.Split(payload["order"].(string), ",")
config, err := t.getConfig(_id)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
content := map[string]interface{}{}
newContent := []interface{}{}
for _, each := range config["content"].([]interface{}) {
panel := each.(map[string]interface{})
content[panel["panelID"].(string)] = panel
}
for _, panelID := range order {
newContent = append(newContent, content[panelID])
}
config["content"] = newContent
err = t.setConfig(_id, config)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
return helper.Result(true, nil, "")
}
示例3: GetDataSource
func (t *DataSourceController) GetDataSource(r *knot.WebContext) interface{} {
r.Config.OutputType = knot.OutputJson
payload := map[string]string{}
err := r.GetForms(&payload)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
_id := payload["_id"]
dsType := payload["type"]
path := payload["path"]
if _, ok := payload["type"]; !ok {
data, err := t.getDataSourceMetaData(_id)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
dsType = data["type"].(string)
path = data["path"].(string)
}
ds, err := helper.FetchDataSource(_id, dsType, path)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
return helper.Result(true, ds, "")
}
示例4: GetDataSourceSelector
func (t *DataSourceController) GetDataSourceSelector(r *knot.WebContext) interface{} {
r.Config.OutputType = knot.OutputJson
payload := map[string]interface{}{}
err := r.GetPayload(&payload)
// fmt.Println(payload["item"].([]interface{}))
// payload := map[string]string{}
// err := r.GetForms(&payload)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
_id := payload["_id"].(string)
dsType := ""
path := ""
if _, ok := payload["type"]; !ok {
data, err := t.getDataSourceMetaData(_id)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
dsType = data["type"].(string)
path = data["path"].(string)
}
ds, err := helper.FetchDataSource(_id, dsType, path)
sds, err := helper.FetchQuerySelector(ds, payload)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
return helper.Result(true, sds, "")
}
示例5: GetPanel
func (t *DesignerController) GetPanel(r *knot.WebContext) interface{} {
r.Config.OutputType = knot.OutputJson
payload := map[string]string{}
err := r.GetForms(&payload)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
data, err := t.getConfig(payload["_id"])
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
for _, eachRaw := range data["content"].([]interface{}) {
each := eachRaw.(map[string]interface{})
if each["panelID"] == payload["panelID"] {
offset := 0
if _, ok := each["offset"]; ok {
offset = int(each["offset"].(float64))
}
data := map[string]interface{}{
"_id": each["panelID"],
"title": each["title"],
"width": int(each["width"].(float64)),
"offset": offset,
}
return helper.Result(true, data, "")
}
}
return helper.Result(true, map[string]interface{}{}, "")
}
示例6: GetDetailGrid
func (t *GridController) GetDetailGrid(r *knot.WebContext) interface{} {
r.Config.OutputType = knot.OutputJson
payload := map[string]string{}
err := r.GetForms(&payload)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
connection, err := helper.LoadConfig(t.AppViewsPath + "data/grid/" + payload["recordid"])
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
defer connection.Close()
cursor, err := connection.NewQuery().Select("*").Cursor(nil)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
defer cursor.Close()
res := []toolkit.M{}
err = cursor.Fetch(&res, 0, false)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
if len(res) == 0 {
return helper.Result(false, nil, "No data found")
}
return helper.Result(true, res, "")
}
示例7: GetGridData
func (t *GridController) GetGridData(r *knot.WebContext) interface{} {
r.Config.OutputType = knot.OutputJson
connection, err := helper.LoadConfig(t.AppViewsPath + "data/mapgrid.json")
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
defer connection.Close()
cursor, err := connection.NewQuery().Select("seq", "data").Cursor(nil)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
defer cursor.Close()
res := []toolkit.M{}
err = cursor.Fetch(&res, 0, false)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
if len(res) == 0 {
return helper.Result(false, nil, "No data found")
}
return helper.Result(true, res, "")
}
示例8: GetConfig
func (t *DesignerController) GetConfig(r *knot.WebContext) interface{} {
r.Config.OutputType = knot.OutputJson
payload := map[string]string{}
err := r.GetForms(&payload)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
_id := payload["_id"]
data, err := t.getConfig(_id)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
connection, err := helper.LoadConfig(t.AppViewsPath + "/data/routes.json")
if !helper.HandleError(err) {
helper.Result(false, nil, err.Error())
}
defer connection.Close()
cursor, err := connection.NewQuery().Where(dbox.Eq("_id", _id)).Cursor(nil)
if !helper.HandleError(err) {
helper.Result(false, nil, err.Error())
}
defer cursor.Close()
dataSource, err := cursor.Fetch(nil, 0, false)
if !helper.HandleError(err) {
helper.Result(false, nil, err.Error())
}
data["href"] = dataSource.Data[0].(map[string]interface{})["href"]
return helper.Result(true, data, "")
}
示例9: RemoveChartConfig
func (t *ChartController) RemoveChartConfig(r *knot.WebContext) interface{} {
r.Config.OutputType = knot.OutputJson
payload := map[string]string{}
err := r.GetForms(&payload)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
// remove chart
filename := fmt.Sprintf("chart-%s.json", payload["_id"])
err = os.Remove(t.AppViewsPath + "data/chart/" + filename)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
// remove chart meta data
connection, err := helper.LoadConfig(t.AppViewsPath + "data/chart.json")
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
defer connection.Close()
err = connection.NewQuery().Delete().Where(dbox.Eq("_id", payload["_id"])).Exec(nil)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
return helper.Result(true, nil, "")
}
示例10: SetHideShow
func (t *DesignerController) SetHideShow(r *knot.WebContext) interface{} {
r.Config.OutputType = knot.OutputJson
payload := map[string]string{}
err := r.GetForms(&payload)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
_id := payload["_id"]
config, err := t.getConfig(_id)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
panelsid := strings.Split(payload["panelid"], ",")
content := config["content"].([]interface{})
for i, each := range content {
content[i].(map[string]interface{})["hide"] = false
for _, panelid := range panelsid {
if panelid == each.(map[string]interface{})["panelID"] {
content[i].(map[string]interface{})["hide"] = true
}
}
}
config["content"] = content
err = t.setConfig(_id, config)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
return helper.Result(true, nil, "")
}
示例11: GetWidgetMetaData
func (t *DesignerController) GetWidgetMetaData(r *knot.WebContext) interface{} {
r.Config.OutputType = knot.OutputJson
payload := map[string]string{}
err := r.GetForms(&payload)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
_id := payload["_id"]
config, err := t.getConfig(_id)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
for _, eachRaw := range config["content"].([]interface{}) {
each := eachRaw.(map[string]interface{})
if each["panelID"] == payload["panelID"] {
for _, subRaw := range each["content"].([]interface{}) {
sub := subRaw.(map[string]interface{})
if sub["widgetID"] == payload["widgetID"] {
return helper.Result(true, sub, "")
}
}
}
}
return helper.Result(false, nil, "")
}
示例12: RemoveDataSource
func (t *DataSourceController) RemoveDataSource(r *knot.WebContext) interface{} {
r.Config.OutputType = knot.OutputJson
payload := map[string]string{}
err := r.GetForms(&payload)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
connection, err := helper.LoadConfig(t.AppViewsPath + "data/datasource.json")
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
defer connection.Close()
err = connection.NewQuery().Delete().Where(dbox.Eq("_id", payload["_id"])).Exec(nil)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
if payload["type"] == "file" {
err = os.Remove(t.AppViewsPath + "data/datasource/" + payload["path"])
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
}
return helper.Result(true, nil, "")
}
示例13: SavePanel
func (t *DesignerController) SavePanel(r *knot.WebContext) interface{} {
r.Config.OutputType = knot.OutputJson
payload := map[string]interface{}{}
err := r.GetForms(&payload)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
_id := payload["_id"].(string)
title := payload["title"].(string)
hide, _ := strconv.ParseBool(payload["hide"].(string))
var width int = int(payload["width"].(float64))
var offset int = int(payload["offset"].(float64))
hideContainerPanel, _ := strconv.ParseBool(payload["hideContainerPanel"].(string))
panelID := payload["panelID"].(string)
config, err := t.getConfig(_id)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
contentOld := config["content"].([]interface{})
if panelID == "" {
panelID = helper.RandomIDWithPrefix("p")
contentNew := map[string]interface{}{
"panelID": panelID,
"title": title,
"width": width,
"offset": offset,
"hide": hide,
"hideContainerPanel": hideContainerPanel,
"content": []interface{}{},
}
config["content"] = append([]interface{}{contentNew}, contentOld...)
} else {
for i, eachRaw := range contentOld {
each := eachRaw.(map[string]interface{})
if each["panelID"] == payload["panelID"] {
contentOld[i].(map[string]interface{})["title"] = title
contentOld[i].(map[string]interface{})["width"] = width
contentOld[i].(map[string]interface{})["offset"] = offset
contentOld[i].(map[string]interface{})["hideContainerPanel"] = hideContainerPanel
}
}
config["content"] = contentOld
}
err = t.setConfig(_id, config)
if !helper.HandleError(err) {
return helper.Result(false, nil, err.Error())
}
return helper.Result(true, panelID, "")
//~ return helper.Result(true, config, config)
//~ return fmt.printf("%v",config)
}
示例14: GetRoutes
func (t *PageController) GetRoutes(r *knot.WebContext) interface{} {
r.Config.OutputType = knot.OutputJson
connection, err := helper.LoadConfig(t.AppViewsPath + "data/routes.json")
helper.HandleError(err)
defer connection.Close()
cursor, err := connection.NewQuery().Select("*").Cursor(nil)
helper.HandleError(err)
defer cursor.Close()
res := []toolkit.M{}
err = cursor.Fetch(&res, 0, false)
helper.HandleError(err)
routes := []map[string]interface{}{}
for _, each := range res {
submenu := each.Get("submenu").([]interface{})
routes = append(routes, map[string]interface{}{
"_id": each["_id"],
"title": each["title"],
"href": each["href"],
"has_child": len(submenu) > 0,
})
for _, subRaw := range submenu {
sub := subRaw.(map[string]interface{})
submenu2 := sub["submenu"].([]interface{})
routes = append(routes, map[string]interface{}{
"_id": fmt.Sprintf("%v|%v", each["_id"], sub["_id"]),
"title": fmt.Sprintf("%v|%v", each["title"], sub["title"]),
"href": sub["href"],
"has_child": len(submenu2) > 0,
})
for _, subRaw2 := range submenu2 {
sub2 := subRaw2.(map[string]interface{})
submenu2 := sub2["submenu"].([]interface{})
routes = append(routes, map[string]interface{}{
"_id": fmt.Sprintf("%v|%v|%v", each["_id"], sub["_id"], sub2["_id"]),
"title": fmt.Sprintf("%v|%v|%v", each["title"], sub["title"], sub2["title"]),
"href": sub["href"],
"has_child": len(submenu2) > 0,
})
}
}
}
return routes
}
示例15: setConfig
func (t *DesignerController) setConfig(_id string, config map[string]interface{}) error {
filename := t.AppViewsPath + "data/page/page-" + _id + ".json"
bytes, err := json.Marshal(config)
if !helper.HandleError(err) {
return err
}
err = ioutil.WriteFile(filename, bytes, 0644)
if !helper.HandleError(err) {
return err
}
return nil
}