// @Title 阅读消息 // @router /readNoticeByStudent [post] func (this *APIStudentController) ReadNoticeByStudent() { // recevie data if user_type := this.GetSession("type").(string); user_type != "学生" { this.SendFailedJSON(1, "操作失败") return } s_id := this.GetSession("id").(string) if models.CountNotReadStudentNotice(s_id) > 0 { send_id, _ := this.GetInt64("sender") if err := models.ReadNoticeByStudent(s_id, this.GetString("sender_type"), send_id); err != nil { this.SendFailedJSON(1, "操作失败") return } } this.SendSuccessJSON("操作成功") return }
func (this *ViewStudentController) Prepare() { // get session user_type := this.GetSession("type").(string) if user_type == "学生" { id := this.GetSession("id").(string) if len(id) > 0 { student, err := models.GetStudentById(id) if err == nil { this.Data["student"] = student // 获取未阅读的通知 this.Data["noticeNum"] = models.CountNotReadStudentNotice(student.Id) // 设置操作签名,获取签名参数 appid, sessid := this.SetSignature() this.Data["appid"] = appid this.Data["sessid"] = sessid this.Data["key"] = models.Str2Sha1(this.Ctx.Input.Cookie("beegosessionID")) return } } } this.Redirect("/error", 302) this.StopRun() }