asd123a20 3 年 前
コミット
d1f8459493
46 ファイル変更132 行追加1182 行削除
  1. 0 46
      service-cms/.github/workflows/nodejs.yml
  2. 1 1
      service-cms/app/model/content.js
  3. 2 0
      service-cms/app/model/imgnews.js
  4. 1 1
      service-cms/app/model/toconfig.js
  5. 4 3
      service-cms/app/service/content.js
  6. 9 7
      service-cms/app/service/imgnews.js
  7. 2 2
      service-cms/app/service/menu.js
  8. 6 8
      service-cms/app/service/toconfig.js
  9. 1 2
      service-files/app/service/filestore.js
  10. 10 1
      service-files/config/config.default.js
  11. 0 46
      service-gateway/.github/workflows/nodejs.yml
  12. 19 9
      service-gateway/app/controller/home.js
  13. 21 21
      service-gateway/config/cms.js
  14. 2 2
      service-gateway/config/code.js
  15. 7 0
      service-gateway/config/config.default.js
  16. 2 2
      service-gateway/config/files.js
  17. 1 1
      service-gateway/config/log.js
  18. 24 24
      service-gateway/config/naf.js
  19. 1 0
      service-gateway/package.json
  20. 0 29
      service-gateway2/.autod.conf.js
  21. 0 1
      service-gateway2/.eslintignore
  22. 0 3
      service-gateway2/.eslintrc
  23. 0 46
      service-gateway2/.github/workflows/nodejs.yml
  24. 0 14
      service-gateway2/.gitignore
  25. 0 12
      service-gateway2/.travis.yml
  26. 0 33
      service-gateway2/README.md
  27. 0 122
      service-gateway2/app/controller/home.js
  28. 0 12
      service-gateway2/app/router.js
  29. 0 14
      service-gateway2/appveyor.yml
  30. 0 197
      service-gateway2/config/cms.js
  31. 0 54
      service-gateway2/config/code.js
  32. 0 60
      service-gateway2/config/config.default.js
  33. 0 22
      service-gateway2/config/files.js
  34. 0 34
      service-gateway2/config/log.js
  35. 0 46
      service-gateway2/config/login.js
  36. 0 147
      service-gateway2/config/naf.js
  37. 0 9
      service-gateway2/config/plugin.js
  38. 0 48
      service-gateway2/config/wx.js
  39. 0 17
      service-gateway2/ecosystem.config.js
  40. 0 5
      service-gateway2/jsconfig.json
  41. 0 49
      service-gateway2/package.json
  42. 0 9
      service-gateway2/server.js
  43. 0 20
      service-gateway2/test/app/controller/home.test.js
  44. 10 2
      service-log/app/service/log.js
  45. 8 0
      service-naf/config/menu.js
  46. 1 1
      service-naf/ecosystem.config.js

+ 0 - 46
service-cms/.github/workflows/nodejs.yml

@@ -1,46 +0,0 @@
-# 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:
-      - main
-      - master
-  pull_request:
-    branches:
-      - main
-      - master
-  schedule:
-    - cron: '0 2 * * *'
-
-jobs:
-  build:
-    runs-on: ${{ matrix.os }}
-
-    strategy:
-      fail-fast: false
-      matrix:
-        node-version: [10]
-        os: [ubuntu-latest, windows-latest, macos-latest]
-
-    steps:
-    - name: Checkout Git Source
-      uses: actions/checkout@v2
-
-    - name: Use Node.js ${{ matrix.node-version }}
-      uses: actions/setup-node@v1
-      with:
-        node-version: ${{ matrix.node-version }}
-
-    - name: Install Dependencies
-      run: npm i -g npminstall && npminstall
-
-    - name: Continuous Integration
-      run: npm run ci
-
-    - name: Code Coverage
-      uses: codecov/codecov-action@v1
-      with:
-        token: ${{ secrets.CODECOV_TOKEN }}

+ 1 - 1
service-cms/app/model/content.js

@@ -4,7 +4,7 @@ const SchemaDefine = {
   // 置顶
   istop: { type: Boolean, required: false, default: false },
   // 排序
-  date: { type: String, required: false },
+  date: { type: Number, required: false },
   // 添加时间
   createAt: { type: Number, required: true },
   // 修改时间

+ 2 - 0
service-cms/app/model/imgnews.js

@@ -19,6 +19,8 @@ const SchemaDefine = {
   column: { type: String, required: false },
   // 绑定单页
   pages: { type: String, required: false },
+  // 名称
+  title: { type: String, required: false },
 };
 const schema = new Schema(SchemaDefine);
 module.exports = app => {

+ 1 - 1
service-cms/app/model/toconfig.js

@@ -4,7 +4,7 @@ const SchemaDefine = {
   code: { type: String, required: true },
   name: { type: String, required: true },
   value: { type: String, required: true },
-  type: { type: String, required: true },
+  type: { type: String, required: false },
 };
 const schema = new Schema(SchemaDefine);
 module.exports = app => {

+ 4 - 3
service-cms/app/service/content.js

@@ -45,11 +45,12 @@ class ContentService extends Service {
       throw error;
     }
   }
-  async query({ skip, limit, title, date }) {
+  async query({ skip, limit, title, date, bind }) {
     const filter = {};
-    if (title || date) filter.$or = [];
+    if (title || date || bind) filter.$or = [];
     if (title) filter.$or.push({ code: { $regex: title } });
-    if (date) filter.$or.push({ name: { $regex: date } });
+    if (date) filter.$or.push({ date: { $regex: date } });
+    if (bind) filter.$or.push({ bind: { $regex: bind } });
     try {
       let res;
       const total = await this.model.find({ ...filter }, { content: false });

+ 9 - 7
service-cms/app/service/imgnews.js

@@ -10,26 +10,27 @@ class ImgnewsService extends Service {
     this.column = this.ctx.model.Column;
     this.pages = this.ctx.model.Pages;
   }
-  async create({ type, bind, date, img, url, column, pages }) {
+  async create({ type, bind, date, img, url, column, pages, title }) {
     assert(type, '类型不存在');
     assert(bind, '绑定类型不存在');
     assert(img, '图片不存在');
+    assert(title, '图片不存在');
     try {
       const createAt = moment().format('x');
       const updateAt = moment().format('x');
-      const item = await this.model.create({ type, bind, date, img, url, column, pages, createAt, updateAt });
+      const item = await this.model.create({ title, type, bind, date, img, url, column, pages, createAt, updateAt });
       return { errcode: 0, errmsg: '', data: item };
     } catch (error) {
       throw error;
     }
   }
-  async update({ id, type, bind, date, img, url, column, pages }) {
+  async update({ id, type, bind, date, img, url, column, pages, title }) {
     assert(id, 'id不存在');
     try {
       const res = await this.model.findOne({ _id: id });
       if (!res) return { errcode: -1001, errmsg: '数据不存在', data: '' };
       const updateAt = moment().format('x');
-      await this.model.updateOne({ _id: id }, { type, bind, date, img, url, column, pages, updateAt });
+      await this.model.updateOne({ _id: id }, { title, type, bind, date, img, url, column, pages, updateAt });
       return { errcode: 0, errmsg: '', data: 'update' };
     } catch (error) {
       throw error;
@@ -46,11 +47,12 @@ class ImgnewsService extends Service {
       throw error;
     }
   }
-  async query({ skip, limit, title, date }) {
+  async query({ skip, limit, title, date, bind }) {
     const filter = {};
-    if (title || date) filter.$or = [];
+    if (title || date || bind) filter.$or = [];
     if (title) filter.$or.push({ code: { $regex: title } });
-    if (date) filter.$or.push({ name: { $regex: date } });
+    if (date) filter.$or.push({ date: { $regex: date } });
+    if (bind) filter.$or.push({ bind: { $regex: bind } });
     try {
       let res;
       const total = await this.model.find({ ...filter }, { content: false });

+ 2 - 2
service-cms/app/service/menu.js

@@ -50,8 +50,8 @@ class MenuService extends Service {
   async query({ skip, limit, name, code }) {
     const filter = {};
     if (name || code) filter.$or = [];
-    if (name) filter.$or.push({ code: { $regex: name } });
-    if (code) filter.$or.push({ name: { $regex: code } });
+    if (name) filter.$or.push({ name: { $regex: name } });
+    if (code) filter.$or.push({ code: { $regex: code } });
     try {
       let res;
       const total = await this.model.find({ ...filter });

+ 6 - 8
service-cms/app/service/toconfig.js

@@ -5,16 +5,14 @@ const Service = require('egg').Service;
 class ToconfigService extends Service {
   constructor(ctx) {
     super(ctx);
-    this.model = this.ctx.model.Type;
-    this.codeModel = this.ctx.model.Dictionary;
+    this.model = this.ctx.model.Toconfig;
   }
   async create({ name, code, type, value }) {
     assert(name, '名称不存在');
     assert(code, '编码不存在');
-    assert(type, '类型不存在');
     assert(value, '值不存在');
     try {
-      const res = await this.findOne({ code });
+      const res = await this.model.findOne({ code });
       if (res) return { errcode: -1001, errmsg: '编码已存在', data: '' };
       const item = await this.model.create({ name, code, type, value });
       return { errcode: 0, errmsg: '', data: item };
@@ -25,7 +23,7 @@ class ToconfigService extends Service {
   async update({ id, name, type, value }) {
     assert(id, 'id不存在');
     try {
-      const res = await this.findOne({ _id: id });
+      const res = await this.model.findOne({ _id: id });
       if (!res) return { errcode: -1001, errmsg: '数据不存在', data: '' };
       await this.model.updateOne({ _id: id }, { name, type, value });
       return { errcode: 0, errmsg: '', data: 'update' };
@@ -36,7 +34,7 @@ class ToconfigService extends Service {
   async delete({ id }) {
     assert(id, 'id不存在');
     try {
-      const res = await this.findOne({ _id: id });
+      const res = await this.model.findOne({ _id: id });
       if (!res) return { errcode: -1001, errmsg: '数据不存在', data: '' };
       await this.model.remove({ _id: id });
       return { errcode: 0, errmsg: '', data: 'delete' };
@@ -47,8 +45,8 @@ class ToconfigService extends Service {
   async query({ skip, limit, name, code }) {
     const filter = {};
     if (name || code) filter.$or = [];
-    if (name) filter.$or.push({ code: { $regex: name } });
-    if (code) filter.$or.push({ name: { $regex: code } });
+    if (name) filter.$or.push({ name: { $regex: name } });
+    if (code) filter.$or.push({ code: { $regex: code } });
     try {
       let res;
       const total = await this.model.find({ ...filter });

+ 1 - 2
service-files/app/service/filestore.js

@@ -13,7 +13,6 @@ class FilestoreService extends Service {
   }
   async upload({ app }) {
     const stream = await this.ctx.getFileStream();
-    console.log(app);
     const rootPath = `${this.app.config.repos_root_path}`;
     // 检查路径是否存在,不存在则创建
     if (!fs.existsSync(`${rootPath}/${app}`)) {
@@ -30,7 +29,7 @@ class FilestoreService extends Service {
     try {
       await awaitWriteStream(stream.pipe(writeStream));
       if (this.app.config.data_save) {
-        return await this.create({ fileName, filePath, name: stream.filename });
+        return await this.create({ fileName, filePath: `/upload/${app}/${fileName}`, name: stream.filename });
       }
       const data = { fileName, filePath, name: stream.filename };
       return { errcode: 0, errmsg: 'ok', data };

+ 10 - 1
service-files/config/config.default.js

@@ -1,7 +1,7 @@
 /* eslint valid-jsdoc: "off" */
 
 'use strict';
-
+const path = require('path');
 /**
  * @param {Egg.EggAppInfo} appInfo app info
  */
@@ -60,6 +60,15 @@ module.exports = appInfo => {
   config.logger = {
     level: 'DEBUG',
   };
+  config.static = {
+    // 静态化访问前缀,如:`http://127.0.0.1:7001/static/images/logo.png`
+    prefix: '/upload',
+    dir: path.join(appInfo.baseDir, 'upload'), // `String` or `Array:[dir1, dir2, ...]` 静态化目录,可以设置多个静态化目录
+    dynamic: true, // 如果当前访问的静态资源没有缓存,则缓存静态文件,和`preload`配合使用;
+    preload: false,
+    maxAge: 31536000, // in prod env, 0 in other envs
+    buffer: true, // in prod env, false in other envs
+  };
   return {
     ...config,
     ...userConfig,

+ 0 - 46
service-gateway/.github/workflows/nodejs.yml

@@ -1,46 +0,0 @@
-# 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:
-      - main
-      - master
-  pull_request:
-    branches:
-      - main
-      - master
-  schedule:
-    - cron: '0 2 * * *'
-
-jobs:
-  build:
-    runs-on: ${{ matrix.os }}
-
-    strategy:
-      fail-fast: false
-      matrix:
-        node-version: [10]
-        os: [ubuntu-latest, windows-latest, macos-latest]
-
-    steps:
-    - name: Checkout Git Source
-      uses: actions/checkout@v2
-
-    - name: Use Node.js ${{ matrix.node-version }}
-      uses: actions/setup-node@v1
-      with:
-        node-version: ${{ matrix.node-version }}
-
-    - name: Install Dependencies
-      run: npm i -g npminstall && npminstall
-
-    - name: Continuous Integration
-      run: npm run ci
-
-    - name: Code Coverage
-      uses: codecov/codecov-action@v1
-      with:
-        token: ${{ secrets.CODECOV_TOKEN }}

+ 19 - 9
service-gateway/app/controller/home.js

@@ -2,6 +2,7 @@
 
 const Controller = require('egg').Controller;
 const jsonwebtoken = require('jsonwebtoken');
+const FormStream = require('formstream');
 class HomeController extends Controller {
   async index() {
     const { modules } = this.app.config;
@@ -27,12 +28,23 @@ class HomeController extends Controller {
     // 发送的数据
     let data = requestMethod === 'GET' ? this.ctx.query : this.ctx.request.body;
     if (requestMethod === 'DELETE') data = this.ctx.params.item;
-    // 发送请求
-    const res = await this.ctx.curl(`${address}${path}`, {
+    // 参数定义
+    let form = {};
+    const options = {
       method: requestMethod,
       data,
       nestedQuerystring: true,
-    });
+    };
+    // 如果是文件上传
+    if (method === 'upload') {
+      const stream = await this.ctx.getFileStream();
+      form = new FormStream();
+      form.stream(stream.fieldname, stream, stream.filename);
+      options.stream = form;
+      options.headers = form.headers();
+    }
+    // 发送请求
+    const res = await this.ctx.curl(`${address}${path}`, options);
     // 默认返回值
     msg = res.data;
 
@@ -103,12 +115,10 @@ class HomeController extends Controller {
     // 获取与当前路径匹配的项
     // const item = modules.filter(e => e.url.includes(path));
     const item = await this.rewrite_path(modules, path);
-    // 没有匹配数据  默认放过
-    if (item) return { errcode: 0, details: '' };
-    // 不验证jwt放过
-    if (!item.jwt) return { errcode: 0, details: '' };
+    // 没有匹配数据  默认放过  不验证jwt放过
+    if (!item || !item.jwt) return { errcode: 0, details: '' };
     // 获取token
-    const token = this.ctx.header.authorization.split('Bearer ')[1];
+    const token = this.ctx.header.authorization;
     try {
       // 解密jwt
       const decode = jsonwebtoken.verify(token, jwt.secret);
@@ -117,7 +127,7 @@ class HomeController extends Controller {
         // 比对签发者
         if (!item.issuer.includes(decode.iss)) return { errcode: -4001, details: 'issuer fail verification' };
       }
-      return { errcode: 0, details: '', decode };
+      return { errcode: 0, details: '', decode: decode._doc };
     } catch (error) {
       return { errcode: -4001, details: error.message };
     }

+ 21 - 21
service-gateway/config/cms.js

@@ -22,9 +22,9 @@ module.exports = [
   },
   {
     url: '/api/cms/column/query',
-    jwt: true,
+    jwt: false,
     issuer: [ 'naf' ],
-    log: true,
+    log: false,
   },
   // 内容
   {
@@ -47,15 +47,15 @@ module.exports = [
   },
   {
     url: '/api/cms/contents/query',
-    jwt: true,
+    jwt: false,
     issuer: [ 'naf' ],
-    log: true,
+    log: false,
   },
   {
     url: '/api/cms/contents/fetch',
-    jwt: true,
+    jwt: false,
     issuer: [ 'naf' ],
-    log: true,
+    log: false,
   },
   // 图片新闻类型
   {
@@ -78,9 +78,9 @@ module.exports = [
   },
   {
     url: '/api/cms/imgtype/query',
-    jwt: true,
+    jwt: false,
     issuer: [ 'naf' ],
-    log: true,
+    log: false,
   },
   // 图片新闻
   {
@@ -103,15 +103,15 @@ module.exports = [
   },
   {
     url: '/api/cms/imgnews/query',
-    jwt: true,
+    jwt: false,
     issuer: [ 'naf' ],
-    log: true,
+    log: false,
   },
   {
-    url: '/api/cms/contents/fetch',
-    jwt: true,
+    url: '/api/cms/imgnews/fetch',
+    jwt: false,
     issuer: [ 'naf' ],
-    log: true,
+    log: false,
   },
   // 菜单
   {
@@ -134,9 +134,9 @@ module.exports = [
   },
   {
     url: '/api/cms/menus/query',
-    jwt: true,
+    jwt: false,
     issuer: [ 'naf' ],
-    log: true,
+    log: false,
   },
   // 单页
   {
@@ -159,15 +159,15 @@ module.exports = [
   },
   {
     url: '/api/cms/pages/query',
-    jwt: true,
+    jwt: false,
     issuer: [ 'naf' ],
-    log: true,
+    log: false,
   },
   {
     url: '/api/cms/pages/fetch',
-    jwt: true,
+    jwt: false,
     issuer: [ 'naf' ],
-    log: true,
+    log: false,
   },
   // 配置
   {
@@ -190,8 +190,8 @@ module.exports = [
   },
   {
     url: '/api/cms/toconfig/query',
-    jwt: true,
+    jwt: false,
     issuer: [ 'naf' ],
-    log: true,
+    log: false,
   },
 ];

+ 2 - 2
service-gateway/config/code.js

@@ -22,7 +22,7 @@ module.exports = [
   },
   {
     url: '/api/code/type/query',
-    jwt: true,
+    jwt: false,
     issuer: [ 'naf' ],
     log: false,
   },
@@ -47,7 +47,7 @@ module.exports = [
   },
   {
     url: '/api/code/dictionary/query',
-    jwt: true,
+    jwt: false,
     issuer: [ 'naf' ],
     log: false,
   },

+ 7 - 0
service-gateway/config/config.default.js

@@ -49,6 +49,13 @@ module.exports = appInfo => {
     wx: 'http://127.0.0.1:9005',
     log: 'http://127.0.0.1:9006',
   };
+  // 限制文件大小
+  config.multipart = {
+    mode: 'stream',
+    fileSize: '5mb',
+    fileExtensions: [ '.zip' ], // 新增允许接收的文件后缀
+    // whitelist: [], // 覆盖允许接收的文件后缀
+  };
   config.jwt = {
     secret: '123456',
   };

+ 2 - 2
service-gateway/config/files.js

@@ -15,8 +15,8 @@ module.exports = [
   },
   {
     url: '/api/files/filestore/query',
-    jwt: true,
+    jwt: false,
     issuer: [ 'naf' ],
-    log: true,
+    log: false,
   },
 ];

+ 1 - 1
service-gateway/config/log.js

@@ -23,7 +23,7 @@ module.exports = [
     url: '/api/log/log/query',
     jwt: false,
     issuer: [ 'naf' ],
-    log: true,
+    log: false,
   },
   {
     url: '/api/log/log/fetch/:id',

+ 24 - 24
service-gateway/config/naf.js

@@ -4,19 +4,19 @@ module.exports = [
   // 用户
   {
     url: '/api/naf/adminUser/create',
-    jwt: false,
+    jwt: true,
     issuer: [ 'naf' ],
     log: true,
   },
   {
     url: '/api/naf/adminUser/update',
-    jwt: false,
+    jwt: true,
     issuer: [ 'naf' ],
     log: true,
   },
   {
     url: '/api/naf/adminUser/delete/:id',
-    jwt: false,
+    jwt: true,
     issuer: [ 'naf' ],
     log: true,
   },
@@ -24,30 +24,30 @@ module.exports = [
     url: '/api/naf/adminUser/query',
     jwt: false,
     issuer: [ 'naf' ],
-    log: true,
+    log: false,
   },
   {
     url: '/api/naf/adminUser/updatePwd',
-    jwt: false,
+    jwt: true,
     issuer: [ 'naf' ],
     log: true,
   },
   // 角色
   {
     url: '/api/naf/role/create',
-    jwt: false,
+    jwt: true,
     issuer: [ 'naf' ],
     log: true,
   },
   {
     url: '/api/naf/role/update',
-    jwt: false,
+    jwt: true,
     issuer: [ 'naf' ],
     log: true,
   },
   {
     url: '/api/naf/role/delete/:id',
-    jwt: false,
+    jwt: true,
     issuer: [ 'naf' ],
     log: true,
   },
@@ -55,12 +55,12 @@ module.exports = [
     url: '/api/naf/role/query',
     jwt: false,
     issuer: [ 'naf' ],
-    log: true,
+    log: false,
   },
   // 菜单
   {
     url: '/api/naf/adminMenu/queryUserMenu',
-    jwt: false,
+    jwt: true,
     issuer: [ 'naf' ],
     log: true,
   },
@@ -68,79 +68,79 @@ module.exports = [
     url: '/api/naf/adminMenu/query',
     jwt: false,
     issuer: [ 'naf' ],
-    log: true,
+    log: false,
   },
   // 用户角色
   {
     url: '/api/naf/userBindRole/bind',
-    jwt: false,
+    jwt: true,
     issuer: [ 'naf' ],
     log: true,
   },
   {
     url: '/api/naf/userBindRole/unbind',
-    jwt: false,
+    jwt: true,
     issuer: [ 'naf' ],
     log: true,
   },
   {
     url: '/api/naf/userBindRole/queryBind',
-    jwt: false,
+    jwt: true,
     issuer: [ 'naf' ],
     log: true,
   },
   {
     url: '/api/naf/userBindRole/queryRole',
-    jwt: false,
+    jwt: true,
     issuer: [ 'naf' ],
     log: true,
   },
   {
     url: '/api/naf/userBindRole/batchBind',
-    jwt: false,
+    jwt: true,
     issuer: [ 'naf' ],
     log: true,
   },
   {
     url: '/api/naf/userBindRole/batchUnBind',
-    jwt: false,
+    jwt: true,
     issuer: [ 'naf' ],
     log: true,
   },
   // 角色菜单
   {
     url: '/api/naf/roleBindMenu/bind',
-    jwt: false,
+    jwt: true,
     issuer: [ 'naf' ],
     log: true,
   },
   {
     url: '/api/naf/roleBindMenu/unbind',
-    jwt: false,
+    jwt: true,
     issuer: [ 'naf' ],
     log: true,
   },
   {
     url: '/api/naf/roleBindMenu/queryBind',
-    jwt: false,
+    jwt: true,
     issuer: [ 'naf' ],
     log: true,
   },
   {
     url: '/api/naf/roleBindMenu/queryRole',
-    jwt: false,
+    jwt: true,
     issuer: [ 'naf' ],
-    log: true,
+    log: false,
   },
   {
     url: '/api/naf/roleBindMenu/batchBind',
-    jwt: false,
+    jwt: true,
     issuer: [ 'naf' ],
     log: true,
   },
   {
     url: '/api/naf/roleBindMenu/batchUnBind',
-    jwt: false,
+    jwt: true,
     issuer: [ 'naf' ],
     log: true,
   },

+ 1 - 0
service-gateway/package.json

@@ -9,6 +9,7 @@
   "dependencies": {
     "egg": "^2.15.1",
     "egg-scripts": "^2.11.0",
+    "formstream": "^1.1.1",
     "jsonwebtoken": "^8.5.1"
   },
   "devDependencies": {

+ 0 - 29
service-gateway2/.autod.conf.js

@@ -1,29 +0,0 @@
-'use strict';
-
-module.exports = {
-  write: true,
-  prefix: '^',
-  plugin: 'autod-egg',
-  test: [
-    'test',
-    'benchmark',
-  ],
-  dep: [
-    'egg',
-    'egg-scripts',
-  ],
-  devdep: [
-    'egg-ci',
-    'egg-bin',
-    'egg-mock',
-    'autod',
-    'autod-egg',
-    'eslint',
-    'eslint-config-egg',
-  ],
-  exclude: [
-    './test/fixtures',
-    './dist',
-  ],
-};
-

+ 0 - 1
service-gateway2/.eslintignore

@@ -1 +0,0 @@
-coverage

+ 0 - 3
service-gateway2/.eslintrc

@@ -1,3 +0,0 @@
-{
-  "extends": "eslint-config-egg"
-}

+ 0 - 46
service-gateway2/.github/workflows/nodejs.yml

@@ -1,46 +0,0 @@
-# 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:
-      - main
-      - master
-  pull_request:
-    branches:
-      - main
-      - master
-  schedule:
-    - cron: '0 2 * * *'
-
-jobs:
-  build:
-    runs-on: ${{ matrix.os }}
-
-    strategy:
-      fail-fast: false
-      matrix:
-        node-version: [10]
-        os: [ubuntu-latest, windows-latest, macos-latest]
-
-    steps:
-    - name: Checkout Git Source
-      uses: actions/checkout@v2
-
-    - name: Use Node.js ${{ matrix.node-version }}
-      uses: actions/setup-node@v1
-      with:
-        node-version: ${{ matrix.node-version }}
-
-    - name: Install Dependencies
-      run: npm i -g npminstall && npminstall
-
-    - name: Continuous Integration
-      run: npm run ci
-
-    - name: Code Coverage
-      uses: codecov/codecov-action@v1
-      with:
-        token: ${{ secrets.CODECOV_TOKEN }}

+ 0 - 14
service-gateway2/.gitignore

@@ -1,14 +0,0 @@
-logs/
-npm-debug.log
-yarn-error.log
-node_modules/
-package-lock.json
-yarn.lock
-coverage/
-.idea/
-run/
-.DS_Store
-*.sw*
-*.un~
-typings/
-.nyc_output/

+ 0 - 12
service-gateway2/.travis.yml

@@ -1,12 +0,0 @@
-
-language: node_js
-node_js:
-  - '10'
-before_install:
-  - npm i npminstall -g
-install:
-  - npminstall
-script:
-  - npm run ci
-after_script:
-  - npminstall codecov && codecov

+ 0 - 33
service-gateway2/README.md

@@ -1,33 +0,0 @@
-# service-gateway
-
-
-
-## QuickStart
-
-<!-- add docs here for user -->
-
-see [egg docs][egg] for more detail.
-
-### Development
-
-```bash
-$ npm i
-$ npm run dev
-$ open http://localhost:7001/
-```
-
-### Deploy
-
-```bash
-$ npm start
-$ npm stop
-```
-
-### npm scripts
-
-- Use `npm run lint` to check code style.
-- Use `npm test` to run unit test.
-- Use `npm run autod` to auto detect dependencies upgrade, see [autod](https://www.npmjs.com/package/autod) for more detail.
-
-
-[egg]: https://eggjs.org

+ 0 - 122
service-gateway2/app/controller/home.js

@@ -1,122 +0,0 @@
-'use strict';
-
-const Controller = require('egg').Controller;
-const jsonwebtoken = require('jsonwebtoken');
-const { createProxyMiddleware, responseInterceptor } = require('http-proxy-middleware');
-class HomeController extends Controller {
-  async index() {
-    const { modules } = this.app.config;
-    // 路径参数
-    const { agent, service, module, method, item } = this.ctx.params;
-    // 请求地址
-    const address = modules[service];
-    // 请求方法
-    const requestMethod = this.ctx.request.method;
-    // 请求路径
-    const path = this.ctx.path;
-    const exampleProxy = createProxyMiddleware(
-      `/${agent}/${service}/`,
-      {
-        target: `${address}${path}`,
-        changeOrigin: true,
-        selfHandleResponse: true,
-        onProxyRes: responseInterceptor(async (buffer, proxyRes, req, res) => {
-          console.log(buffer, 'buffer');
-          console.log(proxyRes, 'proxyRes');
-          console.log(req, 'req');
-          console.log(res, 'res');
-        }),
-      });
-    this.app.use(exampleProxy);
-    this.app.listen(3000);
-    // // jwt 验证
-    // const auth = await this.auth({ service, path });
-    // // 验证失败
-    // if (auth.errcode !== 0) {
-    //   this.ctx.status = 401;
-    //   this.ctx.body = { errcode: 401, errmsg: '身份验证失败', details: auth.details };
-    //   return false;
-    // }
-    this.ctx.body = 111;
-  }
-
-  // 日志记录
-  async setLog({ agent, service, module, method, item, details, result, auth }) {
-    // 配置
-    const { modules, apipath } = this.app.config;
-    // 请求路径
-    const path = this.ctx.path;
-    // 根据service类型 获取配置文件
-    const logmodules = apipath[service];
-    // 没有配置文件默认放过
-    if (logmodules) {
-      // const items = logmodules.find(e => e.url.includes(path));
-      const items = await this.rewrite_path(logmodules, path);
-      if (items && items.log) {
-        // 此处开始记录日志
-        let userName = null;
-        let name = null;
-        if (auth.decode) {
-          userName = auth.decode.userName;
-          name = auth.decode.name;
-        }
-        try {
-          await this.ctx.curl(`${modules.log}/api/log/log/create`, {
-            method: 'POST',
-            dataType: 'json',
-            data: { agent, service, module, method, item, details, result, userName, name },
-          });
-        } catch (error) {
-          this.ctx.logger.error(`日志添加失败: ${error}`);
-        }
-      }
-    }
-  }
-
-  // 验证函数
-  async auth({ service, path }) {
-    const { jwt, apipath } = this.app.config;
-    // 根据service类型 获取配置文件
-    const modules = apipath[service];
-    // 没有配置文件默认放过
-    if (!modules) return { errcode: 0, details: '' };
-    // 获取与当前路径匹配的项
-    // const item = modules.filter(e => e.url.includes(path));
-    const item = await this.rewrite_path(modules, path);
-    // 没有匹配数据  默认放过
-    if (item) return { errcode: 0, details: '' };
-    // 不验证jwt放过
-    if (!item.jwt) return { errcode: 0, details: '' };
-    // 获取token
-    const token = this.ctx.header.authorization.split('Bearer ')[1];
-    try {
-      // 解密jwt
-      const decode = jsonwebtoken.verify(token, jwt.secret);
-      // 如果有验证签发者
-      if (item && item.issuer) {
-        // 比对签发者
-        if (!item.issuer.includes(decode.iss)) return { errcode: -4001, details: 'issuer fail verification' };
-      }
-      return { errcode: 0, details: '', decode };
-    } catch (error) {
-      return { errcode: -4001, details: error.message };
-    }
-  }
-  // 重写路径
-  async rewrite_path(modules, path) {
-    return modules.find(e => {
-      const { url } = e;
-      let data = null;
-      const urlList = url.split('/');
-      const pathIist = path.split('/');
-      const urlItem = urlList.findIndex(j => j.includes(':'));
-      if (urlItem > 0) data = pathIist[urlItem];
-      if (data !== null) urlList[urlItem] = data;
-      const pathItem = urlList.join('/');
-      if (pathItem === path) return e;
-      return false;
-    });
-  }
-}
-
-module.exports = HomeController;

+ 0 - 12
service-gateway2/app/router.js

@@ -1,12 +0,0 @@
-'use strict';
-
-/**
- * @param {Egg.Application} app - egg application
- */
-module.exports = app => {
-  const { router, controller } = app;
-  // router.post('/rewritepath', controller.home.rewrite_path);
-  router.get('/:agent/:service/:module/:method', controller.home.index);
-  router.post('/:agent/:service/:module/:method', controller.home.index);
-  router.delete('/:agent/:service/:module/:method/:item', controller.home.index);
-};

+ 0 - 14
service-gateway2/appveyor.yml

@@ -1,14 +0,0 @@
-environment:
-  matrix:
-    - nodejs_version: '10'
-
-install:
-  - ps: Install-Product node $env:nodejs_version
-  - npm i npminstall && node_modules\.bin\npminstall
-
-test_script:
-  - node --version
-  - npm --version
-  - npm run test
-
-build: off

+ 0 - 197
service-gateway2/config/cms.js

@@ -1,197 +0,0 @@
-'use strict';
-
-module.exports = [
-  // 栏目
-  {
-    url: '/api/cms/column/create',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/column/update',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/column/delete/:id',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/column/query',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  // 内容
-  {
-    url: '/api/cms/contents/create',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/contents/update',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/contents/delete/:id',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/contents/query',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/contents/fetch',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  // 图片新闻类型
-  {
-    url: '/api/cms/imgtype/create',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/imgtype/update',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/imgtype/delete/:id',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/imgtype/query',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  // 图片新闻
-  {
-    url: '/api/cms/imgnews/create',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/imgnews/update',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/imgnews/delete/:id',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/imgnews/query',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/contents/fetch',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  // 菜单
-  {
-    url: '/api/cms/menus/create',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/menus/update',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/menus/delete/:id',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/menus/query',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  // 单页
-  {
-    url: '/api/cms/pages/create',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/pages/update',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/pages/delete/:id',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/pages/query',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/pages/fetch',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  // 配置
-  {
-    url: '/api/cms/toconfig/create',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/toconfig/update',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/toconfig/delete/:id',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/cms/toconfig/query',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-];

+ 0 - 54
service-gateway2/config/code.js

@@ -1,54 +0,0 @@
-'use strict';
-
-module.exports = [
-  // 字典类型
-  {
-    url: '/api/code/type/create',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/code/type/update',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/code/type/delete/:id',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/code/type/query',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: false,
-  },
-  // 字典
-  {
-    url: '/api/code/dictionary/create',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/code/dictionary/update',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/code/dictionary/delete/:id',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/code/dictionary/query',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: false,
-  },
-];

+ 0 - 60
service-gateway2/config/config.default.js

@@ -1,60 +0,0 @@
-/* eslint valid-jsdoc: "off" */
-
-'use strict';
-const code = require('./code');
-const files = require('./files');
-const cms = require('./cms');
-const log = require('./log');
-const login = require('./login');
-const wx = require('./wx');
-const naf = require('./naf');
-/**
- * @param {Egg.EggAppInfo} appInfo app info
- */
-module.exports = appInfo => {
-  /**
-   * built-in config
-   * @type {Egg.EggAppConfig}
-   **/
-  const config = exports = {};
-
-  // use for cookie sign key, should change to your own and keep security
-  config.keys = appInfo.name + '_1637282221255_6501';
-
-  // add your middleware config here
-  config.middleware = [];
-
-  // add your user config here
-  const userConfig = {
-    // myAppName: 'egg',
-  };
-  // 安全配置
-  config.security = {
-    csrf: {
-      // ignoreJSON: true, // 默认为 false,当设置为 true 时,将会放过所有 content-type 为 `application/json` 的请求
-      enable: false,
-    },
-  };
-  config.cluster = {
-    listen: {
-      port: 18090,
-    },
-  };
-  config.modules = {
-    login: 'http://127.0.0.1:9000',
-    code: 'http://127.0.0.1:9001',
-    files: 'http://127.0.0.1:9002',
-    naf: 'http://127.0.0.1:9003',
-    cms: 'http://127.0.0.1:9004',
-    wx: 'http://127.0.0.1:9005',
-    log: 'http://127.0.0.1:9006',
-  };
-  config.jwt = {
-    secret: '123456',
-  };
-  config.apipath = { code, files, naf, cms, login, wx, log };
-  return {
-    ...config,
-    ...userConfig,
-  };
-};

+ 0 - 22
service-gateway2/config/files.js

@@ -1,22 +0,0 @@
-'use strict';
-
-module.exports = [
-  {
-    url: '/api/files/:app/upload',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/files/filestore/delete',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/files/filestore/query',
-    jwt: true,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-];

+ 0 - 34
service-gateway2/config/log.js

@@ -1,34 +0,0 @@
-'use strict';
-
-module.exports = [
-  {
-    url: '/api/log/log/create',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/log/log/update',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/log/log/delete/:id',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/log/log/query',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/log/log/fetch/:id',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-];

+ 0 - 46
service-gateway2/config/login.js

@@ -1,46 +0,0 @@
-'use strict';
-
-module.exports = [
-  // 获取验证码
-  {
-    url: '/api/login/pwdlogin/get_verification_code',
-    jwt: false,
-    issuer: [],
-    log: false,
-  },
-  // 帐号密码登录
-  {
-    url: '/api/login/pwdlogin/auth',
-    jwt: false,
-    issuer: [],
-    log: true,
-  },
-  // 获取二维码(uuid)
-  {
-    url: '/api/login/qrlogin/qrcode',
-    jwt: false,
-    issuer: [],
-    log: false,
-  },
-  // 使用二维码换取登录凭证
-  {
-    url: '/api/login/qrlogin/qrcodeLogin',
-    jwt: false,
-    issuer: [],
-    log: false,
-  },
-  // 获取openid 带参数二维码uuid
-  {
-    url: '/api/login/qrlogin/get_openid',
-    jwt: false,
-    issuer: [],
-    log: false,
-  },
-  // 二维码登录验证
-  {
-    url: '/api/login/qrlogin/auth',
-    jwt: false,
-    issuer: [],
-    log: false,
-  },
-];

+ 0 - 147
service-gateway2/config/naf.js

@@ -1,147 +0,0 @@
-'use strict';
-
-module.exports = [
-  // 用户
-  {
-    url: '/api/naf/adminUser/create',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/naf/adminUser/update',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/naf/adminUser/delete/:id',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/naf/adminUser/query',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/naf/adminUser/updatePwd',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  // 角色
-  {
-    url: '/api/naf/role/create',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/naf/role/update',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/naf/role/delete/:id',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/naf/role/query',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  // 菜单
-  {
-    url: '/api/naf/adminMenu/queryUserMenu',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/naf/adminMenu/query',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  // 用户角色
-  {
-    url: '/api/naf/userBindRole/bind',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/naf/userBindRole/unbind',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/naf/userBindRole/queryBind',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/naf/userBindRole/queryRole',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/naf/userBindRole/batchBind',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/naf/userBindRole/batchUnBind',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  // 角色菜单
-  {
-    url: '/api/naf/roleBindMenu/bind',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/naf/roleBindMenu/unbind',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/naf/roleBindMenu/queryBind',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/naf/roleBindMenu/queryRole',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/naf/roleBindMenu/batchBind',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-  {
-    url: '/api/naf/roleBindMenu/batchUnBind',
-    jwt: false,
-    issuer: [ 'naf' ],
-    log: true,
-  },
-];

+ 0 - 9
service-gateway2/config/plugin.js

@@ -1,9 +0,0 @@
-'use strict';
-
-/** @type Egg.EggPlugin */
-module.exports = {
-  // had enabled by egg
-  // static: {
-  //   enable: true,
-  // }
-};

+ 0 - 48
service-gateway2/config/wx.js

@@ -1,48 +0,0 @@
-'use strict';
-
-module.exports = [
-  // 微信api
-  {
-    url: '/api/wx/wxapi/get_openid',
-    jwt: false,
-    issuer: [],
-    log: false,
-  },
-  {
-    url: '/api/wx/wxapi/get_userInfo',
-    jwt: false,
-    issuer: [],
-    log: false,
-  },
-  {
-    url: '/api/wx/wxapi/pushMould',
-    jwt: true,
-    issuer: [ 'naf', 'user' ],
-    log: true,
-  },
-  // 支付api
-  {
-    url: '/api/wx/payapi/book_order',
-    jwt: true,
-    issuer: [ 'user' ],
-    log: true,
-  },
-  {
-    url: '/api/wx/payapi/pay',
-    jwt: true,
-    issuer: [ 'user' ],
-    log: true,
-  },
-  {
-    url: '/api/wx/payapi/orderClose',
-    jwt: true,
-    issuer: [ 'naf', 'user' ],
-    log: true,
-  },
-  {
-    url: '/api/wx/payapi/refund',
-    jwt: true,
-    issuer: [ 'user' ],
-    log: true,
-  },
-];

+ 0 - 17
service-gateway2/ecosystem.config.js

@@ -1,17 +0,0 @@
-'use strict';
-
-const app = 'service-gateway';
-module.exports = {
-  apps: [{
-    name: app, // 应用名称
-    script: './server.js', // 实际启动脚本
-    out: `./logs/${app}.log`,
-    error: `./logs/${app}.err`,
-    watch: [ // 监控变化的目录,一旦变化,自动重启
-      'app', 'config',
-    ],
-    env: {
-      NODE_ENV: process.env.NODE_ENV || 'production', // 环境参数,当前指定为生产环境
-    },
-  }],
-};

+ 0 - 5
service-gateway2/jsconfig.json

@@ -1,5 +0,0 @@
-{
-  "include": [
-    "**/*"
-  ]
-}

+ 0 - 49
service-gateway2/package.json

@@ -1,49 +0,0 @@
-{
-  "name": "service-gateway",
-  "version": "1.0.0",
-  "description": "",
-  "private": true,
-  "egg": {
-    "declarations": true
-  },
-  "dependencies": {
-    "egg": "^2.15.1",
-    "egg-scripts": "^2.11.0",
-    "express": "^4.17.2",
-    "jsonwebtoken": "^8.5.1"
-  },
-  "devDependencies": {
-    "autod": "^3.0.1",
-    "autod-egg": "^1.1.0",
-    "egg-bin": "^4.11.0",
-    "egg-ci": "^1.11.0",
-    "egg-mock": "^3.21.0",
-    "eslint": "^5.13.0",
-    "eslint-config-egg": "^7.1.0",
-    "http-proxy-middleware": "^2.0.3"
-  },
-  "engines": {
-    "node": ">=10.0.0"
-  },
-  "scripts": {
-    "start": "egg-scripts start --daemon --title=egg-server-service-gateway",
-    "stop": "egg-scripts stop --title=egg-server-service-gateway",
-    "dev": "egg-bin dev",
-    "debug": "egg-bin debug",
-    "test": "npm run lint -- --fix && npm run test-local",
-    "test-local": "egg-bin test",
-    "cov": "egg-bin cov",
-    "lint": "eslint .",
-    "ci": "npm run lint && npm run cov",
-    "autod": "autod"
-  },
-  "ci": {
-    "version": "10"
-  },
-  "repository": {
-    "type": "git",
-    "url": ""
-  },
-  "author": "",
-  "license": "MIT"
-}

+ 0 - 9
service-gateway2/server.js

@@ -1,9 +0,0 @@
-
-// eslint-disable-next-line strict
-const egg = require('egg');
-
-const workers = Number(process.argv[2] || require('os').cpus().length);
-egg.startCluster({
-  workers,
-  baseDir: __dirname,
-});

+ 0 - 20
service-gateway2/test/app/controller/home.test.js

@@ -1,20 +0,0 @@
-'use strict';
-
-const { app, assert } = require('egg-mock/bootstrap');
-
-describe('test/app/controller/home.test.js', () => {
-  it('should assert', () => {
-    const pkg = require('../../../package.json');
-    assert(app.config.keys.startsWith(pkg.name));
-
-    // const ctx = app.mockContext({});
-    // yield ctx.service.xx();
-  });
-
-  it('should GET /', () => {
-    return app.httpRequest()
-      .get('/')
-      .expect('hi, egg')
-      .expect(200);
-  });
-});

+ 10 - 2
service-log/app/service/log.js

@@ -38,12 +38,20 @@ class LogService extends Service {
       throw error;
     }
   }
-  async query({ skip, limit, filter }) {
+  async query({ skip, limit, service, module, method, result, userName, name }) {
+    const filter = {};
+    if (service || module || method || result || userName || name) filter.$or = [];
+    if (service) filter.$or.push({ service: { $regex: service } });
+    if (module) filter.$or.push({ module: { $regex: module } });
+    if (method) filter.$or.push({ method: { $regex: method } });
+    if (result) filter.$or.push({ result: { $regex: result } });
+    if (userName) filter.$or.push({ userName: { $regex: userName } });
+    if (name) filter.$or.push({ name: { $regex: name } });
     try {
       const total = await this.model.find({ ...filter });
       let res;
       if (skip && limit) {
-        res = await this.model.find({ ...filter }).skip(skip * limit).limit(limit);
+        res = await this.model.find({ ...filter }).skip(Number(skip) * Number(limit)).limit(Number(limit));
       } else {
         res = await this.model.find({ ...filter });
       }

+ 8 - 0
service-naf/config/menu.js

@@ -40,6 +40,14 @@ const data = [
     parentCode: 'gaf',
     icon: 'el-icon-star-on',
   },
+  {
+    module: 'log',
+    path: '/log/home',
+    title: '系统日志',
+    code: 'log',
+    parentCode: 'gaf',
+    icon: 'el-icon-star-on',
+  },
   // 内容管理
   {
     module: 'content',

+ 1 - 1
service-naf/ecosystem.config.js

@@ -1,4 +1,4 @@
-g   'use strict';
+ng   'use strict';
 
 const app = 'service-naf';
 module.exports = {