Browse Source

Merge branch 'master' of http://git.cc-lotus.info/service-platform/service-live

liuyu 4 năm trước cách đây
mục cha
commit
b28e768a7a

+ 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

+ 56 - 19
app/controller/.dock.js

@@ -1,22 +1,27 @@
 module.exports = {
   create: {
     requestBody: [
+      "room_id",
+      "password",
+      "room_phone",
       "title",
       "desc",
       "start_time",
       "end_time",
       "join_end",
       "user_id",
+      "apply",
       "province",
       "file_path",
       "place",
-      "is_allowed",
-      "roomname",
-      "u_id",
+      "user_id",
       "adminuser",
       "phone",
       "passwd",
       "vipuser",
+      "email",
+      "company",
+      "openid"
     ],
   },
   destroy: {
@@ -26,21 +31,24 @@ module.exports = {
   update: {
     params: ["!id"],
     requestBody: [
+      "room_phone",
       "title",
       "desc",
+      "status",
+      "apply",
       "start_time",
       "end_time",
       "join_end",
-      "status",
       "province",
-      "file_path",
       "place",
-      "roomname",
-      "uid",
+      "file_path",
       "adminuser",
       "phone",
       "passwd",
       "vipuser",
+      "email",
+      "company",
+      "openid",
     ],
   },
   show: {
@@ -52,18 +60,17 @@ module.exports = {
   index: {
     parameters: {
       query: [
+        "room_phone",
+        "room_id",
         "title",
         "desc",
         "start_time",
         "end_time",
         "join_end",
         "user_id",
-        "is_allowed",
         "status",
         "province",
         "place",
-        "roomname",
-        "uid",
         "adminuser",
         "phone",
       ],
@@ -81,24 +88,54 @@ module.exports = {
     requestBody: [
       "user_id",
       "user_name",
-      "buyer",
       "goodsList",
-      "contact",
       "contact_tel",
-      "email",
       "role",
-      "company",
     ],
     service: "apply",
   },
+  goods: {
+    params: ["!id"],
+    requestBody: [
+      "_id",
+      "totaltype",
+      "name",
+      "product_type_id",
+      "introduction",
+      "phase",
+      "price",
+      "priceunit",
+      "image",
+      "field",
+      "scope",
+      "coopermode",
+      "business",
+      "budget",
+      "end_date",
+      "difficult_problem",
+      "demand",
+      "address",
+      "mature",
+      "team",
+      "property",
+      "mature",
+      "coopercompany",
+      "other",
+      "contact_tel",
+      "contact_user",
+      "dockStatus",
+    ],
+    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",
+  // },
 };

+ 4 - 0
app/controller/dock.js

@@ -33,6 +33,10 @@ class DockController extends Controller {
     const res = await this.service.dockfetch(this.ctx.params);
     this.ctx.ok({ ...res });
   }
+  async getdock() {
+    const res = await this.service.getdock(this.ctx.params);
+    this.ctx.ok({ res });
+  }
 }
 
 module.exports = CrudController(DockController, meta);

+ 34 - 0
app/controller/login.js

@@ -0,0 +1,34 @@
+'use strict';
+
+const Controller = require('egg').Controller;
+
+// 登录管理
+class LoginController extends Controller {
+
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.login;
+  }
+
+  async login() {
+    const res = await this.service.login(this.ctx.request.body);
+    this.ctx.ok({ data: res });
+  }
+
+  async token() {
+    const res = await this.service.token(this.ctx.request.body);
+    this.ctx.ok({ data: res });
+  }
+
+  async destroy() {
+    const res = await this.service.destroy(this.ctx.request.body);
+    this.ctx.ok({ data: res });
+  }
+
+  async wxlogin() {
+    const res = await this.service.wxlogin(this.ctx.request.body);
+    this.ctx.ok({ data: res });
+  }
+}
+
+module.exports = LoginController;

+ 55 - 20
app/model/dock.js

@@ -1,51 +1,86 @@
 'use strict';
 const Schema = require('mongoose').Schema;
 const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
-
+const { Secret } = require('naf-framework-mongoose/lib/model/schema');
+// const image = new Schema({
+// });
+// image.index({ id: 1 });
+// 产品
+const goods = new Schema({
+  totaltype: { type: String, required: false, maxLength: 5 }, // 产品类型
+  name: { type: String, required: false, maxLength: 200 }, // 产品名称
+  product_type_id: { type: Object, required: false, maxLength: 200 }, // 类型
+  introduction: { type: String, required: false, maxLength: 1000 }, // 产品简介
+  phase: { type: String, required: false, maxLength: 200 }, // 研发阶段
+  price: { type: String, required: false, maxLength: 200 }, // 产品单价
+  priceunit: { type: String, required: false, maxLength: 200 }, // 产品单位
+  image: { type: [ Object ], required: false }, // 产品图片
+  field: { type: String, maxLength: 200 }, // 所属领域
+  scope: { type: String, maxLength: 200 }, // 服务范围
+  coopermode: { type: String, maxLength: 200 }, // 合作方式
+  business: { type: String, maxLength: 200 }, // 交易方式
+  budget: { type: String, maxLength: 200 }, // 投入预算
+  end_date: { type: String, maxLength: 200 }, // 需求截止日期
+  difficult_problem: { type: String, maxLength: 500 }, // 难题或瓶颈问题
+  demand: { type: String, maxLength: 500 }, // 企业解决技术需求已具备的条件
+  company: { type: String, maxLength: 200 }, // 企业名称
+  address: { type: String, maxLength: 200 }, // 企业地址
+  team: { type: String, maxLength: 200 }, // 技术团队情况
+  property: { type: String, maxLength: 200 }, // 知识产权情况
+  mature: { type: String, maxLength: 200 }, // 技术成熟度
+  coopercompany: { type: String, maxLength: 200 }, // 是否拟有合同
+  other: { type: String, maxLength: 200 }, // 其他需求
+  contact_user: { type: String, maxLength: 200 }, // 联系人
+  contact_tel: { type: String, maxLength: 200 }, // 联系电话
+  dockStatus: { type: String, default: '0', maxLength: 5 }, // 0未审核,1已通过,2已拒绝
+});
+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 ],
-  contact: { type: String, required: true, maxLength: 200 }, // 联系人
-  contact_tel: { type: String, required: true, maxLength: 200 }, // 联系人电话
-  email: { type: String, maxLength: 200 }, // 邮箱
-  company: { type: String, maxLength: 200 }, // 单位名称
+  goodsList: { type: [ goods ], 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已拒绝)
+  status: { type: String, default: '0', maxLength: 1 }, // 申请状态 (0未审核;1已通过;2已拒绝)
 });
 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 }, // 用户名称
   vipphone: { type: String, required: false, maxLength: 200 }, // 联系人手机
   role: { type: String, required: false, maxLength: 200 }, // 申请人类型
   company: { type: String, required: false, maxLength: 500 }, // 单位名称
-  email: { type: String, required: false, maxLength: 20 }, // 单位名称
-  content: { type: String, required: false }, // 单位名称
+  email: { type: String, required: false, maxLength: 20 }, // 郵箱
+  content: { type: String, required: false }, // 内容
 });
 vipuser.index({ id: 1 });
 const Dock = {
-  title: { type: String, required: true, maxLength: 200 }, // 对接会标题
+  room_id: { type: String, required: true, maxLength: 10 }, // 房间号
+  password: { type: Secret, select: false }, // 密码
+  title: { type: String, required: false, 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: false, 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用户
+  role: { type: String, default: '3', maxLength: 20 }, // 展会角色
+  // 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 }, // 所属用户
+  openid: { type: String, maxLength: 200 }, // openid
 };
 const schema = new Schema(Dock, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });

+ 11 - 1
app/router.js

@@ -40,9 +40,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',
@@ -50,6 +52,14 @@ module.exports = app => {
   );
   router.post('/api/live/dock/updatevipuser/:id', controller.dock.updatevipuser);
   router.post('/api/live/dock/createvipuser/:id', controller.dock.createvipuser);
+  router.post('/api/live/dock/getdock/:id', controller.dock.getdock);
+
+  // 用户登录
+  router.post('/api/live/login', controller.login.login);
+  // 根据token取得用户信息
+  router.post('/api/live/token', controller.login.token);
+  // 用户退出登录
+  router.post('/api/live/logout', controller.login.destroy);
 
   // 栏目表设置路由
   router.resources('column', '/api/live/column', controller.column); // index、create、show、destroy

+ 92 - 47
app/service/dock.js

@@ -4,53 +4,99 @@ 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');
+const jwt = require('jsonwebtoken');
+
 class ChatService extends CrudService {
   constructor(ctx) {
     super(ctx, 'dock');
     this.model = this.ctx.model.Dock;
   }
+  // 创建登录Token
+  async createJwtPwd(password) {
+    const { secret } = this.config.jwt;
+    const token = await jwt.sign(password, secret);
+    return token;
+  }
   async create(body) {
+    // roomid与密码每次加一
+    const findroom = await this.model.find().sort({ room_id: -1 });
+    if (findroom.length > 0) {
+      const room = (parseInt(findroom[0].room_id) + 1) + '';
+      // 将用户输入的密码进行加密并与查询到的用户数据密码相比对
+      const pas = await this.createJwtPwd(room);
+      body.room_id = room;
+      body.password = { secret: pas };
+    } else {
+      // 将用户输入的密码进行加密并与查询到的用户数据密码相比对
+      const room = '1001';
+      const pas = await this.createJwtPwd(room);
+      body.room_id = room;
+      body.password = { secret: pas };
+    }
     const res = await this.model.create(body);
-    if (res) {
-      const url = this.ctx.app.config.axios.auth.baseUrl;
-      const newdata = {
-        name: body.adminuser,
-        phone: body.phone,
-        passwd: body.passwd,
-        uid: res.id,
-        role: '4',
-        pid: body.pid,
-        code: body.code,
-      };
-      const user = await this.ctx.curl(url, {
-        method: 'post',
-        headers: {
-          'content-type': 'application/json',
-        },
-        dataType: 'json',
-        data: JSON.stringify(newdata),
+    return { ...JSON.parse(JSON.stringify(res)), password: res.password.secret, room_id: res.room_id };
+  }
+  // 产品
+  async goods({ id }, body) {
+    // console.log(body);
+    const dock = await this.model.findOne({ _id: ObjectId(id) });
+    if (!dock) {
+      throw new BusinessError('没有查询到该对接会');
+    }
+    if (body._id) {
+      const goods = dock.apply.map(i => i.goodsList).flat().find(function(item) {
+        return item.id === body._id;
       });
-      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();
+      if (body.dockStatus) {
+        goods.dockStatus = body.dockStatus;
       }
+    } else {
+      dock.apply.goodsList.push({
+        ...body,
+      });
     }
-    return { ...JSON.parse(JSON.stringify(res)), adminuser: body.adminuser, phone: body.phone };
+
+    const res = await dock.save();
+    const info = _.last(res.apply.goodsList);
+    return info;
   }
+
   async apply({ id }, body) {
     const dock = await this.model.findOne({ _id: ObjectId(id) });
     if (!dock) {
       throw new BusinessError('没有查询到该对接会');
     }
-    dock.apply.push({
-      ...body,
-      apply_time: moment().format('YYYY-MM-DD HH:mm:ss'),
-    });
+    if (body._id) {
+      // 修改
+      const apply = dock.apply.find(item => item._id === body._id);
+      if (body.user_name) {
+        apply.user_name = body.user_name;
+      }
+      if (body.goodsList) {
+        apply.goodsList = body.goodsList;
+      }
+      if (body.contact_tel) {
+        apply.contact_tel = body.contact_tel;
+      }
+      if (body.apply_time) {
+        apply.apply_time = body.apply_time;
+      }
+      if (body.role) {
+        apply.role = body.role;
+      }
+      if (body.status) {
+        apply.status = body.status;
+      }
+    } else {
+      // 保存
+      dock.apply.push({
+        ...body,
+        apply_time: moment().format('YYYY-MM-DD HH:mm:ss'),
+      });
+    }
+
     const res = await dock.save();
     const info = _.last(res.apply);
     return info;
@@ -70,17 +116,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 }) {
@@ -108,12 +154,6 @@ class ChatService extends CrudService {
     if (info.role) {
       vipuser.role = info.role;
     }
-    if (info.company) {
-      vipuser.company = info.company;
-    }
-    if (info.email) {
-      vipuser.email = info.email;
-    }
     if (info.content) {
       vipuser.content = info.content;
     }
@@ -158,6 +198,11 @@ class ChatService extends CrudService {
     }
     return data;
   }
+
+  async getdock({ id }) {
+    const res = await this.model.find({ vipuser: { $elemMatch: { uid: id } } });
+    return res;
+  }
 }
 
 module.exports = ChatService;

+ 138 - 0
app/service/login.js

@@ -0,0 +1,138 @@
+'use strict';
+
+const assert = require('assert');
+const { ObjectId } = require('mongoose').Types;
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const jwt = require('jsonwebtoken');
+const uuid = require('uuid');
+
+class LoginService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'login');
+    this.model = this.ctx.model.Dock;
+  }
+
+  // 用户登录
+  async login(data) {
+    const { room_phone, passwd, role } = data;
+    const phone = room_phone;
+    const room_id = room_phone;
+    // 根据用户输入的手机号查询其他用户表中是否存在相应数据
+    let user = await this.model.findOne({ phone, role });
+    const flag = true;
+    if (!user) {
+      user = await this.model.findOne({ room_id, role });
+    }
+    // 如果用户不存在抛出异常
+    if (!user) {
+      throw new BusinessError(ErrorCode.USER_NOT_EXIST);
+    }
+    let _user = '';
+    // 将用户输入的密码进行加密并与查询到的用户数据密码相比对
+    const pasw = await this.createJwtPwd(passwd);
+    if (flag) {
+      // 手机
+      _user = await this.model.findOne({ phone, pasw });
+    } else {
+      // 房间号
+      _user = await this.model.findOne({ room_id, pasw });
+    }
+    if (_user === '') {
+      throw new BusinessError(ErrorCode.USER_NOT_EXIST);
+      // throw new BusinessError(ErrorCode.BAD_PASSWORD);
+    }
+    // 将用户输入的密码进行加密并与查询到的用户数据密码相比对
+    // const pas = await this.createJwtPwd(passwd);
+    // // 如果两个密码不一致抛出异常
+    // if (pas !== _user.passwd.secret) {
+    //   throw new BusinessError(ErrorCode.BAD_PASSWORD);
+    // }
+
+    // if (role === '3') {
+    //   console.log('vip用户');
+    // } else if (role === '8') {
+    //   console.log('展会vip用户');
+    // } else {
+    //   console.log('无此展会');
+    // }
+
+
+    // if (_user.role === '3' || _user.role === '8') {
+    //   const url = 'http://127.0.0.1:9004/api/market/user/' + _user.uid;
+    //   const marketuser = await this.ctx.curl(url, {
+    //     method: 'get',
+    //     headers: {
+    //       'content-type': 'application/json',
+    //     },
+    //     dataType: 'json',
+    //   });
+    //   if (marketuser.data.data.status !== '1') {
+    //     throw new BusinessError(ErrorCode.ACCESS_DENIED);
+    //   }
+    // } else if (_user.role === '6') {
+    //   const url = 'http://127.0.0.1:9004/api/market/expertsuser/' + _user.uid;
+    //   const expertsuser = await this.ctx.curl(url, {
+    //     method: 'get',
+    //     headers: {
+    //       'content-type': 'application/json',
+    //     },
+    //     dataType: 'json',
+    //   });
+    //   if (expertsuser.data.data.status !== '1') {
+    //     throw new BusinessError(ErrorCode.ACCESS_DENIED);
+    //   }
+    // }
+    // 取出用户的类型,根据用户类型返回相应信息
+    const state = uuid();
+    const key = `free:auth:state:${state}`;
+    // const _menus = [];
+    // for (const elm of user.menus) {
+    //   const _menu = await this.rmodel.findById({ _id: ObjectId(elm) });
+    //   if (_menu) {
+    //     _menus.push({ id: elm, role_name: _menu.role_name, url: _menu.url });
+    //   }
+    // }
+    // user.menus = JSON.stringify(_menus);
+    console.log(user);
+    const token = await this.createJwt(user);
+    await this.app.redis.set(key, token, 'EX', 60 * 60 * 24);
+    return { key };
+  }
+
+  // 创建登录Token
+  async createJwtPwd(password) {
+    const { secret } = this.config.jwt;
+    const token = await jwt.sign(password, secret);
+    return token;
+  }
+
+  // 创建登录Token
+  async createJwt({ id, adminuser, uid, phone, role, remark, deptid, pid, code }) {
+    const { secret, expiresIn = '1d', issuer = role } = this.config.jwt;
+    const subject = phone;
+    const res = { uid: id, userid: uid, adminuser, phone, role, remark, deptid, pid, code };
+    const token = await jwt.sign(res, secret, { expiresIn, issuer, subject });
+    return token;
+  }
+
+  // 取得redis内token信息
+  async token({ key }) {
+    assert(key, 'key不能为空');
+    const token = await this.app.redis.get(key);
+    if (!token) {
+      throw new BusinessError(ErrorCode.SERVICE_FAULT, 'token已经过期');
+    }
+    return { token };
+  }
+
+  // 删除操作
+  async destroy({ key }) {
+    const res = await this.app.redis.del(key);
+    console.log(res);
+    return res;
+  }
+
+
+}
+module.exports = LoginService;

+ 18 - 1
config/config.default.js

@@ -1,7 +1,7 @@
 /* eslint valid-jsdoc: "off" */
 
 'use strict';
-
+const { jwt } = require('./config.secret');
 /**
  * @param {Egg.EggAppInfo} appInfo app info
  */
@@ -59,6 +59,23 @@ module.exports = appInfo => {
     agent: true,
   };
 
+  // // JWT config
+  config.jwt = {
+    ...jwt,
+    expiresIn: '1d',
+    issuer: 'jobs',
+  };
+
+  // redis config
+  // config.redis = {
+  //   client: {
+  //     port: 6379, // Redis port
+  //     host: '127.0.0.1', // Redis host
+  //     password: 123456,
+  //     db: 0,
+  //   },
+  // };
+
   return {
     ...config,
     ...userConfig,

+ 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,

+ 9 - 1
config/config.prod.js

@@ -30,6 +30,14 @@ module.exports = () => {
     app: true,
     agent: true,
   };
-
+  // redis config
+  config.redis = {
+    client: {
+      port: 6379, // Redis port
+      host: '127.0.0.1', // Redis host
+      password: 123456,
+      db: 0,
+    },
+  };
   return config;
 };

+ 4 - 0
config/plugin.js

@@ -5,3 +5,7 @@ exports.amqp = {
   enable: true,
   package: 'egg-naf-amqp',
 };
+exports.redis = {
+  enable: true,
+  package: 'egg-redis',
+};

+ 4 - 2
package.json

@@ -8,12 +8,14 @@
   },
   "dependencies": {
     "egg": "^2.15.1",
+    "egg-naf-amqp": "0.0.13",
+    "egg-redis": "^2.4.0",
     "egg-scripts": "^2.11.0",
     "lodash": "^4.17.15",
     "moment": "^2.24.0",
     "naf-framework-mongoose": "^0.6.11",
-    "silly-datetime": "^0.1.2",
-    "egg-naf-amqp": "0.0.13"
+    "redis": "^3.0.2",
+    "silly-datetime": "^0.1.2"
   },
   "devDependencies": {
     "autod": "^3.0.1",