youbbs
youbbs
2482 0 0

提醒数不对的矫正方法

提醒数永远消不了,即提醒数大于零,提醒文章列表是空的。
由于官网没有遇到这样的情况,如果您遇到请在这里回复或在github 上反馈

https://github.com/ego008/goyoubbs/issues/25

不管有没有出现这样的问题,在提醒页函数添加下面的判断能在出现不一致时有效的矫正:

	// fix currentUser.NoticeNum != len(evn.PageInfo.Items)
	if currentUser.NoticeNum != len(evn.PageInfo.Items) {
		var newKeys []string
		for _, item := range evn.PageInfo.Items {
			newKeys = append(newKeys, strconv.FormatUint(item.Id, 10))
		}

		currentUser.Notice = strings.Join(newKeys, ",")
		currentUser.NoticeNum = len(newKeys)

		jb, _ := json.Marshal(currentUser)
		db.Hset("user", youdb.I2b(currentUser.Id), jb)

		evn.CurrentUser = currentUser
	}

https://github.com/ego008/goyoubbs/blob/master/controller/user.go#L215-L229

0

See Also

Nearby


Discussion

Login Topics