Files
ClassContent/项目合集/在包河后端/routes/detail.js
2024-09-27 02:06:13 +08:00

206 lines
7.6 KiB
JavaScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const obj = (id) => {
if (id === 1) {
return {
id: 1,
video: "https://www.runoob.com/try/demo_source/movie.ogg"
}
}
return {
id: 2,
video: "https://www.runoob.com/try/demo_source/movie.ogg"
}
}
const comment = [
{
id: 1,
headUrl: "https://upload.jianshu.io/users/upload_avatars/301940/189d69dd-af7c-4290-9e2c-89e98acf3603.jpg?imageMogr2/auto-orient/strip|imageView2/1/w/96/h/96/format/webp",
name: "白勺啊达",
creatTime: 1653891944578,
like: 30,
content: "歌名:判你[doge][歪嘴]"
},
{
id: 2,
headUrl: "https://upload.jianshu.io/users/upload_avatars/301940/189d69dd-af7c-4290-9e2c-89e98acf3603.jpg?imageMogr2/auto-orient/strip|imageView2/1/w/96/h/96/format/webp",
name: "汽水不自闭",
creatTime: 1653891944578,
like: 30,
content: "爱你"
},
{
id: 3,
headUrl: "https://upload.jianshu.io/users/upload_avatars/301940/189d69dd-af7c-4290-9e2c-89e98acf3603.jpg?imageMogr2/auto-orient/strip|imageView2/1/w/96/h/96/format/webp",
name: "三木刃",
creatTime: 1653891944578,
like: 130,
content: "爱你"
},
{
id: 4,
headUrl: "https://upload.jianshu.io/users/upload_avatars/301940/189d69dd-af7c-4290-9e2c-89e98acf3603.jpg?imageMogr2/auto-orient/strip|imageView2/1/w/96/h/96/format/webp",
name: "爱狂三的星总",
creatTime: 1653891944578,
like: 500,
content: "久违的,本来以为你会做听我说谢谢你,结果没做"
}
]
const post = {
lunbo: [
"https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/89fbb601177fec95fd14af5a9cc257e0.jpg?thumb=1&w=720&h=360",
"https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/e25dd7488f695942cfbfd9468ac2c3e7.jpg?thumb=1&w=720&h=360",
"https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/259e5a92a441adb6bd8e2f484987ace6.jpg?thumb=1&w=720&h=360"
],
id: 1,
headUrl: "http://i1.hdslb.com/bfs/face/3c54240c8c92fd43fa0ee87f8bb42b39b2877055.jpg@96w_96h_1c_1s.webp",
name: "白勺啊达",
creatTime: 1653891944578,
like: 30,
content: "歌名:判你[doge][歪嘴]",
comment: comment,
}
const news = (id) => {
if (id == 1) {
return {
title: "台达伺服电机ASDA-B3",
head: "https://i2.hdslb.com/bfs/face/7622fe500d64cac1ba2b7311a25ef904d2311551.jpg@160w_160h_1c_1s.webp",
creatTime: 1653048900000,
browse: 131000,
content: `台达伺服电机ASDA-B3系列已经发布几年了相对于前代升级了很多方面下面就让台达代理商—吉创来为我们科普台达伺服电机ASDA-B3系列。 作者:吉创达减速机厂家 https://www.bilibili.com/read/cv16671272?from=search&spm_id_from=333.337.0.0 出处bilibili`,
comment: comment,
relevantRecommendations: [
{
content: "台达伺服电机ASDA-B3",
creatTime: 1653048900000,
image: "https://i0.hdslb.com/bfs/article/14cddf36b3efde98e3bc8733c8cde181bcb5e621.png@810w_1311h_progressive.webp"
},
{
content: "【韩网新闻】金钟国x尹恩惠在刘在石不知情的情况下“恋爱”…“视网膜”重新点燃",
creatTime: 1653048900000,
image: "https://i0.hdslb.com/bfs/article/2d3eacf786742f88d1235d305faf8c9497863fd7.png@810w_455h_progressive.webp"
},
]
}
}
return {
title: "金钟国x尹恩惠",
head: "https://i0.hdslb.com/bfs/face/11f217565887b25bb3a9ab515134043feab9eeeb.jpg@160w_160h_1c_1s.webp",
creatTime: 1653048900000,
browse: 131000,
content: `如果经常发生的事情重迭,就会这样,但如果特别的回忆重迭,就很难看作是偶然。随着接二连三的记忆重迭,他们再次戴上了对金钟国和尹恩惠的望鹏隐形眼镜。
金钟国和尹恩惠的“恋爱”再次被曝光是因为尹恩惠在17日上传后急忙删除的youtube。尹恩惠在视频中回想着和前男友的回忆说“大部分男人在恋爱初期都会发很多短信过了一段时间联系不是会减少吗?我把男友发过的短信都写在小本子上送给了前男友。”
尹恩惠说:“对方也是好人。看到自己的短信变成简答型,偶尔联系,感到很抱歉。”
“把短信写在笔记本上作为礼物”的插曲虽然不是常见的事情但不知不觉间已经很熟悉了。这与金钟国在2018年SBS《我家的熊孩子》中整理阁楼时发现情书的情况一模一样。 作者:懵钟一起有点甜 https://www.bilibili.com/read/cv16710140?from=search&spm_id_from=333.337.0.0 出处bilibili`,
comment: comment,
relevantRecommendations: [
{
content: "台达伺服电机ASDA-B3",
creatTime: 1653048900000,
image: "https://i0.hdslb.com/bfs/article/14cddf36b3efde98e3bc8733c8cde181bcb5e621.png@810w_1311h_progressive.webp"
},
{
content: "【韩网新闻】金钟国x尹恩惠在刘在石不知情的情况下“恋爱”…“视网膜”重新点燃",
creatTime: 1653048900000,
image: "https://i0.hdslb.com/bfs/article/2d3eacf786742f88d1235d305faf8c9497863fd7.png@810w_455h_progressive.webp"
},
]
}
}
var express = require('express');
var router = express.Router();
router.get('/detail', function (req, res, next) {
const { id } = req.query
if (!!id) {
res.json({
status: 200,
message: '请求成功',
data: obj(id)
});
return
}
res.json({
status: 500,
message: '请求失败',
data: null
});
});
// // 评论接口
// router.get('/comment', function (req, res, next) {
// const { id } = req.query
// res.json({
// status: 200,
// message: '请求成功',
// data: comment
// });
// });
/**
* @api {get} /post /post
* @apiDescription 帖子 页面
* @apiName post
* @apiGroup 接口
* @apiParam {number} id 帖子详情id
* @apiSuccessExample {json} 请求成功的返回:
* {
* "status" : 200,
* "message" : "请求成功"
* "result" : "asjXzXxmnSp8TZGWiTSlJF8Gb...5LhYoHs86SEI2LBXrTZ9e/a4frZOWHZ"
* }
* @apiErrorExample {json} 请求失败的返回
* {
* "status": 404,
* "message" : "请求失败"
* "result": null
* }
* @apiSampleRequest http://127.0.0.1:3000/api/json/post?id=14
* @apiVersion 1.0.0
*/
router.get('/post', function (req, res, next) {
const { id } = req.query
res.json({
status: 200,
message: '请求成功',
data: post
});
});
/**
* @api {get} /news /news
* @apiDescription 新闻 页面
* @apiName news
* @apiGroup 接口
* @apiParam {number} id 新闻详情id
* @apiSuccessExample {json} 请求成功的返回:
* {
* "status" : 200,
* "message" : "请求成功"
* "result" : "asjXzXxmnSp8TZGWiTSlJF8Gb...5LhYoHs86SEI2LBXrTZ9e/a4frZOWHZ"
* }
* @apiErrorExample {json} 请求失败的返回
* {
* "status": 404,
* "message" : "请求失败"
* "result": null
* }
* @apiSampleRequest http://127.0.0.1:3000/api/json/news?id=1
* @apiVersion 1.0.0
*/
//
router.get('/news', function (req, res, next) {
const { id } = req.query
res.json({
status: 200,
message: '请求成功',
data: news(id)
});
});
module.exports = router;