github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/routers/ContactHandler.go (about)

     1  package routers
     2  
     3  import (
     4  	"github.com/insionng/makross"
     5  	"github.com/insionng/yougam/models"
     6  )
     7  
     8  func GetContactHandler(self *makross.Context) error {
     9  
    10  	self.Set("catpage", "ContactHandler")
    11  	self.Set("messager", true)
    12  
    13  	offset := self.Param("offset").MustInt()
    14  	if offset <= 0 {
    15  		offset = self.Args("offset").MustInt()
    16  	}
    17  
    18  	limit := self.Param("limit").MustInt()
    19  	if offset <= 0 {
    20  		limit = self.Args("limit").MustInt()
    21  	}
    22  
    23  	limit = 16 //临时设置,以后再增加翻页处理
    24  
    25  	allow := false
    26  	self.Set("contactHome", false)
    27  	self.Set("contactSearch", false)
    28  
    29  	if self.RequestURI() == "/contact/" {
    30  		allow = false
    31  		self.Set("contactHome", true)
    32  	}
    33  
    34  	if self.RequestURI() == "/contact/search/" {
    35  		allow = false
    36  		self.Set("contactSearch", true)
    37  	}
    38  
    39  	if (self.RequestURI() == "/contact/") || (self.RequestURI() == "/contact/search/") {
    40  		u, e := models.GetUsersOnHotness(offset, limit, "created")
    41  		if (e == nil) && (u != nil) {
    42  			self.Set("UsersByCreated", u)
    43  		}
    44  
    45  		u_, e_ := models.GetUsersOnHotness(offset, limit, "confidence")
    46  		if (e_ == nil) && (u_ != nil) {
    47  			self.Set("UsersByConfidence", u_)
    48  		}
    49  	}
    50  
    51  	self.Set("allow", allow)
    52  	return self.Render("contact")
    53  
    54  }