合并JWL,WZY,TRM代码

Change-Id: Ifb4fcad3c06733e1e005e7d8d9403e3561010fb4
diff --git a/TRM/front/src/api/posts.js b/TRM/front/src/api/posts.js
index a42e781..012cd00 100644
--- a/TRM/front/src/api/posts.js
+++ b/TRM/front/src/api/posts.js
@@ -13,7 +13,16 @@
     body: JSON.stringify({ userid: userId })
   })
   if (!res.ok) throw new Error(`fetchPosts: ${res.status}`)
-  return res.json()
+  
+  const json = await res.json()
+  console.log('fetchPosts response:', json)         // debug: inspect shape
+  
+  // normalize: if it's already an array use it; else pull array out of known keys
+  const list = Array.isArray(json)
+    ? json
+    : json.data || json.posts || []
+  
+  return list
 }
 
 /**
@@ -59,4 +68,50 @@
   })
   if (!res.ok) throw new Error(`fetchPost: ${res.status}`)
   return res.json()
+}
+
+/**
+ * 获取超级管理员用户列表
+ * POST /sgetuserlist
+ * @param {number|string} userId 平台管理员的用户 ID
+ * @returns Promise<[ {id, name, role}, … ]>
+ */
+export async function fetchUserList(userId) {
+  const res = await fetch(`${BASE}/sgetuserlist`, {
+    method: 'POST',
+    headers: { 'Content-Type': 'application/json' },
+    body: JSON.stringify({ userid: userId })
+  })
+  if (!res.ok) throw new Error(`fetchUserList: ${res.status}`)
+  return res.json()
+}
+
+export async function giveAdmin(userId, targetId) {
+  const res = await fetch(`${BASE}/sgiveadmin`, {
+    method: 'POST',
+    headers: { 'Content-Type': 'application/json' },
+    body: JSON.stringify({ userid: userId, targetid: targetId })
+  })
+  if (!res.ok) throw new Error(`giveAdmin: ${res.status}`)
+  return res.json()
+}
+
+export async function giveSuperAdmin(userId, targetId) {
+  const res = await fetch(`${BASE}/sgivesuperadmin`, {
+    method: 'POST',
+    headers: { 'Content-Type': 'application/json' },
+    body: JSON.stringify({ userid: userId, targetid: targetId })
+  })
+  if (!res.ok) throw new Error(`giveSuperAdmin: ${res.status}`)
+  return res.json()
+}
+
+export async function giveUser(userId, targetId) {
+  const res = await fetch(`${BASE}/sgiveuser`, {
+    method: 'POST',
+    headers: { 'Content-Type': 'application/json' },
+    body: JSON.stringify({ userid: userId, targetid: targetId })
+  })
+  if (!res.ok) throw new Error(`giveUser: ${res.status}`)
+  return res.json()
 }
\ No newline at end of file