ruifeng_liu пре 3 година
родитељ
комит
950d911022

+ 2 - 6
app/middleware/patentapply_record.js

@@ -15,18 +15,14 @@ const addRecord = async (ctx, service, args) => {
 module.exports = options => {
   return async function patentapply_record(ctx, next) {
     const { url, method } = ctx.request;
-    let id;
-    if (method === 'POST') {
-      const data = _.get(ctx.body, 'data');
-      if (data && data.id)id = data._id;
-    }
     await next();
+    let id;
     if (method === 'POST') {
       // 将添加,修改拦截,给加上记录
       const arr = url.split('/');
       const last = _.last(arr);
       let word = '';
-      if (ObjectId.isValid(last)) word = 'update';
+      if (ObjectId.isValid(last) && url.includes('update')) word = 'update';
       else {
         word = 'create';
       }

+ 1 - 1
app/model/patent/patentassess.js

@@ -13,7 +13,7 @@ const patentassess = {
   expert: { type: Array }, // 专家
   report: { type: Array }, // 评估报告
   record: { type: Array }, // 记录
-  status: { type: String }, // 状态
+  status: { type: String, default: '0' }, // 状态
   remark: { type: String },
 };
 const schema = new Schema(patentassess, { toJSON: { virtuals: true } });

+ 1 - 1
app/router/patent/patentassess.js

@@ -9,7 +9,7 @@ module.exports = app => {
   const target = 'patentassess';
   const metaTime = app.middleware.createTime();
   const record = app.middleware.patentapplyRecord(`${index}.${target}`);
-  router.resources(target, `${profix}${vision}/${index}/${target}`, metaTime, controller[index][target]); // index、create、show、destroy
+  router.resources(target, `${profix}${vision}/${index}/${target}`, metaTime, record, controller[index][target]); // index、create、show、destroy
   router.post(target, `${profix}${vision}/${index}/${target}/check`, controller[index][target].check);
   router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, record, controller[index][target].update);
 };