revise_check.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date
  7. * @version
  8. */
  9. module.exports = options => {
  10. /**
  11. * 标段校验 中间件
  12. * 1. 读取标段数据(包括属性)
  13. * 2. 检验用户是否可见标段(不校验具体权限)
  14. *
  15. * @param {function} next - 中间件继续执行的方法
  16. * @return {void}
  17. */
  18. return function* reviseAuditCheck(next) {
  19. try {
  20. // 获取revise
  21. this.revise = yield this.service.ledgerRevise.getLastestRevise(this.tender.id);
  22. yield next;
  23. } catch (err) {
  24. // 输出错误到日志
  25. if (err.stack) {
  26. this.logger.error(err);
  27. } else {
  28. this.getLogger('fail').info(JSON.stringify({
  29. error: err,
  30. project: this.session.sessionProject,
  31. user: this.session.sessionUser,
  32. body: this.session.body,
  33. }));
  34. }
  35. // 重定向值标段管理
  36. if (this.helper.isAjax(this.request)) {
  37. if (err.stack) {
  38. this.body = {err: 4, msg: '标段数据未知错误', data: null};
  39. } else {
  40. this.body = {err: 3, msg: err.toString(), data: null};
  41. }
  42. } else {
  43. if (this.helper.isWap(this.request)) {
  44. this.redirect('/wap/list');
  45. } else {
  46. err === '您无权查看该内容' ? this.redirect(this.request.headers.referer) : this.redirect('/list');
  47. }
  48. }
  49. }
  50. };
  51. };