cheny 4 anni fa
parent
commit
deb81dc39d

+ 31 - 0
.github/workflows/nodejs.yml

@@ -0,0 +1,31 @@
+# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
+# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
+
+name: Node.js CI
+
+on:
+  push:
+    branches: [ master ]
+  pull_request:
+    branches: [ master ]
+
+jobs:
+  build:
+
+    runs-on: ${{ matrix.os }}
+
+    strategy:
+      matrix:
+        node-version: [10.x]
+        os: [ubuntu-latest, windows-latest, macos-latest]
+
+    steps:
+    - uses: actions/checkout@v2
+    - name: Use Node.js ${{ matrix.node-version }}
+      uses: actions/setup-node@v1
+      with:
+        node-version: ${{ matrix.node-version }}
+    - run: npm i -g npminstall && npminstall
+    - run: npm run ci
+      env:
+        CI: true

+ 44 - 16
app/controller/.dock.js

@@ -1,6 +1,8 @@
 module.exports = {
   create: {
     requestBody: [
+      "room_id",
+      "password",
       "title",
       "desc",
       "start_time",
@@ -10,9 +12,7 @@ module.exports = {
       "province",
       "file_path",
       "place",
-      "is_allowed",
-      "roomname",
-      "u_id",
+      "user_id",
       "adminuser",
       "phone",
       "passwd",
@@ -28,15 +28,13 @@ module.exports = {
     requestBody: [
       "title",
       "desc",
+      "status",
       "start_time",
       "end_time",
       "join_end",
-      "status",
       "province",
-      "file_path",
       "place",
-      "roomname",
-      "uid",
+      "file_path",
       "adminuser",
       "phone",
       "passwd",
@@ -52,18 +50,16 @@ module.exports = {
   index: {
     parameters: {
       query: [
+        "room_id",
         "title",
         "desc",
         "start_time",
         "end_time",
         "join_end",
         "user_id",
-        "is_allowed",
         "status",
         "province",
         "place",
-        "roomname",
-        "uid",
         "adminuser",
         "phone",
       ],
@@ -82,7 +78,6 @@ module.exports = {
       "user_id",
       "user_name",
       "buyer",
-      "goodsList",
       "contact",
       "contact_tel",
       "email",
@@ -91,14 +86,47 @@ module.exports = {
     ],
     service: "apply",
   },
+  goods: {
+    params: ["!id"],
+    requestBody: [
+      "totaltype",
+      "name",
+      "product_type_id",
+      "introduction",
+      "phase",
+      "price",
+      "priceunit",
+      "image",
+      "field",
+      "scope",
+      "coopermode",
+      "business",
+      "budget",
+      "end_date",
+      "difficult_problem",
+      "demand",
+      "company",
+      "address",
+      "mature",
+      "team",
+      "property",
+      "mature",
+      "coopercompany",
+      "other",
+      "contact_user",
+      "contact_tel",
+    ],
+    service: "goods",
+  },
+
   check: {
     params: ["!id", "!dock_id"],
     requestBody: ["status"],
     service: "check",
   },
-  dockCheck: {
-    params: ["!id"],
-    requestBody: ["is_allowed", "reason"],
-    service: "dockCheck",
-  },
+  // dockCheck: {
+  //   params: ["!id"],
+  //   requestBody: ["is_allowed", "reason"],
+  //   service: "dockCheck",
+  // },
 };

+ 43 - 10
app/model/dock.js

@@ -2,11 +2,41 @@
 const Schema = require('mongoose').Schema;
 const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
 
+// 产品
+const goods = new Schema({
+  totaltype: { type: String, required: true, maxLength: 5 }, // 产品类型
+  name: { type: String, required: true, maxLength: 200 }, // 产品名称
+  product_type_id: { type: Object, required: true, maxLength: 200 }, // 类型
+  introduction: { type: String, required: true, maxLength: 1000 }, // 产品简介
+  phase: { type: String, required: true, maxLength: 200 }, // 研发阶段
+  price: { type: String, required: true, maxLength: 200 }, // 产品单价
+  priceunit: { type: String, required: true, maxLength: 200 }, // 产品单位
+  image: { type: String, required: true, maxLength: 200 }, // 产品图片
+  field: { type: String, maxLength: 200 }, // 所属领域
+  scope: { type: String, maxLength: 200 }, // 服务范围
+  coopermode: { type: String, maxLength: 200 }, // 合作方式
+  business: { type: String, maxLength: 200 }, // 交易方式
+  budget: { type: String, default: 0, maxLength: 200 }, // 投入预算
+  end_date: { type: String, default: 0, maxLength: 200 }, // 需求截止日期
+  difficult_problem: { type: String, default: 0, maxLength: 500 }, // 难题或瓶颈问题
+  demand: { type: String, default: 0, maxLength: 500 }, // 企业解决技术需求已具备的条件
+  company: { type: String, default: 0, maxLength: 200 }, // 企业名称
+  address: { type: String, default: 0, maxLength: 200 }, // 企业地址
+  team: { type: String, default: 0, maxLength: 200 }, // 技术团队情况
+  property: { type: String, default: 0, maxLength: 200 }, // 知识产权情况
+  mature: { type: String, default: 0, maxLength: 200 }, // 技术成熟度
+  coopercompany: { type: String, default: 0, maxLength: 200 }, // 是否拟有合同
+  other: { type: String, default: 0, maxLength: 200 }, // 其他需求
+  contact_user: { type: String, default: 0, maxLength: 200 }, // 联系人
+  contact_tel: { type: String, default: 0, maxLength: 200 }, // 联系电话
+});
+goods.index({ id: 1 });
+// 申请用户
 const apply = new Schema({
   user_id: { type: String, required: true, maxLength: 200 }, // 用户id
   user_name: { type: String, required: true, maxLength: 200 }, // 用户名称
   buyer: { type: String, required: true, maxLength: 1 }, // 买家/卖家 0/1
-  goodsList: [ Object ],
+  goodsList: { type: [ goods ], default: [] }, // 产品列表
   contact: { type: String, required: true, maxLength: 200 }, // 联系人
   contact_tel: { type: String, required: true, maxLength: 200 }, // 联系人电话
   email: { type: String, maxLength: 200 }, // 邮箱
@@ -17,6 +47,7 @@ const apply = new Schema({
 });
 apply.index({ id: 1 });
 apply.index({ userid: 1 });
+// vip用户
 const vipuser = new Schema({
   uid: { type: String, required: false, maxLength: 200 }, // 用户id
   vipname: { type: String, required: false, maxLength: 200 }, // 用户名称
@@ -28,24 +59,26 @@ const vipuser = new Schema({
 });
 vipuser.index({ id: 1 });
 const Dock = {
+  room_id: { type: String, required: true, maxLength: 10 }, // 房间号
+  password: { type: String, required: false, maxLength: 200 }, // 密码
   title: { type: String, required: true, maxLength: 200 }, // 对接会标题
   desc: { type: String, maxLength: 1000 }, // 简介
   status: { type: String, default: '0', maxLength: 1 }, // 状态:0准备中;1已开始;2已结束
   start_time: { type: String, required: true, maxLength: 200 }, // 开始时间
   end_time: { type: String, required: true, maxLength: 200 }, // 结束时间
   join_end: { type: String, required: true, maxLength: 200 }, // 报名截止时间
-  apply: { type: [ apply ], default: [] },
-  is_allowed: { type: String, default: '0', maxLength: 1 }, // 0未审核;1已允许;2已拒绝
-  reason: { type: String, required: false, maxLength: 200 }, // 拒绝理由
-  user_id: { type: String, required: true, maxLength: 200 }, // 申请用户
+  apply: { type: [ apply ], default: [] }, // 申请用户
+  user_id: { type: String, required: true, maxLength: 200 }, // 创建人id
   province: { type: String, required: false }, // 省
+  place: { type: String, required: false }, // 市
   file_path: { type: String, required: false }, // 视频路径
-  place: { type: String, required: false }, // 位置
-  roomname: { type: String, required: false }, // 房间号
-  uid: { type: String, required: false, maxLength: 200 }, // 所属用户
-  adminuser: { type: String, required: false, maxLength: 200 }, // 所属用户姓名
-  phone: { type: String, required: false, maxLength: 200 }, // 所属电话
+  adminuser: { type: String, required: false, maxLength: 200 }, // 用户姓名
+  phone: { type: String, required: false, maxLength: 200 }, // 电话
   vipuser: { type: [ vipuser ], default: [] }, // vip用户
+  // is_allowed: { type: String, default: '0', maxLength: 1 }, // 0未审核;1已允许;2已拒绝
+  // reason: { type: String, required: false, maxLength: 200 }, // 拒绝理由
+  // roomname: { type: String, required: false }, // 房间名称
+  // uid: { type: String, required: false, maxLength: 200 }, // 所属用户
 };
 const schema = new Schema(Dock, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });

+ 3 - 1
app/router.js

@@ -39,9 +39,11 @@ module.exports = app => {
   router.get('/api/live/dock/myapply', controller.dock.myapply); // 查询申请的对接列表
   router.resources('dock', '/api/live/dock', controller.dock); // index、create、show、destroy
   router.post('dock', '/api/live/dock/:id', controller.dock.update);
-  router.post('dock', '/api/live/dock/check/:id', controller.dock.dockCheck);
+  // router.post('dock', '/api/live/dock/check/:id', controller.dock.dockCheck);
   // 对接会申请表
   router.post('dock', '/api/live/dock/apply/:id', controller.dock.apply);
+  // 申请用户产品列表
+  router.post('dock', '/api/live/dock/goods/:id', controller.dock.goods);
   router.post(
     'dock',
     '/api/live/dock/apply/:dock_id/check/:id',

+ 28 - 16
app/service/dock.js

@@ -4,7 +4,7 @@ const assert = require('assert');
 const _ = require('lodash');
 const { ObjectId } = require('mongoose').Types;
 const { CrudService } = require('naf-framework-mongoose/lib/service');
-const { BusinessError, ErrorCode } = require('naf-core').Error;
+const { BusinessError } = require('naf-core').Error;
 const moment = require('moment');
 class ChatService extends CrudService {
   constructor(ctx) {
@@ -19,8 +19,7 @@ class ChatService extends CrudService {
         name: body.adminuser,
         phone: body.phone,
         passwd: body.passwd,
-        uid: res.id,
-        role: '4',
+        role: '3',
         pid: body.pid,
         code: body.code,
       };
@@ -34,7 +33,6 @@ class ChatService extends CrudService {
       });
       if (user.data.errcode === 0) {
         const result = await this.model.findById(res.id);
-        result.uid = user.data.data.id;
         result.adminuser = body.adminuser;
         result.phone = body.phone;
         result.save();
@@ -42,6 +40,21 @@ class ChatService extends CrudService {
     }
     return { ...JSON.parse(JSON.stringify(res)), adminuser: body.adminuser, phone: body.phone };
   }
+  // 产品
+  async goods({ id }, body) {
+    const apply = await this.model.findOne({ _id: ObjectId(id) });
+    if (!apply) {
+      throw new BusinessError('没有查询到该申请用户');
+    }
+    apply.goods.push({
+      ...body,
+      // apply_time: moment().format('YYYY-MM-DD HH:mm:ss'),
+    });
+    const res = await apply.save();
+    const info = _.last(res.goods);
+    return info;
+  }
+
   async apply({ id }, body) {
     const dock = await this.model.findOne({ _id: ObjectId(id) });
     if (!dock) {
@@ -70,17 +83,17 @@ class ChatService extends CrudService {
     const res = dock.save();
     return res;
   }
-  async dockCheck({ id }, { is_allowed, reason = '' }) {
-    const dock = await this.model.findOne({ _id: ObjectId(id) });
-    if (!dock) {
-      throw new BusinessError('没有查询到该对接会');
-    }
-    assert(is_allowed, '请选择审核结果');
-    dock.is_allowed = is_allowed;
-    dock.reason = reason;
-    const res = await dock.save();
-    return res;
-  }
+  // async dockCheck({ id }, { is_allowed, reason = '' }) {
+  //   const dock = await this.model.findOne({ _id: ObjectId(id) });
+  //   if (!dock) {
+  //     throw new BusinessError('没有查询到该对接会');
+  //   }
+  //   assert(is_allowed, '请选择审核结果');
+  //   dock.is_allowed = is_allowed;
+  //   dock.reason = reason;
+  //   const res = await dock.save();
+  //   return res;
+  // }
 
   // 根据申请人id查询所有申请的对接会
   async myapply({ user_id, status, skip, limit }) {
@@ -126,7 +139,6 @@ class ChatService extends CrudService {
       throw new BusinessError('没有查询到该对接会');
     }
     const vipuser = {};
-    vipuser.uid = info.uid;
     vipuser.vipname = info.vipname;
     vipuser.vipphone = info.vipphone;
     vipuser.role = info.role;

+ 2 - 2
config/config.default.js

@@ -40,8 +40,8 @@ module.exports = appInfo => {
   config.mongoose = {
     url: 'mongodb://localhost:27017/platform',
     options: {
-      user: 'admin',
-      pass: 'admin',
+      user: 'platform',
+      pass: 'platform2020',
       authSource: 'admin',
       useNewUrlParser: true,
       useCreateIndex: true,

+ 2 - 2
config/config.local.js

@@ -11,8 +11,8 @@ module.exports = () => {
   config.mongoose = {
     url: 'mongodb://localhost:27017/platform',
     options: {
-      user: 'demo',
-      pass: 'demo',
+      user: 'platform',
+      pass: 'platform2020',
       authSource: 'admin',
       useNewUrlParser: true,
       useCreateIndex: true,

+ 2 - 2
config/config.prod.js

@@ -11,8 +11,8 @@ module.exports = () => {
   config.mongoose = {
     url: 'mongodb://localhost:27017/platform',
     options: {
-      user: 'admin',
-      pass: 'admin',
+      user: 'platform',
+      pass: 'platform2020',
       authSource: 'admin',
       useNewUrlParser: true,
       useCreateIndex: true,