Replies: 1 comment 15 replies
-
Waline API 是基于 RESTful API 语义的,除了 基于功能语义的 API 确实能让每个功能更好的拆分,但它不好的地方在于会写非常多的重复代码。比如你列举的这几个 API,其实本质就是去修改 comment 表的某个字段,但如果拆分4个控制器的话,这个同样的数据库操作你就要写四遍。
Waline API 的 RESTful 语义不算特别完美,但也不至于稀烂~ 你可以先说下你要做什么以及你的诉求,我看下怎么组织处理会比较好? Waline API is based on RESTful API semantics, except for The API based on functional semantics can indeed make each function better split, but its disadvantage is that it will write a lot of repetitive code. For example, the APIs you listed are actually to modify a certain field in the comment table, but if you split the four controllers, you have to write the same database operation four times.
The RESTful semantics of the Waline API are not particularly perfect, but they are not rotten~ You can first talk about what you want to do and your demands, and let me see how to organize and handle it better? |
Beta Was this translation helpful? Give feedback.
-
Describe the bug | 问题描述
https://waline.js.org/reference/server/api.html
能不能URL规则点:
GET /api/comment/list 列表
POST /api/comment/insert 添加
POST /api/comment/update 编辑
POST /api/comment/like 点赞
POST /api/comment/status 通过/审核/垃圾
POST /api/comment/sticky 置顶
怎么实现这样,后端代码总是在一个comment方法里面写判断,代码写的稀烂,我想在comment控制器里面,定义各种方法。。这样结构清晰。
Website URL | 问题网站
https://waline.js.org/reference/server/api.html
Where your waline deploy? | 服务部署在哪里?
Vercel (Default)
Where your comment data store? | 数据存储在哪里?
LeanCloud(https://leancloud.app)
Describe the bug | Problem description
https://waline.js.org/reference/server/api.html
Can you point to URL rules:
GET /api/comment/list list
POST /api/comment/insert add
POST /api/comment/updateEdit
POST /api/comment/like like
POST /api/comment/status pass/review/trash
POST /api/comment/sticky sticky
How to achieve this, the back-end code always writes judgments in a comment method, the code is poorly written, I want to define various methods in the comment controller. . This structure is clear.
Website URL | Problem Website
https://waline.js.org/reference/server/api.html
Where your waline deploy? | Where is the service deployed?
Vercel (Default)
Where your comment data store? | Where is your comment data store?
LeanCloud (https://leancloud.app)
Beta Was this translation helpful? Give feedback.
All reactions