12345678910111213141516171819202122232425262728 |
- /**
- * Created by zhang on 2020/1/8.
- */
- module.exports={
- rationNumberChecking:rationNumberChecking
- };
- let mongoose = require("mongoose");
- let rationModel = mongoose.model("ration");
- async function rationNumberChecking(req, res, next) {
- if(req.session.systemSetting){
- let type = req.session.compilationVersion.indexOf("免费") == -1?"professional":"normal";
- let data = req.body.data;
- if(typeof data === 'object'){
- data = JSON.stringify(data);
- }
- data = JSON.parse(data);
- let projectID = data.projectID;
- let no = await rationModel.find({projectID:projectID}).count();
- if(no >= req.session.systemSetting[type].ration){
- let result = {error:1,message:"您套用定额个数超限,请联系我们的客服人员。"};
- return res.json(result);
- }
- }
- next();
- }
|