完成基本审核功能
Change-Id: Ib93823f864d5340b034a37af4e4cb3fb2cd5491a
diff --git a/TRM/front/src/api/posts.js b/TRM/front/src/api/posts.js
new file mode 100644
index 0000000..a42e781
--- /dev/null
+++ b/TRM/front/src/api/posts.js
@@ -0,0 +1,62 @@
+const BASE = 'http://10.126.59.25:5713' // 后端地址
+
+/**
+ * 获取待审核的帖子列表
+ * POST /apostlist
+ * @param {number|string} userId 平台管理员的用户 ID
+ * @returns Promise<[ {id, title, status}, … ]>
+ */
+export async function fetchPosts(userId) {
+ const res = await fetch(`${BASE}/apostlist`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ userid: userId })
+ })
+ if (!res.ok) throw new Error(`fetchPosts: ${res.status}`)
+ return res.json()
+}
+
+/**
+ * 审核通过
+ * POST /areview
+ */
+export async function approvePost(postId, userId) {
+ const res = await fetch(`${BASE}/areview`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ userid: userId, postid: postId, status: 'published' })
+ })
+ if (!res.ok) throw new Error(`approvePost: ${res.status}`)
+ return res.json()
+}
+
+/**
+ * 驳回
+ * POST /areview
+ */
+export async function rejectPost(postId, userId) {
+ const res = await fetch(`${BASE}/areview`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ userid: userId, postid: postId, status: 'rejected' })
+ })
+ if (!res.ok) throw new Error(`rejectPost: ${res.status}`)
+ return res.json()
+}
+
+/**
+ * 获取单个帖子详情
+ * POST /agetpost
+ * @param {number|string} postId 帖子 ID
+ * @param {number|string} userId 平台管理员的用户 ID
+ * @returns Promise<{id, title, content, status}>
+ */
+export async function fetchPost(postId, userId) {
+ const res = await fetch(`${BASE}/agetpost`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ userid: userId, postid: postId })
+ })
+ if (!res.ok) throw new Error(`fetchPost: ${res.status}`)
+ return res.json()
+}
\ No newline at end of file