()
| 148 | } |
| 149 | |
| 150 | func (this *LoginedController) PostComment() { |
| 151 | content := this.GetString("content") |
| 152 | pid, _ := this.GetInt("pid") |
| 153 | docId, _ := this.GetInt("doc_id") |
| 154 | if l := len(content); l < 5 || l > 255 { |
| 155 | this.Response(http.StatusBadRequest, "点评内容限定 5 - 255 个字符") |
| 156 | } |
| 157 | bookId := this.getBookIdByIdentify(this.GetString("identify")) |
| 158 | |
| 159 | if bookId <= 0 { |
| 160 | this.Response(http.StatusBadRequest, messageBadRequest) |
| 161 | } |
| 162 | |
| 163 | err := new(models.Comments).AddComments(this.isLogin(), bookId, pid, docId, content) |
| 164 | if err != nil { |
| 165 | this.Response(http.StatusBadRequest, err.Error()) |
| 166 | } |
| 167 | |
| 168 | // 点评成功之后,再写入评分。如果之前的评分已存在,则不会再重新写入 |
| 169 | score, _ := this.GetInt("score") |
| 170 | if score > 0 && score <= 5 { |
| 171 | new(models.Score).AddScore(this.isLogin(), bookId, score) |
| 172 | } |
| 173 | |
| 174 | this.Response(http.StatusOK, messageSuccess) |
| 175 | } |
| 176 | |
| 177 | func (this *LoginedController) ChangePassword() { |
| 178 | old := this.GetString("old") |
nothing calls this directly
no test coverage detected