Skip to content

Commit

Permalink
🌈 修复短评,联调成功
Browse files Browse the repository at this point in the history
AqingCyan committed Jan 25, 2020
1 parent bc72bea commit d9315f5
Showing 5 changed files with 13 additions and 9 deletions.
8 changes: 4 additions & 4 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion app/api/v1/book.js
Original file line number Diff line number Diff line change
@@ -53,7 +53,11 @@ router.post('/add/short_comment', new Auth().m, async ctx => {
// 获取书籍短评
router.get('/:book_id/short_comment', new Auth().m, async ctx => {
const v = await new PositiveIntegerValidator().validate(ctx, { id: 'book_id' })
ctx.body = await Comment.getComments(v.get('path.book_id'))
const bookId = v.get('path.book_id')
ctx.body = {
comments: await Comment.getComments(bookId),
book_id: bookId,
}
})

// 模拟一个热搜接口(web开发无法解决)
2 changes: 1 addition & 1 deletion app/model/book-comment.js
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ class Comment extends Model {
Comment.prototype.exclude = ['book_id', 'id']

Comment.init({
content: Sequelize.STRING(24),
content: Sequelize.STRING(12),
nums: {
type: Sequelize.INTEGER,
defaultValue: 0,
4 changes: 2 additions & 2 deletions app/validators/validator.js
Original file line number Diff line number Diff line change
@@ -157,9 +157,9 @@ class AddShortComment extends PositiveIntegerValidator {
constructor() {
super()
this.content = [
new Rule('isLength', '长度必须在1到24之间', {
new Rule('isLength', '长度必须在1到12之间', {
min: 1,
max: 24,
max: 12,
}),
]
}
2 changes: 1 addition & 1 deletion example/pages/index/index.js
Original file line number Diff line number Diff line change
@@ -231,7 +231,7 @@ Page({
url: 'http://localhost:10086/v1/book/add/short_comment',
method: 'POST',
data: {
content: '春风十里不如有你春风十里不如有你',
content: '春风十里不如有你',
book_id: 1120
},
success: res => {

0 comments on commit d9315f5

Please sign in to comment.