Advertisement
Guest User

Untitled

a guest
May 29th, 2015
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. package controllers
  2.  
  3. import (
  4. "fmt"
  5. "github.com/astaxie/beego"
  6. "gopkg.in/mgo.v2"
  7. "gopkg.in/mgo.v2/bson"
  8. )
  9.  
  10. type MainController struct {
  11. beego.Controller
  12. }
  13.  
  14. type ViewController struct {
  15. beego.Controller
  16. }
  17.  
  18. type Pen_hws struct {
  19. Afd_guid string
  20. Areaid string
  21. Hws_latex string
  22. Hws_origin string
  23. Hws_png string
  24. Pageid string
  25. Penid string
  26. Questionid string
  27. stuid string
  28. }
  29.  
  30. func (c *MainController) Get() {
  31. c.Data["Website"] = "beego.me"
  32. c.Data["Email"] = "astaxie@gmail.com"
  33. c.TplNames = "index.tpl"
  34. }
  35.  
  36. func (c *ViewController) Get() {
  37. session, err := mgo.Dial("10.3.255.102")
  38. if err != nil {
  39. panic(err)
  40. }
  41. defer session.Close()
  42. session.SetMode(mgo.Monotonic, true)
  43.  
  44. conn := session.DB("btpen_hws").C("pen_hws")
  45.  
  46. c.Data["Title"] = "点阵笔迹管理系统"
  47. c.Data["afd_guid"] = c.GetString("afd_guid")
  48. c.Data["questionid"] = c.GetString("questionid")
  49. c.Data["penid"] = c.GetString("penid")
  50. fmt.Println("afd_guid", c.Data["afd_guid"])
  51. fmt.Println("questionid", c.Data["questionid"])
  52. fmt.Println("penid", c.Data["penid"])
  53.  
  54. find_pen_hws := bson.M{}
  55. if c.Data["afd_guid"] != {} {
  56. fmt.Println("afd_guid:", c.Data["afd_guid"])
  57. find_pen_hws["afd_guid"] = c.Data["afd_guid"]
  58. }
  59. if c.Data["questionid"] != nil {
  60. find_pen_hws["questionid"] = c.Data["questionid"]
  61. }
  62. if c.Data["penid"] != nil {
  63. find_pen_hws["penid"] = c.Data["penid"]
  64. }
  65. fmt.Println(find_pen_hws)
  66.  
  67. var all_pen_hws []Pen_hws
  68. err = conn.Find(find_pen_hws).All(&all_pen_hws)
  69. if err != nil {
  70. panic(err)
  71. }
  72.  
  73. c.Data["items"] = all_pen_hws
  74. //find_pen_hws := make(map[string]string)
  75. c.TplNames = "btpen_hws_viewall.tpl"
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement