收藏夹
()
| 200 | |
| 201 | // 收藏夹 |
| 202 | func (this *UserController) Collect() { |
| 203 | this.Data["Tab"] = "collect" |
| 204 | action := this.GetString("action") |
| 205 | uid, _ := this.GetInt(":uid") |
| 206 | p, _ := this.GetInt("p", 1) |
| 207 | if p < 1 { |
| 208 | p = 1 |
| 209 | } |
| 210 | if uid < 1 { |
| 211 | uid = this.IsLogin |
| 212 | } |
| 213 | |
| 214 | if uid <= 0 { |
| 215 | this.Redirect("/user/login", 302) |
| 216 | return |
| 217 | } |
| 218 | |
| 219 | listRows := 100 |
| 220 | lists, _, _ := models.GetList(models.GetTableCollectFolder(), p, listRows, orm.NewCondition().And("Uid", uid), "-Id") |
| 221 | if p > 1 { // 页码大于1,以 JSON 返回数据 |
| 222 | this.ResponseJson(true, "数据获取成功", lists) |
| 223 | } |
| 224 | |
| 225 | user, rows, err := models.NewUser().GetById(uid) |
| 226 | if err != nil { |
| 227 | helper.Logger.Error(err.Error()) |
| 228 | } |
| 229 | if rows == 0 { |
| 230 | this.Redirect("/", 302) |
| 231 | return |
| 232 | } |
| 233 | this.Data["Lists"] = lists |
| 234 | this.Data["User"] = user |
| 235 | this.Data["PageId"] = "wenku-user" |
| 236 | this.Data["IsUser"] = true |
| 237 | this.Data["Uid"] = uid |
| 238 | this.Data["Ranks"], _, err = models.NewUser().UserList(1, 8, "i.Document desc", "u.Id,u.Username,u.Avatar,u.Intro,i.Document", "i.Status=1") |
| 239 | if err != nil { |
| 240 | helper.Logger.Error(err.Error()) |
| 241 | } |
| 242 | this.TplName = "collect.html" |
| 243 | this.Data["Seo"] = models.NewSeo().GetByPage("PC-Ucenter-Folder", "收藏夹—会员中心-"+user["Username"].(string), "会员中心,收藏夹,"+user["Username"].(string), "收藏夹—会员中心-"+user["Username"].(string), this.Sys.Site) |
| 244 | if action == "edit" { |
| 245 | this.Data["Edit"] = true |
| 246 | } else { |
| 247 | this.Data["Edit"] = false |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | //用户登录 |
| 252 | func (this *UserController) Login() { |
nothing calls this directly
no test coverage detected