system_setting.js 882 B

12345678910111213141516171819202122232425262728
  1. /**
  2. * Created by zhang on 2020/1/8.
  3. */
  4. module.exports={
  5. rationNumberChecking:rationNumberChecking
  6. };
  7. let mongoose = require("mongoose");
  8. let rationModel = mongoose.model("ration");
  9. async function rationNumberChecking(req, res, next) {
  10. if(req.session.systemSetting){
  11. let type = req.session.compilationVersion.indexOf("免费") == -1?"professional":"normal";
  12. let data = req.body.data;
  13. if(typeof data === 'object'){
  14. data = JSON.stringify(data);
  15. }
  16. data = JSON.parse(data);
  17. let projectID = data.projectID;
  18. let no = await rationModel.find({projectID:projectID}).count();
  19. if(no >= req.session.systemSetting[type].ration){
  20. let result = {error:1,message:"您套用定额个数超限,请联系我们的客服人员。"};
  21. return res.json(result);
  22. }
  23. }
  24. next();
  25. }