MCPcopy Index your code
hub / github.com/TruthHun/BookStack / PostComment

Method PostComment

controllers/api/LoginedController.go:150–175  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

148}
149
150func (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
177func (this *LoginedController) ChangePassword() {
178 old := this.GetString("old")

Callers

nothing calls this directly

Calls 5

ResponseMethod · 0.80
getBookIdByIdentifyMethod · 0.80
AddCommentsMethod · 0.80
isLoginMethod · 0.80
AddScoreMethod · 0.80

Tested by

no test coverage detected