lrf402788946 4 سال پیش
والد
کامیت
74d2a0f7ef
73فایلهای تغییر یافته به همراه1481 افزوده شده و 1592 حذف شده
  1. 45 45
      app/controller/dock/.channel.js
  2. 39 39
      app/controller/dock/.channel_video.js
  3. 22 37
      app/controller/dock/.index.js
  4. 8 1
      app/controller/dock/.dock_chat.js
  5. 50 0
      app/controller/dock/.dock_imgtxt.js
  6. 22 29
      app/controller/dock/.transaction.js
  7. 21 27
      app/controller/dock/.dock_user.js
  8. 4 4
      app/controller/dock/.dock_pw.js
  9. 43 0
      app/controller/dock/.dock_vip.js
  10. 0 85
      app/controller/dock/.patent.js
  11. 31 31
      app/controller/dock/.train_chat.js
  12. 102 102
      app/controller/dock/.train_live.js
  13. 13 13
      app/controller/dock/channel.js
  14. 13 13
      app/controller/dock/channel_video.js
  15. 13 0
      app/controller/dock/dock.js
  16. 13 0
      app/controller/dock/dock_imgtxt.js
  17. 0 13
      app/controller/dock/dock_pw.js
  18. 17 0
      app/controller/dock/dock_transcation.js
  19. 1 2
      app/controller/dock/dock_user.js
  20. 13 0
      app/controller/dock/dock_video.js
  21. 13 0
      app/controller/dock/dock_vip.js
  22. 0 17
      app/controller/dock/index.js
  23. 0 16
      app/controller/dock/patent.js
  24. 13 13
      app/controller/dock/road_show.js
  25. 13 13
      app/controller/dock/train_live.js
  26. 0 18
      app/controller/dock/transaction.js
  27. 23 0
      app/controller/statistics/.index.js
  28. 17 1
      app/controller/statistics/index.js
  29. 42 41
      app/controller/users/.person_room.js
  30. 0 1
      app/middleware/create_time.js
  31. 36 0
      app/middleware/dock_transcation.js
  32. 37 0
      app/middleware/person_room.js
  33. 0 51
      app/model/dock.js
  34. 39 0
      app/model/dock/dock.js
  35. 0 0
      app/model/dock/dock_chat.js
  36. 23 0
      app/model/dock/dock_imgtxt.js
  37. 34 0
      app/model/dock/dock_transcation.js
  38. 30 0
      app/model/dock/dock_user.js
  39. 25 0
      app/model/dock/dock_video.js
  40. 27 0
      app/model/dock/dock_vip.js
  41. 0 24
      app/model/dock_pw.js
  42. 0 29
      app/model/dock_user.js
  43. 27 25
      app/model/person_room.js
  44. 0 41
      app/model/transaction.js
  45. 18 10
      app/router.js
  46. 13 13
      app/router/dock/channel.js
  47. 12 12
      app/router/dock/channel_video.js
  48. 1 3
      app/router/dock/index.js
  49. 12 12
      app/router/dock/dock_chat.js
  50. 1 7
      app/router/dock/patent.js
  51. 14 0
      app/router/dock/dock_transcation.js
  52. 2 3
      app/router/dock/dock_user.js
  53. 1 1
      app/router/dock/dock_pw.js
  54. 2 2
      app/router/dock/transaction.js
  55. 27 27
      app/router/dock/train_live.js
  56. 1 0
      app/router/statistics/index.js
  57. 13 12
      app/router/users/person_room.js
  58. 43 43
      app/service/dock/channel.js
  59. 16 16
      app/service/dock/channel_video.js
  60. 41 0
      app/service/dock/dock.js
  61. 1 1
      app/service/dock/dock_chat.js
  62. 5 7
      app/service/dock/dock_pw.js
  63. 27 0
      app/service/dock/dock_transcation.js
  64. 36 22
      app/service/dock/dock_user.js
  65. 15 0
      app/service/dock/dock_video.js
  66. 42 0
      app/service/dock/dock_vip.js
  67. 0 94
      app/service/dock/index.js
  68. 0 286
      app/service/dock/patent.js
  69. 140 140
      app/service/dock/train_live.js
  70. 0 55
      app/service/dock/transaction.js
  71. 36 2
      app/service/statistics/index.js
  72. 42 42
      app/service/users/person_chat.js
  73. 51 51
      app/service/users/person_room.js

+ 45 - 45
app/controller/dock/.channel.js

@@ -1,45 +1,45 @@
-module.exports = {
-  create: {
-    requestBody: ["user_id", "title", "origin", "type", "desc"],
-  },
-  destroy: {
-    params: ["!id"],
-    service: "delete",
-  },
-  update: {
-    params: ["!id"],
-    requestBody: ["user_id", "title", "origin", "type", "desc"],
-  },
-  show: {
-    parameters: {
-      params: ["!id"],
-    },
-    service: "fetch",
-  },
-  index: {
-    parameters: {
-      query: {
-        user_id:"user_id",
-        room_id:"room_id",
-        type:"type",
-        "create_time@start": "create_time@start",
-        "create_time@end": "create_time@end",
-      },
-      // options: {
-      //   "meta.state": 0 // 默认条件
-      // },
-    },
-    service: "query",
-    options: {
-      query: ["skip", "limit"],
-      sort: ["meta.createdAt"],
-      desc: true,
-      count: true,
-    },
-  },
-  // 登陆
-  login: {
-    requestBody: ["room_id", "passwd"],
-    service: "login",
-  },
-};
+module.exports = {
+  create: {
+    requestBody: ["user_id", "title", "origin", "type", "desc"],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: ["user_id", "title", "origin", "type", "desc"],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    service: "fetch",
+  },
+  index: {
+    parameters: {
+      query: {
+        user_id:"user_id",
+        room_id:"room_id",
+        type:"type",
+        "create_time@start": "create_time@start",
+        "create_time@end": "create_time@end",
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
+  // 登陆
+  login: {
+    requestBody: ["room_id", "passwd"],
+    service: "login",
+  },
+};

+ 39 - 39
app/controller/dock/.channel_video.js

@@ -1,39 +1,39 @@
-module.exports = {
-  create: {
-    requestBody: ["channel_id", "title", "start_time", "end_time", "file_path"],
-  },
-  destroy: {
-    params: ["!id"],
-    service: "delete",
-  },
-  update: {
-    params: ["!id"],
-    requestBody: ["channel_id", "title", "start_time", "end_time", "file_path"],
-  },
-  show: {
-    parameters: {
-      params: ["!id"],
-    },
-    service: "fetch",
-  },
-  index: {
-    parameters: {
-      query: {
-        channel_id: "channel_id",
-        title: "title",
-        "create_time@start": "create_time@start",
-        "create_time@end": "create_time@end",
-      },
-      // options: {
-      //   "meta.state": 0 // 默认条件
-      // },
-    },
-    service: "query",
-    options: {
-      query: ["skip", "limit"],
-      sort: ["meta.createdAt"],
-      desc: true,
-      count: true,
-    },
-  },
-};
+module.exports = {
+  create: {
+    requestBody: ["channel_id", "title", "start_time", "end_time", "file_path"],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: ["channel_id", "title", "start_time", "end_time", "file_path"],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    service: "fetch",
+  },
+  index: {
+    parameters: {
+      query: {
+        channel_id: "channel_id",
+        title: "title",
+        "create_time@start": "create_time@start",
+        "create_time@end": "create_time@end",
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 22 - 37
app/controller/dock/.index.js

@@ -1,18 +1,17 @@
 module.exports = {
   create: {
     requestBody: [
-      "!title",
-      "!start_time",
-      "!end_time",
+      "title",
+      "start_time",
+      "end_time",
       "province",
-      "place",
-      "adminuser",
+      "city",
+      "admin",
       "phone",
       "sponsor",
       "organizer",
-      "videodata",
-      "vipuser",
-      "desc",
+      "user_id",
+      "status",
       "remark",
     ],
   },
@@ -27,14 +26,12 @@ module.exports = {
       "start_time",
       "end_time",
       "province",
-      "place",
-      "adminuser",
+      "city",
+      "admin",
       "phone",
       "sponsor",
       "organizer",
-      "videodata",
-      "vipuser",
-      "desc",
+      "user_id",
       "status",
       "remark",
     ],
@@ -48,11 +45,18 @@ module.exports = {
   index: {
     parameters: {
       query: {
-        title: "title",
         room_id: "room_id",
+        title: "title",
+        start_time: "start_time",
+        end_time: "end_time",
+        admin: "admin",
+        sponsor: "sponsor",
+        user_id: "user_id",
         status: "status",
-        "create_time@start": "create_time@start",
-        "create_time@end": "create_time@end",
+        "start_time@start": "start_time@start",
+        "start_time@end": "start_time@end",
+        "end_time@start": "end_time@start",
+        "end_time@end": "end_time@end",
       },
       // options: {
       //   "meta.state": 0 // 默认条件
@@ -61,32 +65,13 @@ module.exports = {
     service: "query",
     options: {
       query: ["skip", "limit"],
-      sort: ["room_id"],
+      sort: ["meta.createdAt"],
       desc: true,
       count: true,
     },
   },
-  // 登陆
   login: {
-    requestBody: ["room_phone", "password"],
+    requestBody: ["room_id", "password"],
     service: "login",
   },
-  // vip登陆
-  vipLogin: {
-    params: ["!id"],
-    requestBody: ["room_phone", "password"],
-    service: "vipLogin",
-  },
-  product: {
-    parameters: {
-      query: {
-        dock_id: "dock_id",
-        type: "type",
-      },
-    },
-    service: "dockProduct",
-    options: {
-      query: ["skip", "limit"],
-    },
-  },
 };

+ 8 - 1
app/controller/dock/.dock_chat.js

@@ -1,6 +1,12 @@
 module.exports = {
   create: {
-    requestBody: ["!dock_id", "!content", "!sender_id", "!sender_name"],
+    requestBody: [
+      "!dock_id",
+      "!content",
+      "!sender_id",
+      "!sender_name",
+      "sender_time",
+    ],
   },
   destroy: {
     params: ["!id"],
@@ -14,6 +20,7 @@ module.exports = {
       "!sender_id",
       "!sender_name",
       "remark",
+      "sender_time",
     ],
   },
   show: {

+ 50 - 0
app/controller/dock/.dock_imgtxt.js

@@ -0,0 +1,50 @@
+module.exports = {
+  create: {
+    requestBody: [
+      "dock_id",
+      "content",
+      "img_url",
+      "file_url",
+      "user_id",
+      "remark",
+    ],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: [
+      "dock_id",
+      "content",
+      "img_url",
+      "file_url",
+      "user_id",
+      "remark",
+    ],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    service: "fetch",
+  },
+  index: {
+    parameters: {
+      query: {
+        dock_id: "dock_id",
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 22 - 29
app/controller/dock/.transaction.js

@@ -2,15 +2,15 @@ module.exports = {
   create: {
     requestBody: [
       "dock_id",
-      "!supplier",
-      "!s_name",
-      "!s_phone",
-      "!demander",
-      "!d_name",
-      "!d_phone",
-      "!product_id",
-      "!product",
-      "pact",
+      "product_id",
+      "s_id",
+      "s_name",
+      "s_phone",
+      "d_id",
+      "d_name",
+      "d_phone",
+      "status",
+      "contact",
       "remark",
     ],
   },
@@ -22,15 +22,15 @@ module.exports = {
     params: ["!id"],
     requestBody: [
       "dock_id",
-      "!supplier",
-      "!s_name",
-      "!s_phone",
-      "!demander",
-      "!d_name",
-      "!d_phone",
-      "!product_id",
-      "!product",
-      "pact",
+      "product_id",
+      "s_id",
+      "s_name",
+      "s_phone",
+      "d_id",
+      "d_name",
+      "d_phone",
+      "status",
+      "contact",
       "remark",
     ],
   },
@@ -44,14 +44,12 @@ module.exports = {
     parameters: {
       query: {
         dock_id: "dock_id",
-        supplier: "supplier",
-        demander: "demander",
         product_id: "product_id",
-        product: "%product%",
-        user_id: "user_id",
+        s_id: "s_id",
+        s_name: "s_name",
+        d_id: "d_id",
+        d_name: "d_name",
         status: "status",
-        "create_time@start": "create_time@start",
-        "create_time@end": "create_time@end",
       },
       // options: {
       //   "meta.state": 0 // 默认条件
@@ -65,9 +63,4 @@ module.exports = {
       count: true,
     },
   },
-  step: {
-    params: ["!id"],
-    requestBody: ["!status", "pact"],
-    service: "step",
-  },
 };

+ 21 - 27
app/controller/dock/.dock_user.js

@@ -1,13 +1,14 @@
 module.exports = {
   create: {
     requestBody: [
-      "!dock_id",
-      "!user_id",
-      "!user_name",
-      "goodsList",
-      "contact_tel",
-      "apply_time",
+      "dock_id",
+      "name",
+      "phone",
+      "create_time",
+      "productList",
       "status",
+      "user_id",
+      "remark",
     ],
   },
   destroy: {
@@ -17,12 +18,14 @@ module.exports = {
   update: {
     params: ["!id"],
     requestBody: [
-      "user_id",
-      "user_name",
-      "goodsList",
-      "contact_tel",
-      "apply_time",
+      "dock_id",
+      "name",
+      "phone",
+      "create_time",
+      "productList",
       "status",
+      "user_id",
+      "remark",
     ],
   },
   show: {
@@ -35,9 +38,10 @@ module.exports = {
     parameters: {
       query: {
         dock_id: "dock_id",
+        user_id: "user_id",
+        name: "name",
+        phone: "phone",
         status: "status",
-        "create_time@start": "create_time@start",
-        "create_time@end": "create_time@end",
       },
       // options: {
       //   "meta.state": 0 // 默认条件
@@ -51,24 +55,14 @@ module.exports = {
       count: true,
     },
   },
-  goodsCheck: {
+  goodCheck: {
     params: ["!id"],
-    requestBody: ["!good_id","!status"],
-    service: "goodsCheck",
+    requestBody: ["good_id", "status"],
+    service: "goodCheck",
   },
   userCheck: {
     params: ["!id"],
-    requestBody: ["!status"],
+    requestBody: ["status"],
     service: "userCheck",
   },
-
-  findUser:{
-    parameters: {
-      query: {
-        dock_id: "dock_id",
-        user_id: "user_id",
-      },
-    },
-    service: "findUser",
-  }
 };

+ 4 - 4
app/controller/dock/.dock_pw.js

@@ -1,6 +1,6 @@
 module.exports = {
   create: {
-    requestBody: ["!dock_id", "content", "!url", "file_path", "remark"],
+    requestBody: ["dock_id", "title", "brief", "file_url", "user_id", "remark"],
   },
   destroy: {
     params: ["!id"],
@@ -8,7 +8,7 @@ module.exports = {
   },
   update: {
     params: ["!id"],
-    requestBody: ["dock_id", "content", "url", "file_path", "remark"],
+    requestBody: ["dock_id", "title", "brief", "file_url", "user_id", "remark"],
   },
   show: {
     parameters: {
@@ -20,8 +20,8 @@ module.exports = {
     parameters: {
       query: {
         dock_id: "dock_id",
-        "create_time@start": "create_time@start",
-        "create_time@end": "create_time@end",
+        title: "title",
+        user_id: "user_id",
       },
       // options: {
       //   "meta.state": 0 // 默认条件

+ 43 - 0
app/controller/dock/.dock_vip.js

@@ -0,0 +1,43 @@
+module.exports = {
+  create: {
+    requestBody: ["dock_id", "name", "phone", "email", "brief", "remark"],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: ["dock_id", "name", "phone", "email", "brief", "remark"],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    service: "fetch",
+  },
+  index: {
+    parameters: {
+      query: {
+        dock_id: "dock_id",
+        name: "name",
+        phone: "phone",
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
+  login: {
+    params: ["!id"],
+    requestBody: ["phone", "password"],
+    service: "login",
+  },
+};

+ 0 - 85
app/controller/dock/.patent.js

@@ -1,85 +0,0 @@
-module.exports = {
-  create: {
-    requestBody: [
-      "create_number",
-      "create_date",
-      "success_number",
-      "success_date",
-      "name",
-      "inventor",
-      "address",
-      "apply_personal",
-      "term",
-      "type",
-      "agent_personal",
-      "agent",
-      "abstract",
-      "img_url",
-      "origin",
-    ],
-  },
-  destroy: {
-    params: ["!id"],
-    service: "delete",
-  },
-  update: {
-    params: ["!id"],
-    requestBody: [
-      "create_number",
-      "create_date",
-      "success_number",
-      "success_date",
-      "name",
-      "inventor",
-      "address",
-      "apply_personal",
-      "term",
-      "type",
-      "agent_personal",
-      "agent",
-      "abstract",
-      "img_url",
-      "origin",
-    ],
-  },
-  show: {
-    parameters: {
-      params: ["!id"],
-    },
-    service: "fetch",
-  },
-  index: {
-    parameters: {
-      query: {
-        create_number: "create_number",
-        create_date: "create_date",
-        create_number: "create_number",
-        success_date: "success_date",
-        name: "%name%",
-        inventor: "inventor",
-        address: "address",
-        apply_personal: "%apply_personal%",
-        term: "term",
-        type: "type",
-        agent_personal: "agent_personal",
-        agent: "agent",
-        origin: "%origin%",
-      },
-    },
-    service: "query",
-    options: {
-      query: ["skip", "limit"],
-      sort: ["meta.createdAt"],
-      desc: true,
-      count: true,
-    },
-  },
-  toImport: {
-    requestBody: ["uri", "origin"],
-    service: "toImport",
-  },
-  toExport: {
-    requestBody: ["user"],
-    service: "toExport",
-  },
-};

+ 31 - 31
app/controller/dock/.train_chat.js

@@ -1,31 +1,31 @@
-module.exports = {
-  create: {
-    requestBody: ["sender_id", "sender_name", "!content", "send_time", "role", "unit_id"],
-  },
-  destroy: {
-    params: ["!id"],
-    service: "delete",
-  },
-  update: {
-    params: ["!id"],
-    requestBody: ["sender_id", "sender_name", "content", "send_time", "role", "unit_id"],
-  },
-  show: {
-    parameters: {
-      params: ["!id"],
-    },
-    service: "fetch",
-  },
-  index: {
-    parameters: {
-      query: ["sender_id", "sender_name", "content", "send_time", "role", "unit_id"],
-    },
-    service: "query",
-    options: {
-      query: ["skip", "limit"],
-      sort: ["meta.createdAt"],
-      desc: true,
-      count: true,
-    },
-  },
-};
+module.exports = {
+  create: {
+    requestBody: ["sender_id", "sender_name", "!content", "send_time", "role", "unit_id"],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: ["sender_id", "sender_name", "content", "send_time", "role", "unit_id"],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    service: "fetch",
+  },
+  index: {
+    parameters: {
+      query: ["sender_id", "sender_name", "content", "send_time", "role", "unit_id"],
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 102 - 102
app/controller/dock/.train_live.js

@@ -1,102 +1,102 @@
-module.exports = {
-  create: {
-    requestBody: [
-      "title",
-      "province",
-      "place",
-      "sponsor",
-      "brief",
-      "user",
-      "phone",
-      "video_data",
-      "user_data",
-      "start_date",
-    ],
-  },
-  destroy: {
-    params: ["!id"],
-    service: "delete",
-  },
-  update: {
-    params: ["!id"],
-    requestBody: [
-      "title",
-      "province",
-      "place",
-      "sponsor",
-      "brief",
-      "user",
-      "phone",
-      "video_data",
-      "user_data",
-      "start_date",
-    ],
-  },
-  show: {
-    parameters: {
-      params: ["!id"],
-    },
-    service: "fetch",
-  },
-  index: {
-    parameters: {
-      query: {
-        title: "title",
-        province: "province",
-        place: "place",
-        sponsor: "sponsor",
-        brief: "brief",
-        user: "user",
-        phone: "phone",
-        "create_time@start": "create_time@start",
-        "create_time@end": "create_time@end",
-      },
-      // options: {
-      //   "meta.status": 0 // 默认条件
-      // },
-    },
-    service: "query",
-    options: {
-      query: ["skip", "limit"],
-      sort: ["meta.createdAt"],
-      desc: true,
-      count: true,
-    },
-  },
-  userData: {
-    params: ["!id"],
-    service: "userData",
-  },
-  addUser: {
-    params: ["!id"],
-    requestBody: ["users"],
-    service: "addUser",
-  },
-  updateUser: {
-    params: ["!id"],
-    requestBody: ["users"],
-    service: "updateUser",
-  },
-  deleteUser: {
-    params: ["!id"],
-    requestBody: ["users"],
-    service: "deleteUser",
-  },
-  userLogin: {
-    params: ["!id"],
-    requestBody: ["user_phone", "user_password"],
-    service: "userLogin",
-  },
-  userLogout: {
-    params: ["!id"],
-    service: "userLogout",
-  },
-  login: {
-    requestBody: ["room_id", "password"],
-    service: "login",
-  },
-  userLonger: {
-    params: ["!id"],
-    service: "userLonger",
-  },
-};
+module.exports = {
+  create: {
+    requestBody: [
+      "title",
+      "province",
+      "place",
+      "sponsor",
+      "brief",
+      "user",
+      "phone",
+      "video_data",
+      "user_data",
+      "start_date",
+    ],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: [
+      "title",
+      "province",
+      "place",
+      "sponsor",
+      "brief",
+      "user",
+      "phone",
+      "video_data",
+      "user_data",
+      "start_date",
+    ],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    service: "fetch",
+  },
+  index: {
+    parameters: {
+      query: {
+        title: "title",
+        province: "province",
+        place: "place",
+        sponsor: "sponsor",
+        brief: "brief",
+        user: "user",
+        phone: "phone",
+        "create_time@start": "create_time@start",
+        "create_time@end": "create_time@end",
+      },
+      // options: {
+      //   "meta.status": 0 // 默认条件
+      // },
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
+  userData: {
+    params: ["!id"],
+    service: "userData",
+  },
+  addUser: {
+    params: ["!id"],
+    requestBody: ["users"],
+    service: "addUser",
+  },
+  updateUser: {
+    params: ["!id"],
+    requestBody: ["users"],
+    service: "updateUser",
+  },
+  deleteUser: {
+    params: ["!id"],
+    requestBody: ["users"],
+    service: "deleteUser",
+  },
+  userLogin: {
+    params: ["!id"],
+    requestBody: ["user_phone", "user_password"],
+    service: "userLogin",
+  },
+  userLogout: {
+    params: ["!id"],
+    service: "userLogout",
+  },
+  login: {
+    requestBody: ["room_id", "password"],
+    service: "login",
+  },
+  userLonger: {
+    params: ["!id"],
+    service: "userLonger",
+  },
+};

+ 13 - 13
app/controller/dock/channel.js

@@ -1,13 +1,13 @@
-'use strict';
-const meta = require('./.channel.js');
-const Controller = require('egg').Controller;
-const { CrudController } = require('naf-framework-mongoose/lib/controller');
-
-// 科技频道
-class ChannelController extends Controller {
-  constructor(ctx) {
-    super(ctx);
-    this.service = this.ctx.service.dock.channel;
-  }
-}
-module.exports = CrudController(ChannelController, meta);
+'use strict';
+const meta = require('./.channel.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 科技频道
+class ChannelController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.dock.channel;
+  }
+}
+module.exports = CrudController(ChannelController, meta);

+ 13 - 13
app/controller/dock/channel_video.js

@@ -1,13 +1,13 @@
-'use strict';
-const meta = require('./.channel_video.js');
-const Controller = require('egg').Controller;
-const { CrudController } = require('naf-framework-mongoose/lib/controller');
-
-// 科技频道-视频
-class Channel_videoController extends Controller {
-  constructor(ctx) {
-    super(ctx);
-    this.service = this.ctx.service.dock.channelVideo;
-  }
-}
-module.exports = CrudController(Channel_videoController, meta);
+'use strict';
+const meta = require('./.channel_video.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 科技频道-视频
+class Channel_videoController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.dock.channelVideo;
+  }
+}
+module.exports = CrudController(Channel_videoController, meta);

+ 13 - 0
app/controller/dock/dock.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./.dock.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 展会
+class DockController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.dock.dock;
+  }
+}
+module.exports = CrudController(DockController, meta);

+ 13 - 0
app/controller/dock/dock_imgtxt.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./.dock_imgtxt.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 展会图文
+class Dock_imgtxtController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.dock.dockImgtxt;
+  }
+}
+module.exports = CrudController(Dock_imgtxtController, meta);

+ 0 - 13
app/controller/dock/dock_pw.js

@@ -1,13 +0,0 @@
-'use strict';
-const meta = require('./.dock_pw.js');
-const Controller = require('egg').Controller;
-const { CrudController } = require('naf-framework-mongoose/lib/controller');
-
-// 展会-图文
-class Dock_pwController extends Controller {
-  constructor(ctx) {
-    super(ctx);
-    this.service = this.ctx.service.dock.dockPw;
-  }
-}
-module.exports = CrudController(Dock_pwController, meta);

+ 17 - 0
app/controller/dock/dock_transcation.js

@@ -0,0 +1,17 @@
+'use strict';
+const meta = require('./.dock_transcation.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 展会合同
+class Dock_transcationController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.dock.dockTranscation;
+  }
+  async getUserList() {
+    const data = await this.service.getUserList(this.ctx.query);
+    this.ctx.ok(data);
+  }
+}
+module.exports = CrudController(Dock_transcationController, meta);

+ 1 - 2
app/controller/dock/dock_user.js

@@ -3,12 +3,11 @@ const meta = require('./.dock_user.js');
 const Controller = require('egg').Controller;
 const { CrudController } = require('naf-framework-mongoose/lib/controller');
 
-// 展会-用户
+// 展会用户
 class Dock_userController extends Controller {
   constructor(ctx) {
     super(ctx);
     this.service = this.ctx.service.dock.dockUser;
   }
-
 }
 module.exports = CrudController(Dock_userController, meta);

+ 13 - 0
app/controller/dock/dock_video.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./.dock_video.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 展会视频
+class Dock_videoController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.dock.dockVideo;
+  }
+}
+module.exports = CrudController(Dock_videoController, meta);

+ 13 - 0
app/controller/dock/dock_vip.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./.dock_vip.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 展会vip
+class Dock_vipController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.dock.dockVip;
+  }
+}
+module.exports = CrudController(Dock_vipController, meta);

+ 0 - 17
app/controller/dock/index.js

@@ -1,17 +0,0 @@
-'use strict';
-const meta = require('./.index.js');
-const Controller = require('egg').Controller;
-const { CrudController } = require('naf-framework-mongoose/lib/controller');
-
-// 展会
-class IndexController extends Controller {
-  constructor(ctx) {
-    super(ctx);
-    this.service = this.ctx.service.dock.index;
-  }
-  async product() {
-    const { data, total } = await this.service.dockProduct(this.ctx.query);
-    this.ctx.ok({ data, total });
-  }
-}
-module.exports = CrudController(IndexController, meta);

+ 0 - 16
app/controller/dock/patent.js

@@ -1,16 +0,0 @@
-'use strict';
-
-const _ = require('lodash');
-const meta = require('./.patent.js');
-const Controller = require('egg').Controller;
-const { CrudController } = require('naf-framework-mongoose/lib/controller');
-
-// 专利表
-class PatentController extends Controller {
-  constructor(ctx) {
-    super(ctx);
-    this.service = this.ctx.service.dock.patent;
-  }
-}
-
-module.exports = CrudController(PatentController, meta);

+ 13 - 13
app/controller/dock/road_show.js

@@ -1,13 +1,13 @@
-'use strict';
-const meta = require('./.road_show.js');
-const Controller = require('egg').Controller;
-const { CrudController } = require('naf-framework-mongoose/lib/controller');
-
-// 项目路演
-class Road_showController extends Controller {
-  constructor(ctx) {
-    super(ctx);
-    this.service = this.ctx.service.dock.roadShow;
-  }
-}
-module.exports = CrudController(Road_showController, meta);
+'use strict';
+const meta = require('./.road_show.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 项目路演
+class Road_showController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.dock.roadShow;
+  }
+}
+module.exports = CrudController(Road_showController, meta);

+ 13 - 13
app/controller/dock/train_live.js

@@ -1,13 +1,13 @@
-'use strict';
-const meta = require('./.train_live.js');
-const Controller = require('egg').Controller;
-const { CrudController } = require('naf-framework-mongoose/lib/controller');
-
-// 培训问诊
-class Train_liveController extends Controller {
-  constructor(ctx) {
-    super(ctx);
-    this.service = this.ctx.service.dock.trainLive;
-  }
-}
-module.exports = CrudController(Train_liveController, meta);
+'use strict';
+const meta = require('./.train_live.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 培训问诊
+class Train_liveController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.dock.trainLive;
+  }
+}
+module.exports = CrudController(Train_liveController, meta);

+ 0 - 18
app/controller/dock/transaction.js

@@ -1,18 +0,0 @@
-'use strict';
-const meta = require('./.transaction.js');
-const Controller = require('egg').Controller;
-const { CrudController } = require('naf-framework-mongoose/lib/controller');
-
-// 交易表
-class TransactionController extends Controller {
-  constructor(ctx) {
-    super(ctx);
-    this.service = this.ctx.service.dock.transaction;
-  }
-
-  async index() {
-    const { data, total } = await this.service.query(this.ctx.query);
-    this.ctx.ok({ data, total });
-  }
-}
-module.exports = CrudController(TransactionController, meta);

+ 23 - 0
app/controller/statistics/.index.js

@@ -0,0 +1,23 @@
+module.exports = {
+  dockProduct: {
+    parameters: {
+      query: {
+        dock_id: "dock_id",
+        type: "type",
+        name: "productList.name",
+        type: "productList.type",
+        field: "productList.field",
+        cooperation: "productList.cooperation",
+        "create_time@start": "create_time@start",
+        "create_time@end": "create_time@end",
+      },
+      options: {
+        "productList.status": "1", // 默认条件
+      },
+    },
+    service: "dockProduct",
+    options: {
+      query: ["skip", "limit"],
+    },
+  },
+};

+ 17 - 1
app/controller/statistics/index.js

@@ -1,6 +1,7 @@
 'use strict';
 const Controller = require('egg').Controller;
 const { CrudController } = require('naf-framework-mongoose/lib/controller');
+const meta = require('./.index.js');
 
 // 首页-数据动态统计
 class IndexController extends Controller {
@@ -75,5 +76,20 @@ class IndexController extends Controller {
     const data = await this.service.declare();
     this.ctx.ok({ data });
   }
+
+
+  async dockProduct() {
+    const query = this.ctx.query;
+    const arr = [ 'skip', 'limit', 'dock_id' ];
+    for (const key in query) {
+      const r = arr.find(f => f === key);
+      if (!r) {
+        query[`productList.${key}`] = query[key];
+        delete query[key];
+      }
+    }
+    const data = await this.service.dockProduct(query);
+    this.ctx.ok(data);
+  }
 }
-module.exports = CrudController(IndexController, {});
+module.exports = CrudController(IndexController, meta);

+ 42 - 41
app/controller/users/.person_room.js

@@ -1,41 +1,42 @@
-module.exports = {
-  create: {
-    requestBody: ["!p1_id", "p1", "!p2_id", "p2"],
-  },
-  destroy: {
-    params: ["!id"],
-    service: "delete",
-  },
-  update: {
-    params: ["!id"],
-    requestBody: ["p1_id", "p1", "p2_id", "p2"],
-  },
-  show: {
-    parameters: {
-      params: ["!id"],
-    },
-    service: "fetch",
-  },
-  index: {
-    parameters: {
-      query: {
-        p1_id: "p1_id",
-        p1: "p1",
-        p2_id: "p2_id",
-        p2: "p2",
-        "create_time@start": "create_time@start",
-        "create_time@end": "create_time@end",
-      },
-      // options: {
-      //   "meta.state": 0 // 默认条件
-      // },
-    },
-    service: "query",
-    options: {
-      query: ["skip", "limit"],
-      sort: ["last_time"],
-      desc: true,
-      count: true,
-    },
-  },
-};
+module.exports = {
+  create: {
+    requestBody: ["!p1_id", "p1", "!p2_id", "p2", "product_id"],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: ["p1_id", "p1", "p2_id", "p2", "product_id"],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    service: "fetch",
+  },
+  index: {
+    parameters: {
+      query: {
+        p1_id: "p1_id",
+        p1: "p1",
+        p2_id: "p2_id",
+        p2: "p2",
+        product_id: "product_id",
+        "create_time@start": "create_time@start",
+        "create_time@end": "create_time@end",
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["last_time"],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 0 - 1
app/middleware/create_time.js

@@ -10,7 +10,6 @@ const toTime = meta => {
 };
 module.exports = options => {
   return async function create_time(ctx, next) {
-    console.log('function in create_time middleware');
     await next();
     const request = ctx.request;
     const { method } = request;

+ 36 - 0
app/middleware/dock_transcation.js

@@ -0,0 +1,36 @@
+'use strict';
+const _ = require('lodash');
+const idToData = async (ctx, id) => {
+  let res = {};
+  // 1,是产品
+  res = await ctx.service.users.product.fetch({ id });
+  if (res) return res;
+  // 2,是专家
+  res = await ctx.service.users.personal.fetch({ id });
+  return res;
+};
+module.exports = options => {
+  return async function dock_transcation(ctx, next) {
+    await next();
+    const request = ctx.request;
+    const { method } = request;
+    if (method === 'GET') {
+      let { data } = ctx.body;
+      data = JSON.parse(JSON.stringify(data));
+      const dataKey = 'product_id';
+      const key = 'product';
+      if (_.isArray(data)) {
+        // 数组,多个,循环查
+        for (const i of data) {
+          const res = await idToData(ctx, i[dataKey]);
+          if (res)i[key] = res;
+        }
+      } else if (_.isObject(data)) {
+        // 一个,找完就完事
+        const res = await idToData(ctx, data[dataKey]);
+        if (res) data[key] = res;
+      }
+      ctx.body.data = data;
+    }
+  };
+};

+ 37 - 0
app/middleware/person_room.js

@@ -0,0 +1,37 @@
+'use strict';
+const _ = require('lodash');
+const idToData = async (ctx, id) => {
+  let res = {};
+  // 1,是产品
+  res = await ctx.service.users.product.fetch({ id });
+  if (res) return res;
+  // 2,是专家
+  res = await ctx.service.users.personal.fetch({ id });
+  return res;
+};
+module.exports = options => {
+  return async function person_room(ctx, next) {
+    console.log('function in person_room middleware');
+    await next();
+    const request = ctx.request;
+    const { method } = request;
+    if (method === 'GET') {
+      let { data } = ctx.body;
+      data = JSON.parse(JSON.stringify(data));
+      const dataKey = 'product_id';
+      const key = 'product';
+      if (_.isArray(data)) {
+        // 数组,多个,循环查
+        for (const i of data) {
+          const res = await idToData(ctx, i[dataKey]);
+          if (res)i[key] = res;
+        }
+      } else if (_.isObject(data)) {
+        // 一个,找完就完事
+        const res = await idToData(ctx, data[dataKey]);
+        if (res) data[key] = res;
+      }
+      ctx.body.data = data;
+    }
+  };
+};

+ 0 - 51
app/model/dock.js

@@ -1,51 +0,0 @@
-'use strict';
-const Schema = require('mongoose').Schema;
-const moment = require('moment');
-const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
-const { Secret } = require('naf-framework-mongoose/lib/model/schema');
-// 展会视频表
-const videos = new Schema({
-  file_path: { type: String, required: true }, // 视频路径
-  videointro: { type: String, required: false, maxLength: 200 }, // 视频文件标题
-  videointroinfo: { type: String, required: false, maxLength: 200 }, // 视频文件简介
-});
-// vip用户
-const vipuser = new Schema({
-  vipname: { type: String, required: false, maxLength: 200 }, // 用户名称
-  vipphone: { type: String, required: false, maxLength: 200 }, // 联系人手机
-  email: { type: String, required: false, maxLength: 20 }, // 郵箱
-  content: { type: String, required: false }, // 内容
-  password: { type: String, select: false }, // 密码
-});
-
-vipuser.index({ id: 1 });
-// 展会表
-const dock = {
-  room_id: { type: String, required: true, maxLength: 10 }, // 房间号
-  password: { type: Secret, select: false }, // 密码
-  title: { type: String, required: false, maxLength: 200 }, // 对接会标题
-  start_time: { type: String, required: true, maxLength: 200 }, // 开始时间
-  end_time: { type: String, required: true, maxLength: 200 }, // 结束时间
-  province: { type: String, required: false }, // 省
-  place: { type: String, required: false }, // 市
-  adminuser: { type: String, required: false, maxLength: 200 }, // 负责人
-  phone: { type: String, required: false, maxLength: 200 }, // 负责人电话
-  sponsor: { type: String, required: false, maxLength: 200 }, // 主办方
-  organizer: { type: String, required: false, maxLength: 200 }, // 承办方
-  videodata: { type: [ videos ], select: true }, // 视频路径
-  vipuser: { type: [ vipuser ], default: [] }, // vip用户
-  desc: { type: String, maxLength: 1000 }, // 简介
-  status: { type: String, default: '0' }, // 状态:0准备中;1已开始;2已结束
-  remark: { type: String, maxLength: 200 },
-  create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
-};
-const schema = new Schema(dock, { toJSON: { virtuals: true } });
-schema.index({ id: 1 });
-schema.index({ room_id: 1 });
-schema.index({ start_time: 1 });
-schema.index({ 'meta.createdAt': 1 });
-schema.plugin(metaPlugin);
-module.exports = app => {
-  const { mongoose } = app;
-  return mongoose.model('Dock', schema, 'dock');
-};

+ 39 - 0
app/model/dock/dock.js

@@ -0,0 +1,39 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const moment = require('moment');
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+const { ObjectId } = require('mongoose').Types;
+const { Secret } = require('naf-framework-mongoose/lib/model/schema');
+// 展会表
+const dock = {
+  room_id: { type: String, required: true }, // 房间号
+  password: { type: Secret, select: false }, // 密码
+  title: { type: String, required: false, maxLength: 200 }, // 对接会标题
+  start_time: { type: String, required: true, maxLength: 200 }, // 开始时间
+  end_time: { type: String, required: true, maxLength: 200 }, // 结束时间
+  province: { type: String, required: false }, // 省
+  city: { type: String, required: false }, // 市
+  admin: { type: String, required: false, maxLength: 200 }, // 负责人
+  phone: { type: String, required: false, maxLength: 200 }, // 负责人电话
+  sponsor: { type: String, required: false, maxLength: 200 }, // 主办方
+  organizer: { type: String, required: false, maxLength: 200 }, // 承办方
+  user_id: { type: ObjectId }, // 创建人
+  status: { type: String, default: '0' }, // 0-准备中;1-开始;-1-结束
+  remark: { type: String },
+};
+const schema = new Schema(dock, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ room_id: 1 });
+schema.index({ title: 1 });
+schema.index({ start_time: 1 });
+schema.index({ end_time: 1 });
+schema.index({ admin: 1 });
+schema.index({ sponsor: 1 });
+schema.index({ user_id: 1 });
+schema.index({ status: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Dock', schema, 'dock');
+};

app/model/dock_chat.js → app/model/dock/dock_chat.js


+ 23 - 0
app/model/dock/dock_imgtxt.js

@@ -0,0 +1,23 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const moment = require('moment');
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+const { ObjectId } = require('mongoose').Types;
+// 展会图片表
+const dock_imgtxt = {
+  dock_id: { type: ObjectId, required: true }, // 展会id
+  content: { type: String }, // 信息内容
+  img_url: { type: String }, // 图片
+  file_url: { type: String }, // 视频地址
+  user_id: { type: ObjectId }, // 创建人
+  remark: { type: String },
+};
+const schema = new Schema(dock_imgtxt, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ dock_id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Dock_imgtxt', schema, 'dock_imgtxt');
+};

+ 34 - 0
app/model/dock/dock_transcation.js

@@ -0,0 +1,34 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const moment = require('moment');
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+const { ObjectId } = require('mongoose').Types;
+// 表
+const dock_transcation = {
+  dock_id: { type: ObjectId }, // 展会id
+  product_id: { type: ObjectId }, // 产品id
+  s_id: { type: ObjectId }, // 供给者id
+  s_name: { type: String }, // 供给者姓名
+  s_phone: { type: String }, // 供给者电话
+  d_id: { type: ObjectId }, // 需求者id
+  d_name: { type: String }, // 需求者姓名
+  d_phone: { type: String }, // 需求者电话
+  status: { type: String, default: '0' }, // 0-正在洽谈,1-达成意向,2-交易备案,3-交易完成,4-交易失败
+  contact: { type: String }, // 合同备份
+  remark: { type: String },
+};
+const schema = new Schema(dock_transcation, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ dock_id: 1 });
+schema.index({ product_id: 1 });
+schema.index({ s_id: 1 });
+schema.index({ s_name: 1 });
+schema.index({ d_id: 1 });
+schema.index({ d_name: 1 });
+schema.index({ status: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Dock_transcation', schema, 'dock_transcation');
+};

+ 30 - 0
app/model/dock/dock_user.js

@@ -0,0 +1,30 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const moment = require('moment');
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+const { ObjectId } = require('mongoose').Types;
+// 展会用户表
+const dock_user = {
+  dock_id: { type: ObjectId, required: true }, // 展会id
+  user_id: { type: ObjectId }, // 申请人
+  name: { type: String }, // 名称
+  phone: { type: String, required: false, maxLength: 200 }, // 电话
+  create_time: { type: String }, // 申请时间
+  productList: { type: Array }, // 参展项目
+  status: { type: String, default: '0' }, // 0-待审核;1-审核通过;-1-审核拒绝
+  remark: { type: String },
+};
+const schema = new Schema(dock_user, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ dock_id: 1 });
+schema.index({ name: 1 });
+schema.index({ phone: 1 });
+schema.index({ status: 1 });
+schema.index({ user_id: 1 });
+schema.index({ create_time: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Dock_user', schema, 'dock_user');
+};

+ 25 - 0
app/model/dock/dock_video.js

@@ -0,0 +1,25 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const moment = require('moment');
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+const { ObjectId } = require('mongoose').Types;
+// 展会视频表表
+const dock_video = {
+  dock_id: { type: ObjectId, required: true }, // 展会id
+  title: { type: String, required: false, maxLength: 200 }, // 标题
+  brief: { type: String }, // 简介
+  file_url: { type: String }, // 视频地址
+  user_id: { type: ObjectId }, // 创建人
+  remark: { type: String },
+};
+const schema = new Schema(dock_video, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ dock_id: 1 });
+schema.index({ title: 1 });
+schema.index({ user_id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Dock_video', schema, 'dock_video');
+};

+ 27 - 0
app/model/dock/dock_vip.js

@@ -0,0 +1,27 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const moment = require('moment');
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+const { ObjectId } = require('mongoose').Types;
+const { Secret } = require('naf-framework-mongoose/lib/model/schema');
+// 展会vip表
+const dock_vip = {
+  dock_id: { type: ObjectId, required: true }, // 展会id
+  name: { type: String }, // 名称
+  phone: { type: String, required: false, maxLength: 200 }, // 电话
+  password: { type: Secret, select: false }, // 密码
+  email: { type: String, required: false, maxLength: 200 }, // 邮箱
+  brief: { type: String, required: false, maxLength: 200 }, // 简介
+  remark: { type: String },
+};
+const schema = new Schema(dock_vip, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ dock_id: 1 });
+schema.index({ name: 1 });
+schema.index({ phone: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Dock_vip', schema, 'dock_vip');
+};

+ 0 - 24
app/model/dock_pw.js

@@ -1,24 +0,0 @@
-'use strict';
-const Schema = require('mongoose').Schema;
-const moment = require('moment');
-const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
-const { Secret } = require('naf-framework-mongoose/lib/model/schema');
-const { ObjectId } = require('mongoose').Types;
-
-// 展会-图文表
-const dockpw = {
-  dock_id: { type: ObjectId }, // 展会id
-  content: { type: String, maxLength: 500 }, // 信息内容
-  url: { type: Array }, // 图片路径
-  file_path: { type: String }, // 视频路径
-  remark: { type: String, maxLength: 200 },
-  create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
-};
-const schema = new Schema(dockpw, { toJSON: { virtuals: true } });
-schema.index({ id: 1 });
-schema.index({ 'meta.createdAt': 1 });
-schema.plugin(metaPlugin);
-module.exports = app => {
-  const { mongoose } = app;
-  return mongoose.model('Dock_pw', schema, 'dock_pw');
-};

+ 0 - 29
app/model/dock_user.js

@@ -1,29 +0,0 @@
-'use strict';
-const Schema = require('mongoose').Schema;
-const moment = require('moment');
-const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
-const { Secret } = require('naf-framework-mongoose/lib/model/schema');
-const { ObjectId } = require('mongoose').Types;
-// 展会-用户表
-const dockUser = {
-  dock_id: { type: ObjectId }, // 展会id
-  user_id: { type: ObjectId, required: true }, // 用户id
-  user_name: { type: String, required: true, maxLength: 200 }, // 用户名称
-  goodsList: { type: [ Object ], default: [] }, // 产品列表
-  contact_tel: { type: String, required: false, maxLength: 200 }, // 联系人电话
-  apply_time: { type: String, maxLength: 200 }, // 申请时间
-  // role: { type: String, maxLength: 200 }, // 申请人类型
-  status: { type: String, default: '0', maxLength: 1 }, // 申请状态 (0未审核;1已通过;2已拒绝)
-  remark: { type: String, maxLength: 200 },
-  create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
-};
-const schema = new Schema(dockUser, { toJSON: { virtuals: true } });
-schema.index({ id: 1 });
-schema.index({ dock_id: 1 });
-schema.index({ status: 1 });
-schema.index({ 'meta.createdAt': 1 });
-schema.plugin(metaPlugin);
-module.exports = app => {
-  const { mongoose } = app;
-  return mongoose.model('Dock_user', schema, 'dock_user');
-};

+ 27 - 25
app/model/person_room.js

@@ -1,25 +1,27 @@
-'use strict';
-const Schema = require('mongoose').Schema;
-const moment = require('moment');
-const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
-const { Secret } = require('naf-framework-mongoose/lib/model/schema');
-const { ObjectId } = require('mongoose').Types;
-// 个人聊天房间表
-const person_room = {
-  p1_id: { type: ObjectId, required: true }, // 第一个人id
-  p1: { type: String, required: false }, // 第一个人名
-  p2_id: { type: ObjectId, required: true }, // 第二个人id
-  p2: { type: String, required: false }, // 第二个人名
-  create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
-  last_time: { type: String }, // 最后发言时间
-};
-const schema = new Schema(person_room, { toJSON: { virtuals: true } });
-schema.index({ id: 1 });
-schema.index({ p1_id: 1 });
-schema.index({ p2_id: 1 });
-schema.index({ 'meta.createdAt': 1 });
-schema.plugin(metaPlugin);
-module.exports = app => {
-  const { mongoose } = app;
-  return mongoose.model('Person_room', schema, 'person_room');
-};
+'use strict';
+const Schema = require('mongoose').Schema;
+const moment = require('moment');
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+const { Secret } = require('naf-framework-mongoose/lib/model/schema');
+const { ObjectId } = require('mongoose').Types;
+// 个人聊天房间表
+const person_room = {
+  product_id: { type: ObjectId }, // 产品
+  p1_id: { type: ObjectId, required: true }, // 第一个人id
+  p1: { type: String, required: false }, // 第一个人名
+  p2_id: { type: ObjectId, required: true }, // 第二个人id
+  p2: { type: String, required: false }, // 第二个人名
+  create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
+  last_time: { type: String }, // 最后发言时间
+};
+const schema = new Schema(person_room, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ product_id: 1 });
+schema.index({ p1_id: 1 });
+schema.index({ p2_id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Person_room', schema, 'person_room');
+};

+ 0 - 41
app/model/transaction.js

@@ -1,41 +0,0 @@
-'use strict';
-const Schema = require('mongoose').Schema;
-const moment = require('moment');
-const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
-const { Secret } = require('naf-framework-mongoose/lib/model/schema');
-const { ObjectId } = require('mongoose').Types;
-
-// 合同备案
-const pact = new Schema({
-  file_path: { type: String }, // 合同图片
-  desc: { type: String }, // 描述
-  // status: { type: String, default: '0' }, // 状态(0:待审核 1:通过审核)
-});
-// 交易表
-const transaction = {
-  dock_id: { type: ObjectId }, // 展会id
-  supplier: { type: ObjectId }, // 供给者
-  s_name: { type: String }, // 供给者姓名
-  s_phone: { type: String }, // 供给者联系电话
-  demander: { type: ObjectId }, // 需求者
-  d_name: { type: String }, // 需求者姓名
-  d_phone: { type: String }, // 需求者联系电话
-  product_id: { type: ObjectId }, // 产品id
-  product: { type: String }, // 产品名称
-  pact: { type: pact }, // 合同备案
-  status: { type: String, default: '0' }, // 状态(0-正在洽谈;1-达成意向;2-交易备案(待确定);3-交易完成;4-交易失败)
-  remark: { type: String, maxLength: 200 },
-  create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
-};
-const schema = new Schema(transaction, { toJSON: { virtuals: true } });
-schema.index({ id: 1 });
-schema.index({ dock_id: 1 });
-schema.index({ supplier: 1 });
-schema.index({ demander: 1 });
-schema.index({ product: 1 });
-schema.index({ 'meta.createdAt': 1 });
-schema.plugin(metaPlugin);
-module.exports = app => {
-  const { mongoose } = app;
-  return mongoose.model('Transaction', schema, 'transaction');
-};

+ 18 - 10
app/router.js

@@ -14,6 +14,7 @@ module.exports = app => {
   router.post(`${profix}${vision}/util`, controller.home.utilMethod);
   router.post(`${profix}${vision}/spm`, controller.home.spm);
   router.get(`${profix}${vision}/index`, controller.home.indexQuery);
+  // users
   require('./router/users/admin')(app); // 管理员
   require('./router/users/personal')(app); // 个人用户
   require('./router/users/organization')(app); // 机构用户
@@ -23,34 +24,41 @@ module.exports = app => {
   require('./router/users/person_chat')(app); // 个人聊天
   require('./router/users/question')(app); // 调研调查
   require('./router/users/project_solic')(app); // 项目征集
+  // system
   require('./router/system/menu')(app); // 菜单
   require('./router/system/category')(app); // 字典类别
   require('./router/system/code')(app); // 字典
   require('./router/system/invite_code')(app); // 邀请码
   require('./router/system/notice')(app); // 通知管理
   require('./router/system/survey')(app); // 建言献策,网上调查
-  require('./router/dock/index')(app); // 展会
-  require('./router/dock/dock_pw')(app); // 展会-图文
-  require('./router/dock/dock_user')(app); // 展会-用户
-  require('./router/dock/dock_chat')(app); // 展会-公共聊天
-  require('./router/dock/transaction')(app); // 交易合同+备案
+  // dock
   require('./router/dock/road_show')(app); // 路演
+  require('./router/dock/interview')(app); // 访谈
+  require('./router/dock/dock')(app); // 展会
+  require('./router/dock/dock_video')(app); // 展会-视频
+  require('./router/dock/dock_imgtxt')(app); // 展会-图文
+  require('./router/dock/dock_user')(app); // 展会-用户
+  require('./router/dock/dock_vip')(app); // 展会-vip用户
+  require('./router/dock/dock_transcation')(app); // 展会-合同
+  require('./router/dock/train_live')(app); // 培训
+  require('./router/dock/train_chat')(app); // 展会-聊天
   require('./router/dock/channel')(app); // 科技频道
-  require('./router/dock/channel_video')(app); // 科技频道-视频
-  require('./router/dock/train_chat')(app); // 培训问诊聊天
+  require('./router/dock/channel_video')(app); // 科技频道视频
+  require('./router/dock/dock_chat')(app); // 展会聊天
+  // tecinfo
   require('./router/tecinfo/column')(app); // 栏目
   require('./router/tecinfo/news')(app); // 信息
-  require('./router/dock/interview')(app); // 访谈
-  require('./router/dock/train_live')(app); // 培训问诊
-  require('./router/dock/patent')(app); // e专利
   require('./router/tecinfo/science')(app); // 科技新闻
+  // statistics
   require('./router/statistics/index')(app); // 首页统计
+  // cysci
   require('./router/cysci/coupons')(app); // 创新券
   require('./router/cysci/coupons_apply')(app); // 创新券申请
   require('./router/cysci/declare')(app); // 高企申报
   require('./router/cysci/cashing')(app); // 高企申报兑付
   require('./router/cysci/reward')(app); // 研发补贴/奖励兑换申领
   require('./router/cysci/mechanism')(app); // 机构
+  // kjzl
   require('./router/kjzl/kjzl_mini_video')(app); // 科教之旅-微视频
   require('./router/kjzl/kjzl_refute')(app); // 科教之旅-科学辟谣
   require('./router/kjzl/kjzl_medium')(app); // 科教之旅-机构

+ 13 - 13
app/router/dock/channel.js

@@ -1,13 +1,13 @@
-'use strict';
-
-
-module.exports = app => {
-  const { router, controller } = app;
-  const profix = '/api/live/';
-  const vision = 'v0';
-  const index = 'dock';
-  const target = 'channel';
-  router.post(target, `${profix}${vision}/${index}/${target}/login`, controller[index][target].login);
-  router.resources(target, `${profix}${vision}/${index}/${target}`, controller[index][target]); // index、create、show、destroy
-  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
-};
+'use strict';
+
+
+module.exports = app => {
+  const { router, controller } = app;
+  const profix = '/api/live/';
+  const vision = 'v0';
+  const index = 'dock';
+  const target = 'channel';
+  router.post(target, `${profix}${vision}/${index}/${target}/login`, controller[index][target].login);
+  router.resources(target, `${profix}${vision}/${index}/${target}`, controller[index][target]); // index、create、show、destroy
+  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
+};

+ 12 - 12
app/router/dock/channel_video.js

@@ -1,12 +1,12 @@
-'use strict';
-
-
-module.exports = app => {
-  const { router, controller } = app;
-  const profix = '/api/live/';
-  const vision = 'v0';
-  const index = 'dock';
-  const target = 'channelVideo';
-  router.resources(target, `${profix}${vision}/${index}/${target}`, controller[index][target]); // index、create、show、destroy
-  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
-};
+'use strict';
+
+
+module.exports = app => {
+  const { router, controller } = app;
+  const profix = '/api/live/';
+  const vision = 'v0';
+  const index = 'dock';
+  const target = 'channelVideo';
+  router.resources(target, `${profix}${vision}/${index}/${target}`, controller[index][target]); // index、create、show、destroy
+  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
+};

+ 1 - 3
app/router/dock/index.js

@@ -6,9 +6,7 @@ module.exports = app => {
   const profix = '/api/live/';
   const vision = 'v0';
   const index = 'dock';
-  const target = 'index';
-  router.get(target, `${profix}${vision}/${index}/${target}/product`, controller[index][target].product);
-  router.post(target, `${profix}${vision}/${index}/${target}/viplogin/:id`, controller[index][target].vipLogin);
+  const target = 'dock';
   router.post(target, `${profix}${vision}/${index}/${target}/login`, controller[index][target].login);
   router.resources(target, `${profix}${vision}/${index}/${target}`, controller[index][target]); // index、create、show、destroy
   router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);

+ 12 - 12
app/router/dock/dock_chat.js

@@ -1,12 +1,12 @@
-'use strict';
-
-
-module.exports = app => {
-  const { router, controller } = app;
-  const profix = '/api/live/';
-  const vision = 'v0';
-  const index = 'dock';
-  const target = 'dockChat';
-  router.resources(target, `${profix}${vision}/${index}/${target}`, controller[index][target]); // index、create、show、destroy
-  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
-};
+'use strict';
+
+
+module.exports = app => {
+  const { router, controller } = app;
+  const profix = '/api/live/';
+  const vision = 'v0';
+  const index = 'dock';
+  const target = 'dockChat';
+  router.resources(target, `${profix}${vision}/${index}/${target}`, controller[index][target]); // index、create、show、destroy
+  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
+};

+ 1 - 7
app/router/dock/patent.js

@@ -6,13 +6,7 @@ module.exports = app => {
   const profix = '/api/live/';
   const vision = 'v0';
   const index = 'dock';
-  const target = 'patent';
-  // 专利表
+  const target = 'dockImgtxt';
   router.resources(target, `${profix}${vision}/${index}/${target}`, controller[index][target]); // index、create、show、destroy
   router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
-  // 导入专利
-  router.post(target, `${profix}${vision}/${index}/${target}/import`, controller[index][target].toImport);
-  // 导出
-  router.post(target, `${profix}${vision}/${index}/${target}/export`, controller[index][target].toExport);
-
 };

+ 14 - 0
app/router/dock/dock_transcation.js

@@ -0,0 +1,14 @@
+'use strict';
+
+
+module.exports = app => {
+  const { router, controller } = app;
+  const profix = '/api/live/';
+  const vision = 'v0';
+  const index = 'dock';
+  const target = 'dockTranscation';
+  const product = app.middleware.dockTranscation();
+  router.get(target, `${profix}${vision}/${index}/${target}/userList`, product, controller[index][target].getUserList);
+  router.resources(target, `${profix}${vision}/${index}/${target}`, product, controller[index][target]); // index、create、show、destroy
+  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
+};

+ 2 - 3
app/router/dock/dock_user.js

@@ -7,9 +7,8 @@ module.exports = app => {
   const vision = 'v0';
   const index = 'dock';
   const target = 'dockUser';
-  router.get(target, `${profix}${vision}/${index}/${target}/find`, controller[index][target].findUser);
-  router.post(target, `${profix}${vision}/${index}/${target}/check/user/:id`, controller[index][target].userCheck);
-  router.post(target, `${profix}${vision}/${index}/${target}/check/goods/:id`, controller[index][target].goodsCheck);
+  router.post(target, `${profix}${vision}/${index}/${target}/goodCheck/:id`, controller[index][target].goodCheck);
+  router.post(target, `${profix}${vision}/${index}/${target}/userCheck/:id`, controller[index][target].userCheck);
   router.resources(target, `${profix}${vision}/${index}/${target}`, controller[index][target]); // index、create、show、destroy
   router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
 };

+ 1 - 1
app/router/dock/dock_pw.js

@@ -6,7 +6,7 @@ module.exports = app => {
   const profix = '/api/live/';
   const vision = 'v0';
   const index = 'dock';
-  const target = 'dockPw';
+  const target = 'dockVideo';
   router.resources(target, `${profix}${vision}/${index}/${target}`, controller[index][target]); // index、create、show、destroy
   router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
 };

+ 2 - 2
app/router/dock/transaction.js

@@ -6,8 +6,8 @@ module.exports = app => {
   const profix = '/api/live/';
   const vision = 'v0';
   const index = 'dock';
-  const target = 'transaction';
-  router.post(target, `${profix}${vision}/${index}/${target}/step/:id`, controller[index][target].step);
+  const target = 'dockVip';
+  router.post(target, `${profix}${vision}/${index}/${target}/login/:id`, controller[index][target].login);
   router.resources(target, `${profix}${vision}/${index}/${target}`, controller[index][target]); // index、create、show、destroy
   router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
 };

+ 27 - 27
app/router/dock/train_live.js

@@ -1,27 +1,27 @@
-'use strict';
-
-
-module.exports = app => {
-  const { router, controller } = app;
-  const profix = '/api/live/';
-  const vision = 'v0';
-  const index = 'dock';
-  const target = 'trainLive';
-  // 延长登陆
-  router.get(target, `${profix}${vision}/${index}/${target}/user/longer/:id`, controller[index][target].userLonger);
-  // 培训问诊管理员登陆
-  router.post(target, `${profix}${vision}/${index}/${target}/login`, controller[index][target].login);
-  // 参会人员登陆
-  router.post(target, `${profix}${vision}/${index}/${target}/user/login/:id`, controller[index][target].userLogin);
-  // 参会人员注销
-  router.post(target, `${profix}${vision}/${index}/${target}/user/logout/:id`, controller[index][target].userLogout);
-  // 添加参会人员
-  router.post(target, `${profix}${vision}/${index}/${target}/user/:id`, controller[index][target].addUser);
-  // 删除参会人员
-  router.delete(target, `${profix}${vision}/${index}/${target}/user/:id`, controller[index][target].deleteUser);
-  // 修改参会人员
-  router.post(target, `${profix}${vision}/${index}/${target}/user/update/:id`, controller[index][target].updateUser);
-  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
-  router.get(target, `${profix}${vision}/${index}/${target}/user/:id`, controller[index][target].userData);
-  router.resources(target, `${profix}${vision}/${index}/${target}`, controller[index][target]); // index、create、show、destroy
-};
+'use strict';
+
+
+module.exports = app => {
+  const { router, controller } = app;
+  const profix = '/api/live/';
+  const vision = 'v0';
+  const index = 'dock';
+  const target = 'trainLive';
+  // 延长登陆
+  router.get(target, `${profix}${vision}/${index}/${target}/user/longer/:id`, controller[index][target].userLonger);
+  // 培训问诊管理员登陆
+  router.post(target, `${profix}${vision}/${index}/${target}/login`, controller[index][target].login);
+  // 参会人员登陆
+  router.post(target, `${profix}${vision}/${index}/${target}/user/login/:id`, controller[index][target].userLogin);
+  // 参会人员注销
+  router.post(target, `${profix}${vision}/${index}/${target}/user/logout/:id`, controller[index][target].userLogout);
+  // 添加参会人员
+  router.post(target, `${profix}${vision}/${index}/${target}/user/:id`, controller[index][target].addUser);
+  // 删除参会人员
+  router.delete(target, `${profix}${vision}/${index}/${target}/user/:id`, controller[index][target].deleteUser);
+  // 修改参会人员
+  router.post(target, `${profix}${vision}/${index}/${target}/user/update/:id`, controller[index][target].updateUser);
+  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
+  router.get(target, `${profix}${vision}/${index}/${target}/user/:id`, controller[index][target].userData);
+  router.resources(target, `${profix}${vision}/${index}/${target}`, controller[index][target]); // index、create、show、destroy
+};

+ 1 - 0
app/router/statistics/index.js

@@ -7,6 +7,7 @@ module.exports = app => {
   const vision = 'v0';
   const index = 'statistics';
   const target = 'index';
+  router.get(target, `${profix}${vision}/${index}/${target}/dockProduct`, controller[index][target].dockProduct);
   router.get(target, `${profix}${vision}/${index}/${target}/dockIndex`, controller[index][target].dockIndex);
   router.get(target, `${profix}${vision}/${index}/${target}/index`, controller[index][target].index);
   router.get(target, `${profix}${vision}/${index}/${target}/patent`, controller[index][target].patent);

+ 13 - 12
app/router/users/person_room.js

@@ -1,12 +1,13 @@
-'use strict';
-
-
-module.exports = app => {
-  const { router, controller } = app;
-  const profix = '/api/live/';
-  const vision = 'v0';
-  const index = 'users';
-  const target = 'personRoom';
-  router.resources(target, `${profix}${vision}/${index}/${target}`, controller[index][target]); // index、create、show、destroy
-  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
-};
+'use strict';
+
+
+module.exports = app => {
+  const { router, controller } = app;
+  const profix = '/api/live/';
+  const vision = 'v0';
+  const index = 'users';
+  const target = 'personRoom';
+  const product = app.middleware.personRoom();
+  router.resources(target, `${profix}${vision}/${index}/${target}`, product, controller[index][target]); // index、create、show、destroy
+  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
+};

+ 43 - 43
app/service/dock/channel.js

@@ -1,43 +1,43 @@
-'use strict';
-const { CrudService } = require('naf-framework-mongoose/lib/service');
-const { BusinessError, ErrorCode } = require('naf-core').Error;
-const { ObjectId } = require('mongoose').Types;
-const _ = require('lodash');
-const assert = require('assert');
-const jwt = require('jsonwebtoken');
-
-// 科技频道
-class ChannelService extends CrudService {
-  constructor(ctx) {
-    super(ctx, 'channel');
-    this.model = this.ctx.model.Channel;
-  }
-
-  async create(body) {
-    const last = await this.model.findOne().sort({ room_id: -1 });
-    let room_id = 2001;
-    if (last) room_id = last.room_id + 1;
-    body.room_id = room_id;
-    body.passwd = { secret: room_id };
-    return await this.model.create(body);
-  }
-
-  /**
-   * 管理者登陆
-   * @param {Object} { room_id, passwd } 登陆参数
-   * @property {String} room_id 房间号
-   * @property {String} passwd 密码
-   */
-  async login({ room_id, passwd }) {
-    const object = await this.model.findOne({ room_id }, '+passwd');
-    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, `未找到展会号为: ${room_id} 的展会`);
-    const op = _.get(object, 'passwd.secret');
-    if (!_.isEqual(op, passwd)) throw new BusinessError(ErrorCode.BAD_PASSWORD, '密码错误');
-    const data = _.omit(JSON.parse(JSON.stringify(object)), [ 'meta', 'passwd', '__v' ]);
-    const { secret: jwts } = this.config.jwt;
-    const token = jwt.sign(data, jwts);
-    return token;
-  }
-}
-
-module.exports = ChannelService;
+'use strict';
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const { ObjectId } = require('mongoose').Types;
+const _ = require('lodash');
+const assert = require('assert');
+const jwt = require('jsonwebtoken');
+
+// 科技频道
+class ChannelService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'channel');
+    this.model = this.ctx.model.Channel;
+  }
+
+  async create(body) {
+    const last = await this.model.findOne().sort({ room_id: -1 });
+    let room_id = 2001;
+    if (last) room_id = last.room_id + 1;
+    body.room_id = room_id;
+    body.passwd = { secret: room_id };
+    return await this.model.create(body);
+  }
+
+  /**
+   * 管理者登陆
+   * @param {Object} { room_id, passwd } 登陆参数
+   * @property {String} room_id 房间号
+   * @property {String} passwd 密码
+   */
+  async login({ room_id, passwd }) {
+    const object = await this.model.findOne({ room_id }, '+passwd');
+    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, `未找到展会号为: ${room_id} 的展会`);
+    const op = _.get(object, 'passwd.secret');
+    if (!_.isEqual(op, passwd)) throw new BusinessError(ErrorCode.BAD_PASSWORD, '密码错误');
+    const data = _.omit(JSON.parse(JSON.stringify(object)), [ 'meta', 'passwd', '__v' ]);
+    const { secret: jwts } = this.config.jwt;
+    const token = jwt.sign(data, jwts);
+    return token;
+  }
+}
+
+module.exports = ChannelService;

+ 16 - 16
app/service/dock/channel_video.js

@@ -1,16 +1,16 @@
-'use strict';
-const { CrudService } = require('naf-framework-mongoose/lib/service');
-const { BusinessError, ErrorCode } = require('naf-core').Error;
-const { ObjectId } = require('mongoose').Types;
-const _ = require('lodash');
-const assert = require('assert');
-
-// 科技频道-视频表
-class Channel_videoService extends CrudService {
-  constructor(ctx) {
-    super(ctx, 'channel_video');
-    this.model = this.ctx.model.ChannelVideo;
-  }
-}
-
-module.exports = Channel_videoService;
+'use strict';
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const { ObjectId } = require('mongoose').Types;
+const _ = require('lodash');
+const assert = require('assert');
+
+// 科技频道-视频表
+class Channel_videoService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'channel_video');
+    this.model = this.ctx.model.ChannelVideo;
+  }
+}
+
+module.exports = Channel_videoService;

+ 41 - 0
app/service/dock/dock.js

@@ -0,0 +1,41 @@
+'use strict';
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const _ = require('lodash');
+const assert = require('assert');
+const jwt = require('jsonwebtoken');
+
+// 展会
+class DockService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'dock');
+    this.model = this.ctx.model.Dock.Dock;
+  }
+  async create(body) {
+    const last = await this.model.findOne().sort({ room_id: -1 });
+    let room_id = '1001';
+    if (last) room_id = parseInt(last.room_id) + 1;
+    body.room_id = room_id;
+    body.password = { secret: room_id };
+    return await this.model.create(body);
+  }
+
+  /**
+   * 展会管理者登陆
+   * @param {Object} { room_phone, password } 登陆参数
+   * @property {String} room_phone 房间号/电话
+   * @property {String} password 密码
+   */
+  async login({ room_id, password }) {
+    const object = await this.model.findOne({ room_id }, '+password');
+    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, `未找到展会号为: ${room_id} 的展会`);
+    const op = _.get(object, 'password.secret');
+    if (!_.isEqual(op, password)) throw new BusinessError(ErrorCode.BAD_PASSWORD, '密码错误');
+    const data = _.omit(JSON.parse(JSON.stringify(object)), [ 'meta', 'password', '__v' ]);
+    const { secret: jwts } = this.config.jwt;
+    const token = jwt.sign(data, jwts);
+    return token;
+  }
+}
+
+module.exports = DockService;

+ 1 - 1
app/service/dock/dock_chat.js

@@ -8,7 +8,7 @@ const assert = require('assert');
 class Dock_chatService extends CrudService {
   constructor(ctx) {
     super(ctx, 'dock_chat');
-    this.model = this.ctx.model.DockChat;
+    this.model = this.ctx.model.Dock.DockChat;
   }
   async create(data) {
     const res = await this.model.create(data);

+ 5 - 7
app/service/dock/dock_pw.js

@@ -1,17 +1,15 @@
 'use strict';
 const { CrudService } = require('naf-framework-mongoose/lib/service');
 const { BusinessError, ErrorCode } = require('naf-core').Error;
-const { ObjectId } = require('mongoose').Types;
 const _ = require('lodash');
 const assert = require('assert');
 
-// 展会-图文
-class Dock_pwService extends CrudService {
+// 展会图文
+class Dock_imgtxtService extends CrudService {
   constructor(ctx) {
-    super(ctx, 'dock_pw');
-    this.model = this.ctx.model.DockPw;
+    super(ctx, 'dock_imgtxt');
+    this.model = this.ctx.model.Dock.DockImgtxt;
   }
-
 }
 
-module.exports = Dock_pwService;
+module.exports = Dock_imgtxtService;

+ 27 - 0
app/service/dock/dock_transcation.js

@@ -0,0 +1,27 @@
+'use strict';
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const _ = require('lodash');
+const assert = require('assert');
+
+// 展会合同备份
+class Dock_transcationService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'dock_transcation');
+    this.model = this.ctx.model.Dock.DockTranscation;
+  }
+
+  /**
+   * 查该用户的供/需记录
+   * @param {Object} Object
+   */
+  async getUserList({ skip = 0, limit = 0, ...query } = {}) {
+    const { user_id, ...info } = query;
+    const nquery = { ...info, $or: [{ s_id: user_id }, { d_id: user_id }] };
+    const data = await this.model.find(nquery).skip(parseInt(skip)).limit(parseInt(limit));
+    const total = await this.model.count(nquery);
+    return { data, total };
+  }
+}
+
+module.exports = Dock_transcationService;

+ 36 - 22
app/service/dock/dock_user.js

@@ -1,39 +1,56 @@
 'use strict';
 const { CrudService } = require('naf-framework-mongoose/lib/service');
 const { BusinessError, ErrorCode } = require('naf-core').Error;
-const { ObjectId } = require('mongoose').Types;
 const _ = require('lodash');
+const { ObjectId } = require('mongoose').Types;
 const assert = require('assert');
 
-// 展会-用户
+// 展会用户
 class Dock_userService extends CrudService {
   constructor(ctx) {
     super(ctx, 'dock_user');
-    this.model = this.ctx.model.DockUser;
+    this.model = this.ctx.model.Dock.DockUser;
   }
-
   async create(data) {
-    const { goodsList = [] } = data;
-    if (goodsList.length > 0) {
-      data.goodsList = goodsList.map(i => {
-        if (!i.status) i.status = '0';
+    const { dock_id, user_id } = data;
+    let { productList } = data;
+    const user = await this.model.findOne({ dock_id, user_id });
+    if (!user) {
+      const { productList = [] } = data;
+      if (productList.length > 0) {
+        data.productList = productList.map(i => {
+          i.status = '0';
+          i._id = ObjectId();
+          return i;
+        });
+      }
+      return await this.model.create(data);
+    }
+    productList = _.differenceBy(productList, user.productList, 'id');
+    if (productList.length > 0) {
+      productList = productList.map(i => {
+        i.status = '0';
         i._id = ObjectId();
         return i;
       });
     }
-    return await this.model.create(data);
+    user.productList = user.productList.concat(productList);
+    return await user.save();
+
   }
 
   async update({ id }, data) {
-    const { goodsList = [] } = data;
-    if (goodsList.length > 0) {
-      data.goodsList = goodsList.map(i => {
-        if (!i.status) i.status = '0';
+    const { productList = [] } = data;
+    if (productList.length > 0) {
+      data.productList = productList.map(i => {
+        console.log(i.status);
+        if (i.status === '1') data.status = '1';
         if (!i._id)i._id = ObjectId();
         else i._id = ObjectId(i._id);
         return i;
       });
     }
+    console.log(data);
     return this.model.updateOne({ _id: ObjectId(id) }, data);
   }
 
@@ -43,14 +60,14 @@ class Dock_userService extends CrudService {
    * @param {Object} {good_id, status} 要改变的状态
    * 只要有一个产品通过审核,该用户就更变为可通过状态=>need_pass_user
    */
-  async goodsCheck({ id }, { good_id, status }) {
-    const object = await this.model.findOne({ _id: ObjectId(id), goodsList: { $elemMatch: { id: good_id } } });
+  async goodCheck({ id }, { good_id, status }) {
+    const object = await this.model.findOne({ _id: ObjectId(id), productList: { $elemMatch: { id: good_id } } });
     if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到需要审核的产品信息');
-    const product = object.goodsList.find(f => ObjectId(good_id).equals(f.id));
+    const product = object.productList.find(f => ObjectId(good_id).equals(f.id));
     if (!product) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未在需要审核的产品中找到指定的产品');
     product.status = status;
-    await this.model.updateOne({ _id: ObjectId(id), goodsList: { $elemMatch: { id: good_id } } }, object);
-    const need_pass_user = object.goodsList.some(e => e.status === '1');
+    await this.model.updateOne({ _id: ObjectId(id), productList: { $elemMatch: { id: good_id } } }, object);
+    const need_pass_user = object.productList.some(e => e.status === '1');
     if (need_pass_user) this.userCheck({ id: object._id }, { status: '1' });
   }
 
@@ -66,10 +83,7 @@ class Dock_userService extends CrudService {
     await object.save();
   }
 
-  async findUser({ dock_id, user_id }) {
-    const res = await this.model.findOne({ dock_id: ObjectId(dock_id), user_id: ObjectId(user_id) });
-    return res;
-  }
+
 }
 
 module.exports = Dock_userService;

+ 15 - 0
app/service/dock/dock_video.js

@@ -0,0 +1,15 @@
+'use strict';
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const _ = require('lodash');
+const assert = require('assert');
+
+// 展会视频
+class Dock_videoService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'dock_video');
+    this.model = this.ctx.model.Dock.DockVideo;
+  }
+}
+
+module.exports = Dock_videoService;

+ 42 - 0
app/service/dock/dock_vip.js

@@ -0,0 +1,42 @@
+'use strict';
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const _ = require('lodash');
+const assert = require('assert');
+const jwt = require('jsonwebtoken');
+
+// 展会vip
+class Dock_vipService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'dock_vip');
+    this.model = this.ctx.model.Dock.DockVip;
+    this.dock = this.ctx.model.Dock.Dock;
+  }
+  async create(data) {
+    const { dock_id } = data;
+    const dock = await this.dock.findById(dock_id);
+    if (!dock) new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定展会!');
+    const { room_id } = dock;
+    data.password = { secret: room_id };
+    return await this.model.create(data);
+  }
+  /**
+   * 展会管理者登陆
+   * @param {Object} { dock_id } 展会id
+   * @param {Object} { phone, password } 登陆参数
+   * @property {String} phone 电话
+   * @property {String} password 密码
+   */
+  async login({ dock_id }, { phone, password }) {
+    const object = await this.model.findOne({ phone, dock_id }, '+password');
+    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到vip用户');
+    const op = _.get(object, 'password.secret');
+    if (!_.isEqual(op, password)) throw new BusinessError(ErrorCode.BAD_PASSWORD, '密码错误');
+    const data = _.omit(JSON.parse(JSON.stringify(object)), [ 'meta', 'password', '__v' ]);
+    const { secret: jwts } = this.config.jwt;
+    const token = jwt.sign(data, jwts);
+    return token;
+  }
+}
+
+module.exports = Dock_vipService;

+ 0 - 94
app/service/dock/index.js

@@ -1,94 +0,0 @@
-'use strict';
-const { CrudService } = require('naf-framework-mongoose/lib/service');
-const { BusinessError, ErrorCode } = require('naf-core').Error;
-const { ObjectId } = require('mongoose').Types;
-const _ = require('lodash');
-const assert = require('assert');
-const jwt = require('jsonwebtoken');
-
-
-// 展会
-class IndexService extends CrudService {
-  constructor(ctx) {
-    super(ctx, 'index');
-    this.model = this.ctx.model.Dock;
-    this.dockUser = this.ctx.model.DockUser;
-  }
-  async create(body) {
-    const last = await this.model.findOne().sort({ room_id: -1 });
-    let room_id = '1001';
-    if (last) room_id = parseInt(last.room_id) + 1;
-    body.room_id = room_id;
-    body.password = { secret: room_id };
-    const { vipuser } = body;
-    if (_.isArray(vipuser) && vipuser.length > 0) {
-      body.vipuser = vipuser.map(i => {
-        const { password, vipname } = i;
-        if (password) {
-          i.password = { secret: password };
-        } else {
-          i.password = vipname;
-        }
-        return i;
-      });
-    }
-    return await this.model.create(body);
-  }
-  /**
-   * 展会管理者登陆
-   * @param {Object} { room_phone, password } 登陆参数
-   * @property {String} room_phone 房间号/电话
-   * @property {String} password 密码
-   */
-  async login({ room_phone, password }) {
-    const object = await this.model.findOne({ room_id: room_phone }, '+password');
-    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, `未找到展会号为: ${room_phone} 的展会`);
-    const op = _.get(object, 'password.secret');
-    if (!_.isEqual(op, password)) throw new BusinessError(ErrorCode.BAD_PASSWORD, '密码错误');
-    const data = _.omit(JSON.parse(JSON.stringify(object)), [ 'meta', 'passwd', '__v' ]);
-    const { secret: jwts } = this.config.jwt;
-    const token = jwt.sign(data, jwts);
-    return token;
-  }
-
-  /**
-   * vip用户登陆
-   * @param {Obejct} { id, room_phone, password } vip登陆信息
-   * @property {String} id 展会id
-   * @property {String} room_phone 房间号/电话
-   * @property {String} password 密码
-   */
-  async vipLogin({ id, room_phone, password }) {
-    const object = await this.model.findOne({ _id: ObjectId(id) }, '+vipuser.password');
-    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到展会');
-    const { vipuser } = object;
-    const user = vipuser.find(f => _.isEqual(f.vipphone, room_phone));
-    if (!user) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, `未在${object.room_id}展会中找到手机号为 ${room_phone} 的vip`);
-    const op = _.get(user, 'password.secret');
-    if (!_.isEqual(op, password)) throw new BusinessError(ErrorCode.BAD_PASSWORD, '密码错误');
-    const data = {
-      name: _.get(user, 'vipname'),
-      phone: _.get(user, 'vipphone'),
-      remark: id,
-    };
-    const { secret: jwts } = this.config.jwt;
-    const token = jwt.sign(data, jwts);
-    return token;
-  }
-
-  async dockProduct({ dock_id, type, field, skip = 0, limit = 10 } = {}) {
-    assert(dock_id, '缺少展会信息');
-    assert(type, '要查询的类型');
-    const query = { dockStatus: '1' };
-    if (field) query.field = field;
-    const res = await this.dockUser.aggregate([
-      { $match: { dock_id: ObjectId(dock_id), 'goodsList.type': type, 'goodsList.dockStatus': '1' } },
-      { $project: { goodsList: 1 } },
-      { $unwind: '$goodsList' },
-    ]);
-    const list = res.map(i => i.goodsList);
-    return { data: _.slice(list, parseInt(skip), parseInt(skip) + parseInt(limit)), total: list.length };
-  }
-}
-
-module.exports = IndexService;

+ 0 - 286
app/service/dock/patent.js

@@ -1,286 +0,0 @@
-'use strict';
-
-const assert = require('assert');
-const moment = require('moment');
-const Excel = require('exceljs');
-const Path = require('path');
-const _ = require('lodash');
-const { sep } = require('path');
-const fs = require('fs');
-const { CrudService } = require('naf-framework-mongoose/lib/service');
-const { BusinessError, ErrorCode } = require('naf-core').Error;
-
-class PatentService extends CrudService {
-  constructor(ctx) {
-    super(ctx, 'patent');
-    this.model = this.ctx.model.Patent;
-    this.root_path = _.get(this.ctx.app.config.export, 'root_path');
-    this.file_type = '';
-    if (!fs.existsSync(`${this.root_path}${this.file_type}`)) {
-      // 如果不存在文件夹,就创建
-      fs.mkdirSync(`${this.root_path}${this.file_type}`);
-    }
-    this.excel_path = `${sep}excel${sep}`;
-    this.domain = 'http://127.0.0.1';
-    this.export_limit = 50;
-  }
-
-  async toImport({ uri, origin }) {
-    assert(uri, '未获取到文件地址');
-    const file = await this.ctx.curl(`${this.domain}${uri}`);
-    if (!(file && file.data)) {
-      throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定文件');
-    }
-    const workbook = new Excel.Workbook();
-    await workbook.xlsx.load(file.data);
-    const sheet = workbook.getWorksheet(1);
-    const arr = [];
-    const allNotice = [];
-    const sheetImageInfo = sheet.getImages();
-    const imgids = _.compact(sheetImageInfo.map(i => {
-      const { imageId, range } = i;
-      const row = _.get(range, 'tl.nativeRow');
-      if (row) return { row, imageId };
-    }));
-    sheet.eachRow((row, rindex) => {
-      if (rindex !== 1) {
-        // 组织数据,图片的索引和行索引不一致,准确的说是:图片索引比行索引少1
-        // 原因:图片在工作簿中获取,按照1,2,3...顺序排序,但是行的第一行是表头(当前文件),所以当前行数需要减掉表头那一行
-        const imgid = imgids.find(f => f.row === rindex - 1);
-        let img_url;
-        if (imgid) { img_url = this.turnImageToBase64(workbook.getImage(imgid.imageId)); }
-        const create_number = row.getCell(2).value || undefined,
-          create_date =
-            moment(row.getCell(3).value).format('YYYY-MM-DD') || undefined,
-          success_number = row.getCell(4).value || undefined,
-          success_date =
-            moment(row.getCell(5).value).format('YYYY-MM-DD') || undefined,
-          inventor = row.getCell(6).value || undefined,
-          agent = row.getCell(7).value || undefined,
-          agent_personal = row.getCell(8).value || undefined,
-          abstract = row.getCell(9).value || undefined,
-          address = row.getCell(10).value || undefined,
-          name = row.getCell(11).value || undefined,
-          apply_personal = row.getCell(12).value || undefined,
-          term = row.getCell(13).value || undefined,
-          type = row.getCell(14).value || undefined,
-          number = row.getCell(1).value || undefined;
-        const obj = {
-          create_number,
-          create_date,
-          success_number,
-          success_date,
-          inventor,
-          agent,
-          agent_personal,
-          abstract,
-          address,
-          name,
-          apply_personal,
-          term,
-          type,
-          img_url,
-          number,
-          origin,
-        };
-        // 此处添加判断条件,不限制则不需要加,直接放过即可
-        const { result, notice } = this.tocheckData(obj);
-        if (result) {
-          arr.push(obj);
-        } else {
-          allNotice.push(notice);
-        }
-      }
-    });
-    if (allNotice.length > 0) return allNotice;
-    await this.model.insertMany(arr);
-
-  }
-  async toExport({ user }) {
-    const data = {
-      title: '专利导出',
-      params: {
-        project: 'market',
-        service: 'patent',
-        method: 'export',
-      },
-      user,
-    };
-    try {
-      await this.ctx.service.util.httpUtil.cpost('/api/mission', 'mission', data);
-    } catch (error) {
-      console.log(error);
-      throw new BusinessError(ErrorCode.SERVICE_FAULT, '任务创建失败');
-
-    }
-  }
-
-  async export({ missionid }) {
-    const nowDate = new Date().getTime();
-    const filename = `导出结果-${nowDate}.xlsx`;
-    const path = `${this.root_path}${this.file_type}${this.excel_path}`;
-    if (!path) {
-      throw new BusinessError(ErrorCode.BUSINESS, '服务端没有设置存储路径');
-    }
-    if (!fs.existsSync(path)) {
-      // 如果不存在文件夹,就创建
-      fs.mkdirSync(path);
-    }
-    const total = await this.model.count();
-    let skip = 0;
-    let downloadPath;
-    // 将数据分割,否则容易直接把js堆栈干满了,服务就炸了
-    for (let i = 0; i < total; i = i + this.export_limit) {
-      const list = await this.model.find().skip(skip).limit(this.export_limit);
-      skip = skip + this.export_limit;
-      downloadPath = await this.asyncExport(list, filename, path, downloadPath);
-      try {
-        const data = {
-          progress: _.ceil((skip / total) * 100),
-          status: '1',
-          id: missionid,
-        };
-        this.ctx.service.util.httpUtil.cpost('/api/mission/progress', 'mission', data);
-      } catch (error) {
-        this.logger.error(`任务id:${missionid},进度更新失败`);
-      }
-    }
-    try {
-      const data = {
-        progress: 100,
-        status: '2',
-        uri: downloadPath,
-      };
-      await this.ctx.service.util.httpUtil.cpost(`/api/mission/update/${missionid}`, 'mission', data);
-    } catch (error) {
-      this.logger.error(`任务id:${missionid},已完成更新失败`);
-    }
-    return downloadPath;
-
-  }
-
-  async asyncExport(list, filename, path, downloadPath) {
-    const workbook = new Excel.Workbook();
-    let sheet;
-    if (!downloadPath) {
-      sheet = workbook.addWorksheet('sheet');
-    } else {
-      const file = await this.ctx.curl(`${this.domain}${downloadPath}`);
-      if (!(file && file.data)) {
-        throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定文件');
-      }
-      await workbook.xlsx.load(file.data);
-      sheet = workbook.getWorksheet('sheet');
-    }
-    const rowNumber = sheet.rowCount || 1;
-    const meta = this.getHeader();
-    sheet.columns = meta;
-    sheet.addRows(list);
-    for (let i = 0; i < list.length; i++) {
-      const e = list[i];
-      const { img_url, _id } = e;
-      try {
-        if (img_url) {
-          const is_base64 = img_url.includes('base64,');
-          let imgid;
-          if (is_base64) {
-            imgid = workbook.addImage({
-              base64: img_url,
-              extension: 'jpeg',
-            });
-          } else if (img_url.includes('/files')) {
-            const prefix = `${this.root_path}`;
-            const new_url = img_url.replace('/files', prefix);
-            const suffix = Path.extname(img_url).substring(1);
-            imgid = workbook.addImage({
-              filename: new_url,
-              extension: suffix,
-            });
-          } else {
-            // 什么都不是,那就下一个
-            continue;
-          }
-
-          sheet.addImage(imgid, {
-            tl: { col: 13.2, row: i + rowNumber + 0.2 },
-            br: { col: 14, row: i + rowNumber + 1 },
-          });
-        }
-      } catch (error) {
-        this.ctx.logger.error(`导出,id为:${_id}的图片处理出现错误!`);
-      }
-
-    }
-    const filepath = `${path}${filename}`;
-    if (list.length <= 0) return;
-    await workbook.xlsx.writeFile(filepath);
-    return `/files/excel/${filename}`;
-  }
-
-  /**
-   * 检查数据是否没填 必填项
-   * @param {Object} object 每行数据,已转换成model的字段名
-   */
-  tocheckData(object) {
-    let result = true;
-    const { number } = object;
-    let notice;
-    const arr = [
-      { column: 'create_number', zh: '申请号' },
-      { column: 'create_date', zh: '申请日' },
-      { column: 'success_number', zh: '公开(公告)号' },
-      { column: 'success_date', zh: '公开(公告)日' },
-      { column: 'name', zh: '标题' },
-    ];
-    const word = [];
-    for (const o of arr) {
-      const { column, zh } = o;
-      if (!_.get(object, column)) {
-        result = false;
-        word.push(`${zh}`);
-      }
-    }
-    if (!result) {
-      notice = `序号${number}缺少:${word.join(';')}`;
-    }
-    return { result, notice };
-  }
-
-  /**
-   * 转换图片为base64
-   * @param {Object} object excel获取的图片object
-   * @property extension  后缀,文件类型
-   * @property buffer 图片内容,不含头部信息的,
-   */
-  turnImageToBase64(object = {}) {
-    const { extension, buffer } = object;
-    if (extension && buffer) {
-      const suffix = object.extension;
-      const ib = object.buffer.toString('base64');
-      const base64 = `data:image/${suffix};base64,${ib}`;
-      return base64;
-    }
-  }
-
-  getHeader() {
-    const arr = [
-      { header: '申请号', key: 'create_number', width: 30, style: { alignment: { wrapText: true, vertical: 'middle', horizontal: 'center' } } },
-      { header: '申请日', key: 'create_date', width: 30, style: { alignment: { wrapText: true, vertical: 'middle', horizontal: 'center' } } },
-      { header: '公开(公告)号', key: 'success_number', width: 30, style: { alignment: { wrapText: true, vertical: 'middle', horizontal: 'center' } } },
-      { header: '公开(公告)日', key: 'success_date', width: 30, style: { alignment: { wrapText: true, vertical: 'middle', horizontal: 'center' } } },
-      { header: '发明人', key: 'inventor', width: 30, style: { alignment: { wrapText: true, vertical: 'middle', horizontal: 'center' } } },
-      { header: '代理机构', key: 'agent', width: 30, style: { alignment: { wrapText: true, vertical: 'middle', horizontal: 'center' } } },
-      { header: '代理人', key: 'agent_personal', width: 30, style: { alignment: { wrapText: true, vertical: 'middle', horizontal: 'center' } } },
-      { header: '摘要', key: 'abstract', width: 30, style: { alignment: { wrapText: true, vertical: 'middle', horizontal: 'center' } } },
-      { header: '发明人地址', key: 'address', width: 30, style: { alignment: { wrapText: true, vertical: 'middle', horizontal: 'center' } } },
-      { header: '标题', key: 'name', width: 30, style: { alignment: { wrapText: true, vertical: 'middle', horizontal: 'center' } } },
-      { header: '申请人', key: 'apply_personal', width: 30, style: { alignment: { wrapText: true, vertical: 'middle', horizontal: 'center' } } },
-      { header: '专利有效性', key: 'term', width: 30, style: { alignment: { wrapText: true, vertical: 'middle', horizontal: 'center' } } },
-      { header: '专利类型', key: 'type', width: 30, style: { alignment: { wrapText: true, vertical: 'middle', horizontal: 'center' } } },
-      { header: '首页附图', width: 30, style: { alignment: { wrapText: true, vertical: 'middle', horizontal: 'center' } } },
-    ];
-    return arr;
-  }
-}
-
-module.exports = PatentService;

+ 140 - 140
app/service/dock/train_live.js

@@ -1,140 +1,140 @@
-'use strict';
-const { CrudService } = require('naf-framework-mongoose/lib/service');
-const { BusinessError, ErrorCode } = require('naf-core').Error;
-const { ObjectId } = require('mongoose').Types;
-const assert = require('assert');
-const _ = require('lodash');
-const jwt = require('jsonwebtoken');
-// 培训问诊表
-class TrainliveService extends CrudService {
-  constructor(ctx) {
-    super(ctx, 'trainlive');
-    this.model = this.ctx.model.TrainLive;
-  }
-  /**
-   * 重写创建,room_id自动生成
-   * @param {Object} body 数据
-   */
-  async create(body) {
-    const last = await this.model.findOne().sort({ room_id: -1 });
-    let room_id = '3001',
-      password = '3001';
-    if (last) {
-      room_id = parseInt(_.get(last, 'room_id', '3000')) + 1;
-      password = room_id;
-    }
-    body.room_id = room_id;
-    body.password = password;
-    return await this.model.create(body);
-  }
-
-  /**
-   * 查询指定培训问诊的参会人员
-   * @param {Object} {id} 培训问诊id
-   */
-  async userData({ id }) {
-    const object = await this.model.findOne({ _id: ObjectId(id) }, 'user_data');
-    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定的培训问诊信息!');
-    return _.get(object, 'user_data');
-  }
-
-  /**
-   * 培训问诊管理登陆
-   * @param {Object} {room_id,password} 房间号,密码
-   */
-  async login({ room_id, password }) {
-    const object = await this.model.findOne({ room_id });
-    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定的培训问诊信息!');
-    if (object.password !== password) throw new BusinessError(ErrorCode.BAD_PASSWORD, '密码错误!');
-    const data = _.omit(JSON.parse(JSON.stringify(object)), [ 'meta', 'passwd', '__v' ]);
-    const { secret: jwts } = this.config.jwt;
-    const token = jwt.sign(data, jwts);
-    return token;
-  }
-
-  /**
-   * 为培训问诊添加参加用户
-   * @param {Object} {id} 培训问诊的数据id
-   * @param {Array} {users} 培训问诊的参加用户
-   */
-  async addUser({ id }, { users }) {
-    const object = await this.model.findOne({ _id: ObjectId(id) }, '+ user_data');
-    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定的培训问诊信息!');
-    object.user_data.push(...users);
-    await object.save();
-  }
-
-  /**
-   * 更改培训问诊下指定用户的数据
-   * @param {Object} {id} 培训问诊的数据id
-   * @param {Array} {users} 用户的数据
-   */
-  async updateUser({ id }, { users }) {
-    const object = await this.model.findOne({ _id: ObjectId(id) }, '+ user_data');
-    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定的培训问诊信息!');
-    for (const user of users) {
-      const { _id, ...info } = user;
-      if (_id) {
-        // 存在_id,修改
-        const oldData = object.user_data.id(ObjectId(_id));
-        if (!oldData) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到培训问诊下指定的参会人员信息!');
-        const keys = Object.keys(info);
-        for (const key of keys) {
-          oldData[key] = info[key];
-        }
-      }
-    }
-    await object.save();
-  }
-
-  /**
-   *移除培训问诊下指定用户
-   * @param {Object} {id} 培训问诊的数据id
-   * @param {Object} {users} 用户的数据id集合
-   */
-  async deleteUser({ id }, { users }) {
-    const object = await this.model.findOne({ _id: ObjectId(id) }, '+ user_data');
-    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定的培训问诊信息!');
-    object.user_data = object.user_data.filter(f => !users.find(uf => ObjectId(uf).equals(f._id)));
-    await object.save();
-  }
-  /**
-   * 参会人员登陆
-   * @param {Object} {id} 培训问诊的数据id
-   * @param {Object} user 参会人员的信息,手机号和密码
-   */
-  async userLogin({ id }, { user_phone, user_password }) {
-    assert(user_phone, '缺少登陆的参会人员 手机号');
-    assert(user_password, '缺少登陆的参会人员 密码');
-    const object = await this.model.findOne({ _id: ObjectId(id) }, '+ user_data');
-    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定的培训问诊信息!');
-    const user = object.user_data.find(f => f.user_phone === user_phone);
-    if (!user) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到培训问诊下该手机号的用户信息!');
-    const is_login = this.ctx.session[`trainlive/${user._id}`];
-    if (is_login) throw new BusinessError(ErrorCode.BUSINESS, '用户已登录');
-    if (user.user_password !== user_password) throw new BusinessError(ErrorCode.BAD_PASSWORD, '用户密码错误!');
-    this.ctx.session[`trainlive/${user._id}`] = user;
-    const { secret: jwts } = this.config.jwt;
-    const token = jwt.sign(JSON.parse(JSON.stringify(user)), jwts);
-    return token;
-  }
-
-  /**
-   * 延长用户登陆时效
-   * @param {Object} {id} 用户id
-   */
-  async userLonger({ id }) {
-    const is_login = this.ctx.session[`trainlive/${id}`];
-    if (!is_login) throw new BusinessError(ErrorCode.BUSINESS, '用户登陆已失效,请重新登陆');
-  }
-
-  /**
-   * 参会人员注销
-   * @param {String} {id} 参会人员id
-   */
-  async userLogout({ id }) {
-    this.ctx.session[`trainlive/${id}`] = null;
-  }
-}
-
-module.exports = TrainliveService;
+'use strict';
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const { ObjectId } = require('mongoose').Types;
+const assert = require('assert');
+const _ = require('lodash');
+const jwt = require('jsonwebtoken');
+// 培训问诊表
+class TrainliveService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'trainlive');
+    this.model = this.ctx.model.TrainLive;
+  }
+  /**
+   * 重写创建,room_id自动生成
+   * @param {Object} body 数据
+   */
+  async create(body) {
+    const last = await this.model.findOne().sort({ room_id: -1 });
+    let room_id = '3001',
+      password = '3001';
+    if (last) {
+      room_id = parseInt(_.get(last, 'room_id', '3000')) + 1;
+      password = room_id;
+    }
+    body.room_id = room_id;
+    body.password = password;
+    return await this.model.create(body);
+  }
+
+  /**
+   * 查询指定培训问诊的参会人员
+   * @param {Object} {id} 培训问诊id
+   */
+  async userData({ id }) {
+    const object = await this.model.findOne({ _id: ObjectId(id) }, 'user_data');
+    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定的培训问诊信息!');
+    return _.get(object, 'user_data');
+  }
+
+  /**
+   * 培训问诊管理登陆
+   * @param {Object} {room_id,password} 房间号,密码
+   */
+  async login({ room_id, password }) {
+    const object = await this.model.findOne({ room_id });
+    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定的培训问诊信息!');
+    if (object.password !== password) throw new BusinessError(ErrorCode.BAD_PASSWORD, '密码错误!');
+    const data = _.omit(JSON.parse(JSON.stringify(object)), [ 'meta', 'passwd', '__v' ]);
+    const { secret: jwts } = this.config.jwt;
+    const token = jwt.sign(data, jwts);
+    return token;
+  }
+
+  /**
+   * 为培训问诊添加参加用户
+   * @param {Object} {id} 培训问诊的数据id
+   * @param {Array} {users} 培训问诊的参加用户
+   */
+  async addUser({ id }, { users }) {
+    const object = await this.model.findOne({ _id: ObjectId(id) }, '+ user_data');
+    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定的培训问诊信息!');
+    object.user_data.push(...users);
+    await object.save();
+  }
+
+  /**
+   * 更改培训问诊下指定用户的数据
+   * @param {Object} {id} 培训问诊的数据id
+   * @param {Array} {users} 用户的数据
+   */
+  async updateUser({ id }, { users }) {
+    const object = await this.model.findOne({ _id: ObjectId(id) }, '+ user_data');
+    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定的培训问诊信息!');
+    for (const user of users) {
+      const { _id, ...info } = user;
+      if (_id) {
+        // 存在_id,修改
+        const oldData = object.user_data.id(ObjectId(_id));
+        if (!oldData) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到培训问诊下指定的参会人员信息!');
+        const keys = Object.keys(info);
+        for (const key of keys) {
+          oldData[key] = info[key];
+        }
+      }
+    }
+    await object.save();
+  }
+
+  /**
+   *移除培训问诊下指定用户
+   * @param {Object} {id} 培训问诊的数据id
+   * @param {Object} {users} 用户的数据id集合
+   */
+  async deleteUser({ id }, { users }) {
+    const object = await this.model.findOne({ _id: ObjectId(id) }, '+ user_data');
+    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定的培训问诊信息!');
+    object.user_data = object.user_data.filter(f => !users.find(uf => ObjectId(uf).equals(f._id)));
+    await object.save();
+  }
+  /**
+   * 参会人员登陆
+   * @param {Object} {id} 培训问诊的数据id
+   * @param {Object} user 参会人员的信息,手机号和密码
+   */
+  async userLogin({ id }, { user_phone, user_password }) {
+    assert(user_phone, '缺少登陆的参会人员 手机号');
+    assert(user_password, '缺少登陆的参会人员 密码');
+    const object = await this.model.findOne({ _id: ObjectId(id) }, '+ user_data');
+    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定的培训问诊信息!');
+    const user = object.user_data.find(f => f.user_phone === user_phone);
+    if (!user) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到培训问诊下该手机号的用户信息!');
+    const is_login = this.ctx.session[`trainlive/${user._id}`];
+    if (is_login) throw new BusinessError(ErrorCode.BUSINESS, '用户已登录');
+    if (user.user_password !== user_password) throw new BusinessError(ErrorCode.BAD_PASSWORD, '用户密码错误!');
+    this.ctx.session[`trainlive/${user._id}`] = user;
+    const { secret: jwts } = this.config.jwt;
+    const token = jwt.sign(JSON.parse(JSON.stringify(user)), jwts);
+    return token;
+  }
+
+  /**
+   * 延长用户登陆时效
+   * @param {Object} {id} 用户id
+   */
+  async userLonger({ id }) {
+    const is_login = this.ctx.session[`trainlive/${id}`];
+    if (!is_login) throw new BusinessError(ErrorCode.BUSINESS, '用户登陆已失效,请重新登陆');
+  }
+
+  /**
+   * 参会人员注销
+   * @param {String} {id} 参会人员id
+   */
+  async userLogout({ id }) {
+    this.ctx.session[`trainlive/${id}`] = null;
+  }
+}
+
+module.exports = TrainliveService;

+ 0 - 55
app/service/dock/transaction.js

@@ -1,55 +0,0 @@
-'use strict';
-const { CrudService } = require('naf-framework-mongoose/lib/service');
-const { BusinessError, ErrorCode } = require('naf-core').Error;
-const { ObjectId } = require('mongoose').Types;
-const _ = require('lodash');
-const assert = require('assert');
-
-// 交易表
-class TransactionService extends CrudService {
-  constructor(ctx) {
-    super(ctx, 'transaction');
-    this.model = this.ctx.model.Transaction;
-  }
-
-  async query({ skip = 0, limit = 0, ...query }) {
-    query = this.ctx.service.util.util.dealQuery(query);
-    const { user_id, supplier, demander, status, ...info } = query;
-    if (status)query.status = status.split(',');
-    let data;
-    let total;
-    if (!user_id) {
-      data = await this.model.find(query).skip(parseInt(skip)).limit(parseInt(limit))
-        .sort({ 'meta.createdAt': -1 });
-      total = await this.model.count(query);
-    } else {
-      const nquery = { ...info, $or: [{ supplier: user_id }, { demander: user_id }] };
-      if (query.status) nquery.status = query.status;
-      data = await this.model.find(nquery).skip(parseInt(skip)).limit(parseInt(limit))
-        .sort({ 'meta.createdAt': -1 });
-      total = await this.model.count(nquery);
-    }
-    return { data, total };
-  }
-
-  /**
-   *  审核交易
-   * @param {Object} { id } 交易数据的id
-   * @param {Object} { status, pact }
-   * @property {String} status 状态
-   * @property {Object} pact 交易备案
-   */
-  async step({ id }, { status, pact }) {
-    const query = { _id: ObjectId(id) };
-    const data = { status };
-    if (status === '2') {
-      assert(pact, '请填写合同备案');
-      data.pact = pact;
-    } else {
-      if (pact) data.pact = pact;
-    }
-    await this.model.updateOne(query, data);
-  }
-}
-
-module.exports = TransactionService;

+ 36 - 2
app/service/statistics/index.js

@@ -18,8 +18,8 @@ class IndexService extends CrudService {
     this.personalModel = this.ctx.model.Personal;
     this.organizationModel = this.ctx.model.Organization;
     this.surveyModel = this.ctx.model.Survey;
-    this.dockUser = this.ctx.model.DockUser;
-    this.tranModel = this.ctx.model.Transaction;
+    this.dockUser = this.ctx.model.DockUser; // 没改
+    this.tranModel = this.ctx.model.Transaction;// 没改
   }
   /**
    * 首页专利统计
@@ -344,6 +344,40 @@ class IndexService extends CrudService {
     }
     return obj;
   }
+
+  async dockProduct({ skip = 0, limit = 10, ...query } = {}) {
+    const productQuery = {};
+    const userQuery = {};
+    for (const key in query) {
+      if (query[key].length > 12) {
+        if (ObjectId.isValid(query[key])) query[key] = ObjectId(query[key]);
+      }
+      if (key.includes('.')) productQuery[key] = query[key];
+      else userQuery[key] = query[key];
+    }
+    const publics = [
+      { $match: userQuery },
+      { $project: { productList: 1, _id: 0 } },
+      { $unwind: '$productList' },
+      { $match: productQuery },
+    ];
+    const data = await this.ctx.model.Dock.DockUser.aggregate([
+      ...publics,
+      { $skip: parseInt(skip) },
+      { $limit: parseInt(limit) },
+    ]).replaceRoot('productList');
+    let total = await this.ctx.model.Dock.DockUser.aggregate([
+      ...publics,
+      { $group: {
+        _id: null,
+        count: { $sum: 1 },
+      } },
+    ]);
+    if (total && _.isArray(total)) {
+      total = _.get(_.head(total), 'count', 0);
+    }
+    return { data, total };
+  }
 }
 
 module.exports = IndexService;

+ 42 - 42
app/service/users/person_chat.js

@@ -1,42 +1,42 @@
-'use strict';
-const { CrudService } = require('naf-framework-mongoose/lib/service');
-const { BusinessError, ErrorCode } = require('naf-core').Error;
-const { ObjectId } = require('mongoose').Types;
-const _ = require('lodash');
-const assert = require('assert');
-
-// 个人聊天表
-class Person_chatService extends CrudService {
-  constructor(ctx) {
-    super(ctx, 'person_chat');
-    this.model = this.ctx.model.PersonChat;
-  }
-  async create(data) {
-    const res = await this.model.create(data);
-    if (res) {
-      const exchange = 'personChat';
-      const routeKey = `${res.room_id}.${res.receiver_id}`;
-      const content = JSON.stringify(_.pick(res, [ 'sender_id', 'sender_name', 'receiver_id', 'receiver_name', 'room_id', 'content', 'is_read', 'send_time' ]));
-      const param = { durable: true };
-      const { mq } = this.ctx;
-      if (mq) {
-        try {
-          await mq.topic(exchange, routeKey, content, param);
-        } catch (error) {
-          this.ctx.logger.error(error);
-        }
-      } else {
-        this.ctx.logger.error('!!!!!!没有配置MQ插件!!!!!!');
-      }
-    }
-    return res;
-  }
-
-  async allRead({ user_id, room_id }) {
-    assert(user_id && room_id, '缺少信息');
-    const res = await this.model.updateMany({ receiver_id: user_id, room_id }, { is_read: true });
-    return res;
-  }
-}
-
-module.exports = Person_chatService;
+'use strict';
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const { ObjectId } = require('mongoose').Types;
+const _ = require('lodash');
+const assert = require('assert');
+
+// 个人聊天表
+class Person_chatService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'person_chat');
+    this.model = this.ctx.model.PersonChat;
+  }
+  async create(data) {
+    const res = await this.model.create(data);
+    if (res) {
+      const exchange = 'personChat';
+      const routeKey = `${res.room_id}.${res.receiver_id}`;
+      const content = JSON.stringify(_.pick(res, [ 'sender_id', 'sender_name', 'receiver_id', 'receiver_name', 'room_id', 'content', 'is_read', 'send_time' ]));
+      const param = { durable: true };
+      const { mq } = this.ctx;
+      if (mq) {
+        try {
+          await mq.topic(exchange, routeKey, content, param);
+        } catch (error) {
+          this.ctx.logger.error(error);
+        }
+      } else {
+        this.ctx.logger.error('!!!!!!没有配置MQ插件!!!!!!');
+      }
+    }
+    return res;
+  }
+
+  async allRead({ user_id, room_id }) {
+    assert(user_id && room_id, '缺少信息');
+    const res = await this.model.updateMany({ receiver_id: user_id, room_id }, { is_read: true });
+    return res;
+  }
+}
+
+module.exports = Person_chatService;

+ 51 - 51
app/service/users/person_room.js

@@ -1,51 +1,51 @@
-'use strict';
-const { CrudService } = require('naf-framework-mongoose/lib/service');
-const { BusinessError, ErrorCode } = require('naf-core').Error;
-const { ObjectId } = require('mongoose').Types;
-const _ = require('lodash');
-const assert = require('assert');
-
-// 个人聊天房间表
-class Person_roomService extends CrudService {
-  constructor(ctx) {
-    super(ctx, 'person_room');
-    this.model = this.ctx.model.PersonRoom;
-    this.pc = this.ctx.model.PersonChat;
-  }
-  async query(query) {
-    query = this.ctx.service.util.util.turnDateRangeQuery(this.ctx.service.util.util.turnFilter(query));
-    const { p_id, skip = 0, limit = 0, ...info } = query;
-    const condition = { ...info }; // last_time: { $exists: true },
-    if (p_id) {
-      condition.$or = [{ p1_id: p_id }, { p2_id: p_id }];
-    }
-    let data = await this.model.find(condition).skip(parseInt(skip)).limit(parseInt(limit));
-    const aggQuery = [
-      { $match: { room_id: { $in: data.map(i => ObjectId(i._id)) }, is_read: false, receiver_id: ObjectId(p_id) } },
-      {
-        $group: {
-          _id: '$room_id',
-          sum: { $sum: 1 },
-        },
-      },
-    ];
-    const notReads = await this.pc.aggregate(aggQuery);
-    if (data.length > 0) data = JSON.parse(JSON.stringify(data));
-    data = data.map(i => {
-      const nr = notReads.find(f => ObjectId(f._id).equals(i._id));
-      if (nr) i.not_read = nr.sum;
-      return i;
-    });
-    const total = await this.model.count(condition);
-    return { data, total };
-  }
-  async create(payload) {
-    const { p1_id, p2_id } = payload;
-    const obj = await this.model.findOne({ $or: [{ p1_id, p2_id }, { p1_id: p2_id, p2_id: p1_id }] });
-    if (obj) return obj;
-    const res = await this.model.create(payload);
-    return res;
-  }
-}
-
-module.exports = Person_roomService;
+'use strict';
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const { ObjectId } = require('mongoose').Types;
+const _ = require('lodash');
+const assert = require('assert');
+
+// 个人聊天房间表
+class Person_roomService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'person_room');
+    this.model = this.ctx.model.PersonRoom;
+    this.pc = this.ctx.model.PersonChat;
+  }
+  async query(query) {
+    query = this.ctx.service.util.util.turnDateRangeQuery(this.ctx.service.util.util.turnFilter(query));
+    const { p_id, skip = 0, limit = 0, ...info } = query;
+    const condition = { ...info }; // last_time: { $exists: true },
+    if (p_id) {
+      condition.$or = [{ p1_id: p_id }, { p2_id: p_id }];
+    }
+    let data = await this.model.find(condition).skip(parseInt(skip)).limit(parseInt(limit));
+    const aggQuery = [
+      { $match: { room_id: { $in: data.map(i => ObjectId(i._id)) }, is_read: false, receiver_id: ObjectId(p_id) } },
+      {
+        $group: {
+          _id: '$room_id',
+          sum: { $sum: 1 },
+        },
+      },
+    ];
+    const notReads = await this.pc.aggregate(aggQuery);
+    if (data.length > 0) data = JSON.parse(JSON.stringify(data));
+    data = data.map(i => {
+      const nr = notReads.find(f => ObjectId(f._id).equals(i._id));
+      if (nr) i.not_read = nr.sum;
+      return i;
+    });
+    const total = await this.model.count(condition);
+    return { data, total };
+  }
+  async create(payload) {
+    const { p1_id, p2_id, product_id } = payload;
+    const obj = await this.model.findOne({ $or: [{ p1_id, p2_id }, { p1_id: p2_id, p2_id: p1_id }], product_id });
+    if (obj) return obj;
+    const res = await this.model.create(payload);
+    return res;
+  }
+}
+
+module.exports = Person_roomService;