From ccc4f14138f5f19a3a3ded311ef0d1d892a78a60 Mon Sep 17 00:00:00 2001 From: yy <1952755664@qq.com> Date: Sun, 10 Nov 2024 19:06:35 +0800 Subject: [PATCH] wxy1 --- app.js | 31 ++++- models/model.js | 27 +++- node_modules/.package-lock.json | 115 ++++++++++++++++ package-lock.json | 216 +++++++++++++++++++++++++++++ package.json | 3 +- routes/Notice.js | 5 +- routes/wxy.js | 234 +++++++++++++++++++++++++++++++- 7 files changed, 620 insertions(+), 11 deletions(-) diff --git a/app.js b/app.js index 7bcb842..b1e5724 100644 --- a/app.js +++ b/app.js @@ -6,7 +6,7 @@ var logger = require("morgan"); const mount = require("mount-routes"); const cors = require("cors"); - +const multer = require('multer') var app = express(); app.use(cors()); @@ -39,4 +39,33 @@ app.use(function (err, req, res, next) { res.render("error"); }); + +// 设置存储配置 +const storage = multer.diskStorage({ + destination: function (req, file, cb) { + cb(null, 'uploads/'); // 保存文件的目录 + }, + filename: function (req, file, cb) { + cb(null, Date.now() + path.extname(file.originalname)); // 使用时间戳和文件扩展名作为文件名 + } +}); + +// 初始化 multer 实例 +const upload = multer({ storage: storage }); + +// 路由处理文件上传 +app.post('/upload.do', upload.single('file'), (req, res) => { + try { + // 文件信息存储在 req.file 中 + // 如果上传成功,req.file 将包含文件信息,如文件名、路径等 + // 如果上传失败(如文件太大、没有文件等),req.file 将是 undefined + if (!req.file) { + return res.status(400).send('No file uploaded.'); + } + // 你可以在这里处理文件,比如保存到数据库、进行图像处理等 + res.send('File uploaded successfully: ' + req.file.filename); + } catch (error) { + res.status(500).send('Error uploading file: ' + error.message); + } +}); module.exports = app; diff --git a/models/model.js b/models/model.js index 0124317..7b09677 100644 --- a/models/model.js +++ b/models/model.js @@ -77,7 +77,7 @@ let paylistSchema = new mongoose.Schema({ type: mongoose.Schema.Types.ObjectId, ref: "user", }, - time: String, + time: Array, status: Boolean, title: String, payable: Number, //应缴 @@ -175,6 +175,26 @@ const roleSchema = mongoose.Schema({ const roleModel = mongoose.model("role", roleSchema); +// 房屋租赁表 +// 房屋租赁 +let houserentSchema = new mongoose.Schema({ + cate: Number,//整租0、合租1 + title: String,// 房屋标题 + price: Number, // 房屋价格 + area: Number, // 房屋面积 + desc: String, // 房屋描述 + facility: Array, // 房屋设施 + img: Array, // 房屋图片 + time: String, // 发布时间 + userid: { + type: mongoose.Schema.Types.ObjectId, + ref: "user", + }, + roomid: { + type: mongoose.Schema.Types.ObjectId, + ref: "room" + }, +}) let user = mongoose.model("user", userSchema, "user"); let dong = mongoose.model("dong", dongSchema, "dong"); @@ -183,7 +203,7 @@ let pay = mongoose.model("pay", paySchema, "pay"); let NoticeModel = mongoose.model("notice", noticeSchema, "notice"); let paylist = mongoose.model("paylist", paylistSchema, "paylist"); let visitor = mongoose.model("visitor", visitorSchema, "visitor"); - +let houserent = mongoose.model("houserent", houserentSchema, "houserent"); module.exports = { user, room, @@ -195,4 +215,5 @@ module.exports = { dong, roleModel, permissionModel, -}; + houserent +} diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index 65d1bfc..923be95 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -195,6 +195,11 @@ "node": ">=0.4.2" } }, + "node_modules/append-field": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/append-field/-/append-field-1.0.0.tgz", + "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==" + }, "node_modules/array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmmirror.com/array-flatten/-/array-flatten-1.1.1.tgz", @@ -271,6 +276,22 @@ "resolved": "https://registry.npmmirror.com/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" + }, + "node_modules/busboy": { + "version": "1.6.0", + "resolved": "https://registry.npmmirror.com/busboy/-/busboy-1.6.0.tgz", + "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", + "dependencies": { + "streamsearch": "^1.1.0" + }, + "engines": { + "node": ">=10.16.0" + } + }, "node_modules/bytes": { "version": "3.0.0", "resolved": "https://registry.npmmirror.com/bytes/-/bytes-3.0.0.tgz", @@ -378,6 +399,20 @@ "node": ">= 0.6.x" } }, + "node_modules/concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmmirror.com/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "engines": [ + "node >= 0.8" + ], + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, "node_modules/constantinople": { "version": "3.0.2", "resolved": "https://registry.npmmirror.com/constantinople/-/constantinople-3.0.2.tgz", @@ -435,6 +470,11 @@ "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.", "hasInstallScript": true }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + }, "node_modules/cors": { "version": "2.8.5", "resolved": "https://registry.npmmirror.com/cors/-/cors-2.8.5.tgz", @@ -769,6 +809,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" + }, "node_modules/jade": { "version": "1.11.0", "resolved": "https://registry.npmmirror.com/jade/-/jade-1.11.0.tgz", @@ -1149,6 +1194,23 @@ "resolved": "https://registry.npmmirror.com/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, + "node_modules/multer": { + "version": "1.4.5-lts.1", + "resolved": "https://registry.npmmirror.com/multer/-/multer-1.4.5-lts.1.tgz", + "integrity": "sha512-ywPWvcDMeH+z9gQq5qYHCCy+ethsk4goepZ45GLD63fOu0YcNecQxi64nDs3qluZB+murG3/D4dJ7+dGctcCQQ==", + "dependencies": { + "append-field": "^1.0.0", + "busboy": "^1.0.0", + "concat-stream": "^1.5.2", + "mkdirp": "^0.5.4", + "object-assign": "^4.1.1", + "type-is": "^1.6.4", + "xtend": "^4.0.0" + }, + "engines": { + "node": ">= 6.0.0" + } + }, "node_modules/negotiator": { "version": "0.6.3", "resolved": "https://registry.npmmirror.com/negotiator/-/negotiator-0.6.3.tgz", @@ -1243,6 +1305,11 @@ "resolved": "https://registry.npmmirror.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz", "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, "node_modules/promise": { "version": "6.1.0", "resolved": "https://registry.npmmirror.com/promise/-/promise-6.1.0.tgz", @@ -1301,6 +1368,20 @@ "node": ">= 0.8" } }, + "node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmmirror.com/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, "node_modules/regenerator-runtime": { "version": "0.11.1", "resolved": "https://registry.npmmirror.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", @@ -1433,6 +1514,22 @@ "node": ">= 0.6" } }, + "node_modules/streamsearch": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/streamsearch/-/streamsearch-1.1.0.tgz", + "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, "node_modules/tencentcloud-sdk-nodejs-common": { "version": "4.0.968", "resolved": "https://registry.npmmirror.com/tencentcloud-sdk-nodejs-common/-/tencentcloud-sdk-nodejs-common-4.0.968.tgz", @@ -1541,6 +1638,11 @@ "node": ">= 0.6" } }, + "node_modules/typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmmirror.com/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==" + }, "node_modules/uglify-js": { "version": "2.8.29", "resolved": "https://registry.npmmirror.com/uglify-js/-/uglify-js-2.8.29.tgz", @@ -1586,6 +1688,11 @@ "node": ">= 0.8" } }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, "node_modules/utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmmirror.com/utils-merge/-/utils-merge-1.0.1.tgz", @@ -1718,6 +1825,14 @@ "node": ">=4.0" } }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmmirror.com/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "engines": { + "node": ">=0.4" + } + }, "node_modules/yargs": { "version": "3.10.0", "resolved": "https://registry.npmmirror.com/yargs/-/yargs-3.10.0.tgz", diff --git a/package-lock.json b/package-lock.json index 8984764..31d0050 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "mongoose": "^8.7.3", "morgan": "~1.9.1", "mount-routes": "^1.0.8", + "multer": "^1.4.5-lts.1", "tencentcloud-sdk-nodejs-iai": "^4.0.918", "ws": "^8.18.0" } @@ -214,6 +215,11 @@ "node": ">=0.4.2" } }, + "node_modules/append-field": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/append-field/-/append-field-1.0.0.tgz", + "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==" + }, "node_modules/array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmmirror.com/array-flatten/-/array-flatten-1.1.1.tgz", @@ -290,6 +296,22 @@ "resolved": "https://registry.npmmirror.com/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" + }, + "node_modules/busboy": { + "version": "1.6.0", + "resolved": "https://registry.npmmirror.com/busboy/-/busboy-1.6.0.tgz", + "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", + "dependencies": { + "streamsearch": "^1.1.0" + }, + "engines": { + "node": ">=10.16.0" + } + }, "node_modules/bytes": { "version": "3.0.0", "resolved": "https://registry.npmmirror.com/bytes/-/bytes-3.0.0.tgz", @@ -397,6 +419,20 @@ "node": ">= 0.6.x" } }, + "node_modules/concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmmirror.com/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "engines": [ + "node >= 0.8" + ], + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, "node_modules/constantinople": { "version": "3.0.2", "resolved": "https://registry.npmmirror.com/constantinople/-/constantinople-3.0.2.tgz", @@ -454,6 +490,11 @@ "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.", "hasInstallScript": true }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + }, "node_modules/cors": { "version": "2.8.5", "resolved": "https://registry.npmmirror.com/cors/-/cors-2.8.5.tgz", @@ -788,6 +829,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" + }, "node_modules/jade": { "version": "1.11.0", "resolved": "https://registry.npmmirror.com/jade/-/jade-1.11.0.tgz", @@ -1168,6 +1214,23 @@ "resolved": "https://registry.npmmirror.com/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, + "node_modules/multer": { + "version": "1.4.5-lts.1", + "resolved": "https://registry.npmmirror.com/multer/-/multer-1.4.5-lts.1.tgz", + "integrity": "sha512-ywPWvcDMeH+z9gQq5qYHCCy+ethsk4goepZ45GLD63fOu0YcNecQxi64nDs3qluZB+murG3/D4dJ7+dGctcCQQ==", + "dependencies": { + "append-field": "^1.0.0", + "busboy": "^1.0.0", + "concat-stream": "^1.5.2", + "mkdirp": "^0.5.4", + "object-assign": "^4.1.1", + "type-is": "^1.6.4", + "xtend": "^4.0.0" + }, + "engines": { + "node": ">= 6.0.0" + } + }, "node_modules/negotiator": { "version": "0.6.3", "resolved": "https://registry.npmmirror.com/negotiator/-/negotiator-0.6.3.tgz", @@ -1262,6 +1325,11 @@ "resolved": "https://registry.npmmirror.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz", "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, "node_modules/promise": { "version": "6.1.0", "resolved": "https://registry.npmmirror.com/promise/-/promise-6.1.0.tgz", @@ -1320,6 +1388,20 @@ "node": ">= 0.8" } }, + "node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmmirror.com/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, "node_modules/regenerator-runtime": { "version": "0.11.1", "resolved": "https://registry.npmmirror.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", @@ -1452,6 +1534,22 @@ "node": ">= 0.6" } }, + "node_modules/streamsearch": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/streamsearch/-/streamsearch-1.1.0.tgz", + "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, "node_modules/tencentcloud-sdk-nodejs-common": { "version": "4.0.968", "resolved": "https://registry.npmmirror.com/tencentcloud-sdk-nodejs-common/-/tencentcloud-sdk-nodejs-common-4.0.968.tgz", @@ -1560,6 +1658,11 @@ "node": ">= 0.6" } }, + "node_modules/typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmmirror.com/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==" + }, "node_modules/uglify-js": { "version": "2.8.29", "resolved": "https://registry.npmmirror.com/uglify-js/-/uglify-js-2.8.29.tgz", @@ -1605,6 +1708,11 @@ "node": ">= 0.8" } }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, "node_modules/utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmmirror.com/utils-merge/-/utils-merge-1.0.1.tgz", @@ -1737,6 +1845,14 @@ "node": ">=4.0" } }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmmirror.com/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "engines": { + "node": ">=0.4" + } + }, "node_modules/yargs": { "version": "3.10.0", "resolved": "https://registry.npmmirror.com/yargs/-/yargs-3.10.0.tgz", @@ -1913,6 +2029,11 @@ "resolved": "https://registry.npmmirror.com/amdefine/-/amdefine-1.0.1.tgz", "integrity": "sha512-S2Hw0TtNkMJhIabBwIojKL9YHO5T0n5eNqWJ7Lrlel/zDbftQpxpapi8tZs3X1HWa+u+QeydGmzzNU0m09+Rcg==" }, + "append-field": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/append-field/-/append-field-1.0.0.tgz", + "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==" + }, "array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmmirror.com/array-flatten/-/array-flatten-1.1.1.tgz", @@ -1977,6 +2098,19 @@ "resolved": "https://registry.npmmirror.com/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" }, + "buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" + }, + "busboy": { + "version": "1.6.0", + "resolved": "https://registry.npmmirror.com/busboy/-/busboy-1.6.0.tgz", + "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", + "requires": { + "streamsearch": "^1.1.0" + } + }, "bytes": { "version": "3.0.0", "resolved": "https://registry.npmmirror.com/bytes/-/bytes-3.0.0.tgz", @@ -2056,6 +2190,17 @@ "resolved": "https://registry.npmmirror.com/commander/-/commander-2.6.0.tgz", "integrity": "sha512-PhbTMT+ilDXZKqH8xbvuUY2ZEQNef0Q7DKxgoEKb4ccytsdvVVJmYqR0sGbi96nxU6oGrwEIQnclpK2NBZuQlg==" }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmmirror.com/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, "constantinople": { "version": "3.0.2", "resolved": "https://registry.npmmirror.com/constantinople/-/constantinople-3.0.2.tgz", @@ -2098,6 +2243,11 @@ "resolved": "https://registry.npmmirror.com/core-js/-/core-js-2.6.12.tgz", "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==" }, + "core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + }, "cors": { "version": "2.8.5", "resolved": "https://registry.npmmirror.com/cors/-/cors-2.8.5.tgz", @@ -2362,6 +2512,11 @@ "resolved": "https://registry.npmmirror.com/is-stream/-/is-stream-2.0.1.tgz", "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==" }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" + }, "jade": { "version": "1.11.0", "resolved": "https://registry.npmmirror.com/jade/-/jade-1.11.0.tgz", @@ -2648,6 +2803,20 @@ "resolved": "https://registry.npmmirror.com/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, + "multer": { + "version": "1.4.5-lts.1", + "resolved": "https://registry.npmmirror.com/multer/-/multer-1.4.5-lts.1.tgz", + "integrity": "sha512-ywPWvcDMeH+z9gQq5qYHCCy+ethsk4goepZ45GLD63fOu0YcNecQxi64nDs3qluZB+murG3/D4dJ7+dGctcCQQ==", + "requires": { + "append-field": "^1.0.0", + "busboy": "^1.0.0", + "concat-stream": "^1.5.2", + "mkdirp": "^0.5.4", + "object-assign": "^4.1.1", + "type-is": "^1.6.4", + "xtend": "^4.0.0" + } + }, "negotiator": { "version": "0.6.3", "resolved": "https://registry.npmmirror.com/negotiator/-/negotiator-0.6.3.tgz", @@ -2718,6 +2887,11 @@ "resolved": "https://registry.npmmirror.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz", "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, "promise": { "version": "6.1.0", "resolved": "https://registry.npmmirror.com/promise/-/promise-6.1.0.tgz", @@ -2761,6 +2935,20 @@ "unpipe": "1.0.0" } }, + "readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmmirror.com/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, "regenerator-runtime": { "version": "0.11.1", "resolved": "https://registry.npmmirror.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", @@ -2866,6 +3054,19 @@ "resolved": "https://registry.npmmirror.com/statuses/-/statuses-1.4.0.tgz", "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" }, + "streamsearch": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/streamsearch/-/streamsearch-1.1.0.tgz", + "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==" + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + }, "tencentcloud-sdk-nodejs-common": { "version": "4.0.968", "resolved": "https://registry.npmmirror.com/tencentcloud-sdk-nodejs-common/-/tencentcloud-sdk-nodejs-common-4.0.968.tgz", @@ -2954,6 +3155,11 @@ "mime-types": "~2.1.24" } }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmmirror.com/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==" + }, "uglify-js": { "version": "2.8.29", "resolved": "https://registry.npmmirror.com/uglify-js/-/uglify-js-2.8.29.tgz", @@ -2987,6 +3193,11 @@ "resolved": "https://registry.npmmirror.com/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==" }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, "utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmmirror.com/utils-merge/-/utils-merge-1.0.1.tgz", @@ -3067,6 +3278,11 @@ "resolved": "https://registry.npmmirror.com/xmlbuilder/-/xmlbuilder-11.0.1.tgz", "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==" }, + "xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmmirror.com/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" + }, "yargs": { "version": "3.10.0", "resolved": "https://registry.npmmirror.com/yargs/-/yargs-3.10.0.tgz", diff --git a/package.json b/package.json index 5e6072a..49047ac 100644 --- a/package.json +++ b/package.json @@ -14,11 +14,10 @@ "http-errors": "~1.6.3", "jade": "~1.11.0", "jsonwebtoken": "^9.0.2", - "morgan": "~1.9.1", - "mount-routes": "^1.0.8", "mongoose": "^8.7.3", "morgan": "~1.9.1", "mount-routes": "^1.0.8", + "multer": "^1.4.5-lts.1", "tencentcloud-sdk-nodejs-iai": "^4.0.918", "ws": "^8.18.0" } diff --git a/routes/Notice.js b/routes/Notice.js index 24cf8d9..bba7294 100644 --- a/routes/Notice.js +++ b/routes/Notice.js @@ -11,5 +11,8 @@ router.get("/notice", async (req, res) => { code: 200, result: data, }); -}); +}) + + + module.exports = router; \ No newline at end of file diff --git a/routes/wxy.js b/routes/wxy.js index fd17eca..cd4faee 100644 --- a/routes/wxy.js +++ b/routes/wxy.js @@ -1,6 +1,6 @@ const express=require('express') const router=express.Router() -const {permissionModel,roleModel,user}=require('../models/model') +const {permissionModel,roleModel,user,room,dong,pay,paylist,houserent}=require('../models/model') const jwt = require('jsonwebtoken') const crypto = require("crypto"); const { pipeline } = require('stream'); @@ -28,7 +28,7 @@ router.post('/userHt',async(req,res)=>{ let tokens={} router.post('/login',async(req,res)=>{ const {username,password}=req.body - console.log(username,password) + // console.log(username,password) const user1=await user.findOne({username,password:md5Password(password)}) if(user1){ let token=jwt.sign({username:username},'2401a',{expiresIn:'1h'}) @@ -166,8 +166,6 @@ router.get('/permission',async(req,res)=>{ }) - - // 获取所有角色 router.get('/role',async(req,res)=>{ let data=await roleModel.aggregate([ @@ -193,6 +191,234 @@ router.post('/role',async(req,res)=>{ }) +// 账单列表 +// 获取收费类型 +router.get('/pay',async(req,res)=>{ + let data=await pay.find() + res.send({ + code:200, + data:data + }) +}) + +// 获取账单列表 +router.get('/paylist',async(req,res)=>{ + let data=await paylist.aggregate([ + { + $lookup:{ + from:'pay', + localField:'cid', + foreignField:'_id', + as:'PData' + } + }, + { + $unwind:"$PData", + }, + { + $lookup:{ + from:'user', + localField:'userid', + foreignField:'_id', + as:'UData' + } + }, + { + $unwind:"$UData", + }, + { + $lookup:{ + from:'room', + localField:'rommid', + foreignField:'_id', + as:'RData' + } + }, + { + $unwind:"$RData", + }, + { + $project:{ + _id:1, + cid:"$PData._id", + cname:"$PData.name", + cprice:"$PData.price", + computer:"$PData.computer", + roomid:"$RData._id", + roomname:"$RData.name", + dongid:"$RData.cid", + userid:"$UData._id", + username:"$UData.name", + time:1, + status:1, + title:1, + } + } + ]) + res.send({ + code:200, + data:data + }) +}) + +// 获取楼信息表 +router.get('/dong',async(req,res)=>{ + let data = await dong.find() + res.send({ + code:200, + data:data + }) +}) + +// 获取房间表 +router.get('/room',async(req,res)=>{ + let data=await room.aggregate([ + { + $lookup:{ + from:'dong', + localField:'cid', + foreignField:'_id', + as:'DData' + } + }, + { + $unwind:"$DData", + }, + { + $project:{ + _id:1, + name:1, + cid:"$DData._id", + cname:"$DData.name", + } + } + ]) + res.send({ + code:200, + data:data + }) +}) + +// 新建账单 +router.post('/bill',async(req,res)=>{ + let room1=await room.findOne({ + _id:req.body.roomid + }) + await paylist.create({ + rommid:req.body.roomid, + cid:req.body.cid, + userid:room1.userid, + time:req.body.time, + status:false, + title:req.body.title, + }) + res.send({ + code:200 + }) +}) + +// 删除单条账单 +router.delete('/paylist',async(req,res)=>{ + await paylist.deleteOne({ + _id:req.query.id + }) + res.send({ + code:200 + }) +}) + + +// 房屋租赁表 +router.get('/houserent',async(req,res)=>{ + let data=await houserent.aggregate([ + { + $lookup:{ + from:'room', + localField:'roomid', + foreignField:'_id', + as:'roomData' + } + }, + { + $unwind:"$roomData", + }, + { + $lookup:{ + from:'user', + localField:'roomData.userid', + foreignField:'_id', + as:'userData' + } + }, + { + $unwind:"$userData", + }, + { + $lookup:{ + from:'dong', + localField:'roomData.cid', + foreignField:'_id', + as:'dongData' + } + }, + { + $project:{ + cate:1, + title:1, + area:1, + desc:1, + facility:1, + img:1, + time:1, + _id:1, + price:1, + uname:'$userData.username', + tel:"$userData.phone", + roomname:'$roomData.name', + dongname:'$dongData.name', + dongid:'$dongData._id', + s:"$dongData.s" + } + } + ]) + res.send({ + code:200, + data:data + }) +}) + +// 删除房屋租赁信息 +router.delete('/houserent',async(req,res)=>{ + await houserent.deleteOne({_id:req.query.id}) + res.send({ + code:200 + }) +}) + + +// 新增房屋租赁信息 +router.post('/houserent',async(req,res)=>{ + // console.log(req.body) + let {roomid,title,price,cate,facility,desc,time}=req.body + let room2=await room.findOne({_id:req.body.roomid}) + let dong1=await dong.findOne({_id:room2.cid}) + + await houserent.create({ + cate, + title, + price, + area:dong1.s, + desc, + facility, + time, + roomid, + userid:room2.userid + }) + res.send({ + code:200 + }) +}) + module.exports=router -- Gitee