数据库User表结构以及测试数据:
控制器:
package controllers
import (
"encoding/json"
"fmt"
"github.com/astaxie/beego/orm"
"github.com/davecgh/go-spew/spew" //此为第三方包,需自行下载:go get github.com/davecgh/go-spew/spew
)
type IndexController struct {
BaseController //这里继承了我之前写的基类控制器,可替换为beego.Controller
}
type UserDb struct {
Id int `json:"id" orm:"column(id)"`
Account string `json:"account" orm:"column(account)&