// 新加入会员 // uri: /users/newest.json func NewestUserHandler(rw http.ResponseWriter, req *http.Request) { newestUsers := service.FindNewUsers(0, 9) buf, err := json.Marshal(newestUsers) if err != nil { logger.Errorln("[NewestUserHandler] json.marshal error:", err) fmt.Fprint(rw, `{"ok": 0, "error":"解析json出错"}`) return } fmt.Fprint(rw, `{"ok": 1, "data":`+string(buf)+`}`) }
// 会员列表 // URI: /users func UsersHandler(rw http.ResponseWriter, req *http.Request) { // 获取活跃会员 activeUsers := service.FindActiveUsers(0, 30) // 获取最新加入会员 newUsers := service.FindNewUsers(0, 30) // 获取会员总数 total := service.CountUsers() req.Form.Set(filter.CONTENT_TPL_KEY, "/template/user/users.html") // 设置模板数据 filter.SetData(req, map[string]interface{}{"activeUsers": "active", "actives": activeUsers, "news": newUsers, "total": total}) }