소스 검색

2022/4/21提交

asd123a20 3 년 전
부모
커밋
2c96ef3cab
32개의 변경된 파일612개의 추가작업 그리고 10개의 파일을 삭제
  1. 1 1
      service-cms/app/model/imgnews.js
  2. 1 1
      service-gateway/app/controller/home.js
  3. 1 0
      service-gateway/app/router.js
  4. 2 2
      service-gateway/config/config.default.js
  5. 28 0
      service-gateway/config/importandexport.js
  6. 2 2
      service-import-export/app/controller/handle.js
  7. 3 0
      service-import-export/app/importFiled/user.js
  8. 7 0
      service-import-export/app/importFiled/vip.js
  9. 2 2
      service-import-export/app/router.js
  10. 2 2
      service-import-export/app/service/progress.js
  11. 29 0
      service-integral/.autod.conf.js
  12. 1 0
      service-integral/.eslintignore
  13. 3 0
      service-integral/.eslintrc
  14. 14 0
      service-integral/.gitignore
  15. 12 0
      service-integral/.travis.yml
  16. 33 0
      service-integral/README.md
  17. 27 0
      service-integral/app/controller/power.js
  18. 27 0
      service-integral/app/controller/vip.js
  19. 15 0
      service-integral/app/model/power.js
  20. 29 0
      service-integral/app/model/vip.js
  21. 19 0
      service-integral/app/router.js
  22. 17 0
      service-integral/app/schedule/inspect.js
  23. 69 0
      service-integral/app/service/power.js
  24. 92 0
      service-integral/app/service/vip.js
  25. 14 0
      service-integral/appveyor.yml
  26. 54 0
      service-integral/config/config.default.js
  27. 9 0
      service-integral/config/plugin.js
  28. 17 0
      service-integral/ecosystem.config.js
  29. 5 0
      service-integral/jsconfig.json
  30. 48 0
      service-integral/package.json
  31. 9 0
      service-integral/server.js
  32. 20 0
      service-integral/test/app/controller/home.test.js

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

@@ -12,7 +12,7 @@ const SchemaDefine = {
   // 绑定类型
   // 绑定类型
   bind: { type: String, required: true },
   bind: { type: String, required: true },
   // 类型
   // 类型
-  type: { type: Number, required: true }, // 0 = 栏目  1 = 单页  2 = 链接
+  type: { type: Number, required: true }, // 1 = 栏目  2 = 单页  0 = 链接
   // 链接地址
   // 链接地址
   url: { type: String, required: false },
   url: { type: String, required: false },
   // 绑定栏目
   // 绑定栏目

+ 1 - 1
service-gateway/app/controller/home.js

@@ -37,7 +37,7 @@ class HomeController extends Controller {
       nestedQuerystring: true,
       nestedQuerystring: true,
     };
     };
     // 如果是文件上传
     // 如果是文件上传
-    if (method === 'upload') {
+    if (method === 'upload' || method === 'import') {
       const stream = await this.ctx.getFileStream();
       const stream = await this.ctx.getFileStream();
       form = new FormStream();
       form = new FormStream();
       form.stream(stream.fieldname, stream, stream.filename);
       form.stream(stream.fieldname, stream, stream.filename);

+ 1 - 0
service-gateway/app/router.js

@@ -8,5 +8,6 @@ module.exports = app => {
   // router.post('/rewritepath', controller.home.rewrite_path);
   // router.post('/rewritepath', controller.home.rewrite_path);
   router.get('/:agent/:service/:module/:method', controller.home.index);
   router.get('/:agent/:service/:module/:method', controller.home.index);
   router.post('/:agent/:service/:module/:method', controller.home.index);
   router.post('/:agent/:service/:module/:method', controller.home.index);
+  router.post('/:agent/:service/:module/:method/:item', controller.home.index);
   router.delete('/:agent/:service/:module/:method/:item', controller.home.index);
   router.delete('/:agent/:service/:module/:method/:item', controller.home.index);
 };
 };

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

@@ -59,7 +59,7 @@ module.exports = appInfo => {
     clientUser: 'http://127.0.0.1:9013',
     clientUser: 'http://127.0.0.1:9013',
     clientVip: 'http://127.0.0.1:9014',
     clientVip: 'http://127.0.0.1:9014',
     activity: 'http://127.0.0.1:9015',
     activity: 'http://127.0.0.1:9015',
-    importExport: 'http://127.0.0.1:9016',
+    importandexport: 'http://127.0.0.1:9016',
     reader: 'http://127.0.0.1:9017',
     reader: 'http://127.0.0.1:9017',
     question: 'http://127.0.0.1:9018',
     question: 'http://127.0.0.1:9018',
   };
   };
@@ -67,7 +67,7 @@ module.exports = appInfo => {
   config.multipart = {
   config.multipart = {
     mode: 'stream',
     mode: 'stream',
     fileSize: '5mb',
     fileSize: '5mb',
-    fileExtensions: [ '.zip' ], // 新增允许接收的文件后缀
+    fileExtensions: [ '.zip', 'xlsx' ], // 新增允许接收的文件后缀
     // whitelist: [], // 覆盖允许接收的文件后缀
     // whitelist: [], // 覆盖允许接收的文件后缀
   };
   };
   config.jwt = {
   config.jwt = {

+ 28 - 0
service-gateway/config/importandexport.js

@@ -0,0 +1,28 @@
+'use strict';
+
+module.exports = [
+  {
+    url: '/api/importandexport/handle/import/:type',
+    jwt: false,
+    issuer: [ 'naf' ],
+    log: true,
+  },
+  {
+    url: '/api/importandexport/handle/exports',
+    jwt: false,
+    issuer: [ 'naf' ],
+    log: true,
+  },
+  {
+    url: '/api/importandexport/handle/template',
+    jwt: false,
+    issuer: [ 'naf' ],
+    log: true,
+  },
+  {
+    url: '/api/importandexport/handle/progressed',
+    jwt: false,
+    issuer: [ 'naf' ],
+    log: false,
+  },
+];

+ 2 - 2
service-import-export/app/controller/handle.js

@@ -4,7 +4,7 @@ const { v4: uuidv4 } = require('uuid');
 class HandleController extends Controller {
 class HandleController extends Controller {
   async import() {
   async import() {
     const taskId = uuidv4();
     const taskId = uuidv4();
-    this.ctx.service.handle.import({ ...this.ctx.params, taskId });
+    await this.ctx.service.handle.import({ ...this.ctx.params, taskId });
     this.ctx.body = { errcode: 0, errmsg: '', data: [], taskId };
     this.ctx.body = { errcode: 0, errmsg: '', data: [], taskId };
   }
   }
   async export() {
   async export() {
@@ -13,7 +13,7 @@ class HandleController extends Controller {
     this.ctx.body = { errcode: 0, errmsg: '', data: [], taskId };
     this.ctx.body = { errcode: 0, errmsg: '', data: [], taskId };
   }
   }
   async progressed() {
   async progressed() {
-    const res = await this.ctx.service.progress.progressed(this.ctx.params);
+    const res = await this.ctx.service.progress.progressed(this.ctx.query);
     this.ctx.body = res;
     this.ctx.body = res;
   }
   }
   async template() {
   async template() {

+ 3 - 0
service-import-export/app/importFiled/user.js

@@ -3,4 +3,7 @@
 module.exports = [
 module.exports = [
   { '姓名': 'name' },
   { '姓名': 'name' },
   { '电话': 'phone' },
   { '电话': 'phone' },
+  { '单位': 'company' },
+  { '标识': 'tab' },
+  { 'openid': 'openid' },
 ];
 ];

+ 7 - 0
service-import-export/app/importFiled/vip.js

@@ -3,4 +3,11 @@
 module.exports = [
 module.exports = [
   { '姓名': 'name' },
   { '姓名': 'name' },
   { '电话': 'phone' },
   { '电话': 'phone' },
+  { '单位': 'company' },
+  { '标识': 'tab' },
+  { 'openid': 'openid' },
+  { 'Vip标识': 'vipTab' },
+  { '状态': 'status' },
+  { '会员开始时间': 'startTime' },
+  { '会员过期时间': 'endTime' },
 ];
 ];

+ 2 - 2
service-import-export/app/router.js

@@ -5,9 +5,9 @@
  */
  */
 module.exports = app => {
 module.exports = app => {
   const { router, controller } = app;
   const { router, controller } = app;
-  // 点赞
+  // 导入导出进度
   router.post('/api/importandexport/handle/import/:type', controller.handle.import);
   router.post('/api/importandexport/handle/import/:type', controller.handle.import);
   router.post('/api/importandexport/handle/exports', controller.handle.export);
   router.post('/api/importandexport/handle/exports', controller.handle.export);
   router.get('/api/importandexport/handle/template', controller.handle.template);
   router.get('/api/importandexport/handle/template', controller.handle.template);
-  router.get('/api/importandexport/handle/progressed/:taskId', controller.handle.progressed);
+  router.get('/api/importandexport/handle/progressed', controller.handle.progressed);
 };
 };

+ 2 - 2
service-import-export/app/service/progress.js

@@ -11,9 +11,9 @@ class HandleService extends Service {
     const res = await this.progressModel.findOne({ taskId });
     const res = await this.progressModel.findOne({ taskId });
     if (!res) {
     if (!res) {
       await this.progressModel.create({ type, taskId, progress });
       await this.progressModel.create({ type, taskId, progress });
-      return;
+    } else {
+      await this.progressModel.updateOne({ _id: res._id }, { type, taskId, progress });
     }
     }
-    await this.progressModel.updateOne({ _id: res._id }, { type, taskId, progress });
   }
   }
   // 查询进度
   // 查询进度
   async progressed({ taskId }) {
   async progressed({ taskId }) {

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

@@ -0,0 +1,29 @@
+'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',
+  ],
+};
+

+ 1 - 0
service-integral/.eslintignore

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

+ 3 - 0
service-integral/.eslintrc

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

+ 14 - 0
service-integral/.gitignore

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

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

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

+ 33 - 0
service-integral/README.md

@@ -0,0 +1,33 @@
+# service-code
+
+
+
+## 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

+ 27 - 0
service-integral/app/controller/power.js

@@ -0,0 +1,27 @@
+'use strict';
+const Controller = require('egg').Controller;
+
+class PowerController extends Controller {
+  async create() {
+    const res = await this.ctx.service.power.create(this.ctx.request.body);
+    this.ctx.body = res;
+  }
+  async update() {
+    const res = await this.ctx.service.power.update(this.ctx.request.body);
+    this.ctx.body = res;
+  }
+  async proceed() {
+    const res = await this.ctx.service.power.proceed(this.ctx.request.body);
+    this.ctx.body = res;
+  }
+  async delete() {
+    const res = await this.ctx.service.power.delete(this.ctx.params);
+    this.ctx.body = res;
+  }
+  async query() {
+    const res = await this.ctx.service.power.query(this.ctx.query);
+    this.ctx.body = res;
+  }
+}
+
+module.exports = PowerController;

+ 27 - 0
service-integral/app/controller/vip.js

@@ -0,0 +1,27 @@
+'use strict';
+const Controller = require('egg').Controller;
+
+class VipController extends Controller {
+  async create() {
+    const res = await this.ctx.service.vip.create(this.ctx.request.body);
+    this.ctx.body = res;
+  }
+  async update() {
+    const res = await this.ctx.service.vip.update(this.ctx.request.body);
+    this.ctx.body = res;
+  }
+  async proceed() {
+    const res = await this.ctx.service.vip.proceed(this.ctx.request.body);
+    this.ctx.body = res;
+  }
+  async delete() {
+    const res = await this.ctx.service.vip.delete(this.ctx.params);
+    this.ctx.body = res;
+  }
+  async query() {
+    const res = await this.ctx.service.vip.query(this.ctx.query);
+    this.ctx.body = res;
+  }
+}
+
+module.exports = VipController;

+ 15 - 0
service-integral/app/model/power.js

@@ -0,0 +1,15 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const SchemaDefine = {
+  // 标识
+  vipTab: { type: String, required: false },
+  // openid
+  openid: { type: String, required: true },
+  // 文章IDlist
+  list: { type: Array, required: true },
+};
+const schema = new Schema(SchemaDefine);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('power', schema, 'power');
+};

+ 29 - 0
service-integral/app/model/vip.js

@@ -0,0 +1,29 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const SchemaDefine = {
+  // 头像
+  thumbnail: { type: String, required: false },
+  // 昵称
+  name: { type: String, required: true },
+  // 手机号
+  phone: { type: String, required: true },
+  // 单位
+  company: { type: String, required: false },
+  // 标识
+  vipTab: { type: String, required: false },
+  // 标识
+  tab: { type: String, required: false },
+  // openid
+  openid: { type: String, required: true },
+  // 状态:0=正常,1=过期
+  status: { type: String, required: true },
+  // 创建时间
+  startTime: { type: Number, required: true },
+  // 结束时间
+  endTime: { type: Number, required: true },
+};
+const schema = new Schema(SchemaDefine);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('vip', schema, 'vip');
+};

+ 19 - 0
service-integral/app/router.js

@@ -0,0 +1,19 @@
+'use strict';
+
+/**
+ * @param {Egg.Application} app - egg application
+ */
+module.exports = app => {
+  const { router, controller } = app;
+  // vip
+  router.post('/api/clientVip/vip/create', controller.vip.create);
+  router.post('/api/clientVip/vip/update', controller.vip.update);
+  router.post('/api/clientVip/vip/proceed', controller.vip.proceed);
+  router.delete('/api/clientVip/vip/delete/:id', controller.vip.delete);
+  router.get('/api/clientVip/vip/query', controller.vip.query);
+  // 权限
+  router.post('/api/clientVip/power/create', controller.power.create);
+  router.post('/api/clientVip/power/update', controller.power.update);
+  router.delete('/api/clientVip/power/delete/:id', controller.power.delete);
+  router.get('/api/clientVip/power/query', controller.power.query);
+};

+ 17 - 0
service-integral/app/schedule/inspect.js

@@ -0,0 +1,17 @@
+'use strict';
+const moment = require('moment');
+module.exports = {
+  schedule: {
+    interval: '1m', // 1 分钟间隔
+    type: 'all', // 指定所有的 worker 都需要执行
+  },
+  async task(ctx) {
+    const res = await ctx.model.Vip.find({ status: 0, vipTab: 'svip' });
+    for (let i = 0; i < res.length; i++) {
+      const time = moment().valueOf();
+      if (res[i].endTime <= time) {
+        await ctx.model.Vip.updateOne({ _id: res[i]._id }, { endTime: 0, status: '1' });
+      }
+    }
+  },
+};

+ 69 - 0
service-integral/app/service/power.js

@@ -0,0 +1,69 @@
+'use strict';
+
+const assert = require('assert');
+const Service = require('egg').Service;
+class PowerService extends Service {
+  constructor(ctx) {
+    super(ctx);
+    this.model = this.ctx.model.Power;
+  }
+  async create({ vipTab, openid, list }) {
+    assert(list, 'ID列表不存在');
+    assert(openid, 'openid不存在');
+    assert(vipTab, '会员标识不存在');
+    try {
+      const res = await this.model.create({ vipTab, openid, list });
+      return { errcode: 0, errmsg: 'ok', data: res };
+    } catch (error) {
+      throw error;
+    }
+  }
+  async update({ id, vipTab, list }) {
+    assert(id, 'id不存在');
+    try {
+      await this.model.updateOne({ _id: id }, { vipTab, list });
+      return { errcode: 0, errmsg: 'ok', data: '' };
+    } catch (error) {
+      throw error;
+    }
+  }
+  async delete({ id }) {
+    assert(id, 'id不存在');
+    try {
+      await this.model.deleteOne({ _id: id });
+      return { errcode: 0, errmsg: 'ok', data: '' };
+    } catch (error) {
+      throw error;
+    }
+  }
+  async query({ skip, limit, vipTab, openid, list }) {
+    const filter = {};
+    const arr = { vipTab, openid, list };
+    for (const e in arr) {
+      let datas;
+      if (e === 'list') {
+        datas = `{ "${e}": { "$elemMatch": { "$eq": "${arr[e]}" } } }`;
+      } else {
+        datas = `{ "${e}": { "$regex": "${arr[e]}" } }`;
+      }
+      if (arr[e]) {
+        filter.$or = [];
+        filter.$or.push(JSON.parse(datas));
+      }
+    }
+    try {
+      const total = await this.model.find({ ...filter });
+      let res;
+      if (skip && limit) {
+        res = await this.model.find({ ...filter }).skip(Number(skip) * Number(limit)).limit(Number(limit));
+      } else {
+        res = await this.model.find({ ...filter });
+      }
+      return { errcode: 0, errmsg: 'ok', data: res, total: total.length };
+    } catch (error) {
+      throw error;
+    }
+  }
+}
+
+module.exports = PowerService;

+ 92 - 0
service-integral/app/service/vip.js

@@ -0,0 +1,92 @@
+'use strict';
+
+const assert = require('assert');
+const Service = require('egg').Service;
+const moment = require('moment');
+class VipService extends Service {
+  constructor(ctx) {
+    super(ctx);
+    this.model = this.ctx.model.Vip;
+  }
+  async create({ name, thumbnail, phone, company, tab, openid, vipTab }) {
+    assert(name, '昵称不存在');
+    assert(phone, '电话不存在');
+    assert(openid, 'openid不存在');
+    assert(vipTab, '会员标识不存在');
+    const filter = {};
+    const arr = { phone, openid };
+    for (const e in arr) {
+      const data = `{ "${e}": "${arr[e]}" }`;
+      if (arr[e]) {
+        filter.$or = [];
+        filter.$or.push(JSON.parse(data));
+      }
+    }
+    const total = await this.model.find({ ...filter });
+    if (total.length > 0) {
+      return { errcode: -1001, errmsg: '用户手机号或微信已存在' };
+    }
+    try {
+      const startTime = moment().valueOf();
+      const endTime = vipTab === 'svip' ? moment().add(1, 'Y').valueOf() : 0;
+      const res = await this.model.create({ name, thumbnail, phone, company, tab, openid, status: '0', startTime, endTime, vipTab });
+      return { errcode: 0, errmsg: 'ok', data: res };
+    } catch (error) {
+      throw error;
+    }
+  }
+  async update({ id, name, thumbnail, phone, company, tab, status }) {
+    assert(id, 'id不存在');
+    try {
+      await this.model.updateOne({ _id: id }, { name, thumbnail, phone, company, tab, status });
+      return { errcode: 0, errmsg: 'ok', data: '' };
+    } catch (error) {
+      throw error;
+    }
+  }
+  // 续费 修改结束时间
+  async proceed({ id }) {
+    assert(id, 'id不存在');
+    try {
+      const endTime = moment().add(1, 'Y').valueOf();
+      await this.model.updateOne({ _id: id }, { endTime });
+      return { errcode: 0, errmsg: 'ok', data: '' };
+    } catch (error) {
+      throw error;
+    }
+  }
+  async delete({ id }) {
+    assert(id, 'id不存在');
+    try {
+      await this.model.deleteOne({ _id: id });
+      return { errcode: 0, errmsg: 'ok', data: '' };
+    } catch (error) {
+      throw error;
+    }
+  }
+  async query({ skip, limit, name, phone, company, tab, openid, status, startTime, endTime, vipTab }) {
+    const filter = {};
+    const arr = { name, phone, company, tab, openid, status, startTime, endTime, vipTab };
+    for (const e in arr) {
+      const data = `{ "${e}": { "$regex": "${arr[e]}" } }`;
+      if (arr[e]) {
+        filter.$or = [];
+        filter.$or.push(JSON.parse(data));
+      }
+    }
+    try {
+      const total = await this.model.find({ ...filter });
+      let res;
+      if (skip && limit) {
+        res = await this.model.find({ ...filter }).skip(Number(skip) * Number(limit)).limit(Number(limit));
+      } else {
+        res = await this.model.find({ ...filter });
+      }
+      return { errcode: 0, errmsg: 'ok', data: res, total: total.length };
+    } catch (error) {
+      throw error;
+    }
+  }
+}
+
+module.exports = VipService;

+ 14 - 0
service-integral/appveyor.yml

@@ -0,0 +1,14 @@
+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

+ 54 - 0
service-integral/config/config.default.js

@@ -0,0 +1,54 @@
+/* eslint valid-jsdoc: "off" */
+
+'use strict';
+
+/**
+ * @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 + '_1635902541751_9477';
+
+  // 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: 9018,
+    },
+  };
+  // 数据库配置
+  config.mongoose = {
+    url: 'mongodb://127.0.0.1/Microservices',
+    options: {
+      // user: 'root',
+      // pass: 'cms@cc-lotus',
+      // authSource: 'admin',
+      // useNewUrlParser: true,
+      // useCreateIndex: true,
+    },
+  };
+  config.logger = {
+    level: 'DEBUG',
+  };
+  return {
+    ...config,
+    ...userConfig,
+  };
+};

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

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

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

@@ -0,0 +1,17 @@
+'use strict';
+
+const app = 'service-code';
+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', // 环境参数,当前指定为生产环境
+    },
+  }],
+};

+ 5 - 0
service-integral/jsconfig.json

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

+ 48 - 0
service-integral/package.json

@@ -0,0 +1,48 @@
+{
+  "name": "service-integral",
+  "version": "1.0.0",
+  "description": "",
+  "private": true,
+  "egg": {
+    "declarations": true
+  },
+  "dependencies": {
+    "egg": "^2.15.1",
+    "egg-mongoose": "^3.3.1",
+    "egg-scripts": "^2.11.0",
+    "moment": "^2.29.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"
+  },
+  "engines": {
+    "node": ">=10.0.0"
+  },
+  "scripts": {
+    "start": "egg-scripts start --daemon --title=egg-server-service-user",
+    "stop": "egg-scripts stop --title=egg-server-service-user",
+    "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"
+}

+ 9 - 0
service-integral/server.js

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

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

@@ -0,0 +1,20 @@
+'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);
+  });
+});