12345678910111213141516171819202122232425262728293031323334353637383940 |
- 'use strict';
- /**
- *
- *
- * @author Mai
- * @date
- * @version
- */
- module.exports = options => {
- /**
- * 标段校验 中间件
- * 1. 读取标段数据(包括属性)
- * 2. 检验用户是否可见标段(不校验具体权限)
- *
- * @param {function} next - 中间件继续执行的方法
- * @return {void}
- */
- return function* tenderPermissionCheck(next) {
- try {
- // 读取标段数据
- if (this.session.sessionUser.is_admin) {
- this.permission = this.service.tenderPermission.getAdminPermission();
- } else {
- this.permission = yield this.service.tenderPermission.getUserPermission(this.tender.id, this.session.sessionUser.accountId);
- }
- yield next;
- } catch (err) {
- this.log(err);
- if (this.helper.isAjax(this.request)) {
- this.ajaxErrorBody(err, '未知错误');
- } else {
- this.postError(err, '未知错误');
- this.redirect(this.request.headers.referer);
- }
- }
- };
- };
|