diff --git a/model/lyf.js b/model/lyf.js index e083982a52074ed57d2ba36313a34d59891cc929..5f10dc90e7f41112f99fe42fd14bd0cbabf61a69 100644 --- a/model/lyf.js +++ b/model/lyf.js @@ -23,20 +23,35 @@ let performanceSchema = new Schema({ value: Array, }); +let anyimgSchema = new Schema({ + img: Array, + title: String, +}); + let AsspModel = mongoose.model("assp", AsspSchame); let categoryModel = mongoose.model("category", categorySchema); let economicModel = mongoose.model("economic", economicSchema); let salesModel = mongoose.model("sales", salesScheme); let performanceModel = mongoose.model("performance", performanceSchema); +let anyimgModel = mongoose.model("anyimg", anyimgSchema); // performanceModel.create({ // value: [100, 200, 300, 400, 500, 450, 380], // }); +// anyimgModel.create({ +// title: "美颜", +// img: [ +// "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.alicdn.com%2Fbao%2Fuploaded%2Fi4%2F2200790215397%2FO1CN012Asjv31pjs8z7Qp0E_%21%210-item_pic.jpg&refer=http%3A%2F%2Fimg.alicdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1720314264&t=b579a52258c5e641157aeb211c8d6f21", +// "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.alicdn.com%2Fbao%2Fuploaded%2Fi4%2F2200790215397%2FO1CN012Asjv31pjs8z7Qp0E_%21%210-item_pic.jpg&refer=http%3A%2F%2Fimg.alicdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1720314264&t=b579a52258c5e641157aeb211c8d6f21", +// ], +// }); + module.exports = { AsspModel, categoryModel, economicModel, salesModel, performanceModel, + anyimgModel }; diff --git a/routes/lyf.js b/routes/lyf.js index 4e699c0fdb38ee790bc2fca3f27568e1955e0ea3..9dcca9a364fa1e28870a73f6b766c086318ba8fe 100644 --- a/routes/lyf.js +++ b/routes/lyf.js @@ -6,8 +6,10 @@ let { economicModel, salesModel, performanceModel, + anyimgModel, } = require("../model/lyf.js"); +var { goodsListModel } = require("../model/whz"); router.get("/getassp", async (req, res) => { let data = await AsspModel.find(); @@ -18,17 +20,8 @@ router.get("/getassp", async (req, res) => { }); }); -router.get("/getcategory", async (req, res) => { - let data = await categoryModel.find(); - res.send({ - status: 0, - message: "获取成功", - data, - }); -}); - -router.get("/geteconomic", async (req, res) => { - let data = await economicModel.find(); +router.get("/getsales", async (req, res) => { + let data = await goodsListModel.find(); res.send({ status: 0, message: "获取成功", @@ -36,8 +29,8 @@ router.get("/geteconomic", async (req, res) => { }); }); -router.get("/getsales", async (req, res) => { - let data = await salesModel.find(); +router.get("/getperformance", async (req, res) => { + let data = await performanceModel.find(); res.send({ status: 0, message: "获取成功", @@ -45,8 +38,8 @@ router.get("/getsales", async (req, res) => { }); }); -router.get("/getperformance", async (req, res) => { - let data = await performanceModel.find(); +router.get("/getanyimg", async (req, res) => { + let data = await anyimgModel.find(); res.send({ status: 0, message: "获取成功", @@ -62,13 +55,11 @@ router.get("/events", (req, res) => { Connection: "keep-alive", //持续发送数据 }); res.flushHeaders(); - const custom_event_interval = setInterval(() => { - res.write("event: ping\n"); - res.write(`data:${Date.now()}\n\n`); //信息发送 + const interval = setInterval(() => { + res.write(`data:${Date()}\n\n`); }, 5000); res.on("close", () => { - // clearInterval(interval); - clearInterval(custom_event_interval); + clearInterval(interval); res.end(); }); });