```
prevexpect,_ := strconv.Atoi(PrevExpect())
sql := "SELECT * from plan pl " +
"left JOIN program pr on pl.program_id = pr.id " +
"left JOIN program_info pi on pi.program_id = pr.id and pi.code = pr.code " +
"where pr.status = 1 and pi.status = 1 and pl.expect = ?"
res,err := models.Engine.Query(sql,prevexpect+1)
r := make(gin.H)
if err == nil {
m := make([]map[string]string,len(res))
for k,v := range res {
m[k] = make(map[string]string)
for kk,vv := range v{
m[k][kk] = string(vv)
}
}
r["Code"] = 0
r["Message"] = "获取成功"
r["Data"] = m
c.XML(200,r)
//c.JSON(200,r)
} else {
r["Code"] = 1
r["Message"] = "更新失败"
r["Data"] = err
c.XML(200,gin.H{
"data":"",
})
}
```
报错使用c.json可以直接转换.
```
xml: unsupported type: map[string]string
```
有疑问加站长微信联系(非本文作者)