Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package controllers
- import (
- "fmt"
- "github.com/astaxie/beego"
- "gopkg.in/mgo.v2"
- "gopkg.in/mgo.v2/bson"
- )
- type MainController struct {
- beego.Controller
- }
- type ViewController struct {
- beego.Controller
- }
- type Pen_hws struct {
- Afd_guid string
- Areaid string
- Hws_latex string
- Hws_origin string
- Hws_png string
- Pageid string
- Penid string
- Questionid string
- stuid string
- }
- func (c *MainController) Get() {
- c.Data["Website"] = "beego.me"
- c.Data["Email"] = "astaxie@gmail.com"
- c.TplNames = "index.tpl"
- }
- func (c *ViewController) Get() {
- session, err := mgo.Dial("10.3.255.102")
- if err != nil {
- panic(err)
- }
- defer session.Close()
- session.SetMode(mgo.Monotonic, true)
- conn := session.DB("btpen_hws").C("pen_hws")
- c.Data["Title"] = "点阵笔迹管理系统"
- c.Data["afd_guid"] = c.GetString("afd_guid")
- c.Data["questionid"] = c.GetString("questionid")
- c.Data["penid"] = c.GetString("penid")
- fmt.Println("afd_guid", c.Data["afd_guid"])
- fmt.Println("questionid", c.Data["questionid"])
- fmt.Println("penid", c.Data["penid"])
- find_pen_hws := bson.M{}
- if c.Data["afd_guid"] != {} {
- fmt.Println("afd_guid:", c.Data["afd_guid"])
- find_pen_hws["afd_guid"] = c.Data["afd_guid"]
- }
- if c.Data["questionid"] != nil {
- find_pen_hws["questionid"] = c.Data["questionid"]
- }
- if c.Data["penid"] != nil {
- find_pen_hws["penid"] = c.Data["penid"]
- }
- fmt.Println(find_pen_hws)
- var all_pen_hws []Pen_hws
- err = conn.Find(find_pen_hws).All(&all_pen_hws)
- if err != nil {
- panic(err)
- }
- c.Data["items"] = all_pen_hws
- //find_pen_hws := make(map[string]string)
- c.TplNames = "btpen_hws_viewall.tpl"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement