feat(admin): complete post management, finance csv export, and wechat message template config

这个提交包含在:
xcbyy
2026-10-13 11:11:40 +08:00
父节点 3bb6f5a6be
当前提交 736450973e
共有 11 个文件被更改,包括 951 次插入 和 4 次删除

查看文件

@@ -1686,6 +1686,84 @@ app.get('/api/posts', async (req: Request, res: Response) => {
}
});
// 管理端:全量动态管理与检索
app.get('/api/admin/posts', async (req: Request, res: Response) => {
try {
const category = req.query.category ? String(req.query.category) : undefined;
const keyword = req.query.keyword ? String(req.query.keyword) : undefined;
const status = req.query.status ? String(req.query.status) : undefined;
const posts = await repo.getPosts(category, keyword, status);
res.json({ code: 20000, data: posts });
} catch (err: any) {
res.status(500).json({ code: 50000, message: err.message });
}
});
// 管理端:切换置顶状态
app.post('/api/admin/posts/:id/top', async (req: Request, res: Response) => {
try {
const postId = String(req.params.id);
const { isTop } = req.body;
await repo.togglePostTop(postId, Boolean(isTop));
res.json({ code: 20000, message: isTop ? '置顶成功' : '已取消置顶' });
} catch (err: any) {
res.status(400).json({ code: 40000, message: err.message });
}
});
// 管理端:切换显示/隐藏状态
app.post('/api/admin/posts/:id/status', async (req: Request, res: Response) => {
try {
const postId = String(req.params.id);
const { status } = req.body;
await repo.updatePostStatus(postId, String(status));
res.json({ code: 20000, message: '动态状态更新成功' });
} catch (err: any) {
res.status(400).json({ code: 40000, message: err.message });
}
});
// 管理端:违规下架彻底删除
app.delete('/api/admin/posts/:id', async (req: Request, res: Response) => {
try {
const postId = String(req.params.id);
await repo.adminDeletePost(postId);
res.json({ code: 20000, message: '违规动态及关联评论已彻底删除' });
} catch (err: any) {
res.status(400).json({ code: 40000, message: err.message });
}
});
// 管理端:删除单条不当评论
app.delete('/api/admin/posts/comments/:commentId', async (req: Request, res: Response) => {
try {
const commentId = String(req.params.commentId);
await repo.adminDeletePostComment(commentId);
res.json({ code: 20000, message: '违规评论已删除' });
} catch (err: any) {
res.status(400).json({ code: 40000, message: err.message });
}
});
// 管理端:微信订阅消息与服务通知模拟测试推送接口
app.post('/api/admin/message/test-send', async (req: Request, res: Response) => {
try {
const { templateType, targetUserId, previewData } = req.body;
// 模拟微信服务器发送模版消息
const result = {
templateType: templateType || 'order_status',
targetUserId: targetUserId || 1001,
sendTime: new Date().toISOString(),
status: 'SUCCESS',
wechatMsgId: `wx_msg_${Date.now()}`,
previewData: previewData || { title: '订单履约提醒', detail: '您的同城生活陪伴订单已开始服务' }
};
res.json({ code: 20000, data: result, message: '微信模板消息模拟发送成功' });
} catch (err: any) {
res.status(400).json({ code: 40000, message: err.message });
}
});
app.post('/api/posts', async (req: Request, res: Response) => {
try {
const { content } = req.body || {};