lrf402788946 4 vuotta sitten
commit
0af7de990e

+ 29 - 0
.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
.eslintignore

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

+ 3 - 0
.eslintrc

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

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

@@ -0,0 +1,42 @@
+# 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 ]
+  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 }}

+ 14 - 0
.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
.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
README.md

@@ -0,0 +1,33 @@
+# service-achive
+
+成果评价系统-服务端
+
+## 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

+ 12 - 0
app/controller/home.js

@@ -0,0 +1,12 @@
+'use strict';
+
+const Controller = require('egg').Controller;
+
+class HomeController extends Controller {
+  async index() {
+    const { ctx } = this;
+    ctx.body = 'hi, egg';
+  }
+}
+
+module.exports = HomeController;

+ 89 - 0
app/model/achieve_apply.js

@@ -0,0 +1,89 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const moment = require('moment');
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+// 基本信息
+const base = new Schema({
+  achieve_name: { type: String }, // 成果名称
+  achieve_type: { type: String }, // 成果类别
+  achieve_num: { type: String }, // 成果编号
+  achieve_date: { type: String }, // 成果取得时间
+  achieve_form: { type: String }, // 成果形式
+  apply_personal: { type: String }, // 申请人
+  apply_company: { type: String }, // 申请单位
+  address: { type: String }, // 地址
+  apply_nature: { type: String }, // 申请单位/申请人属性
+  contacts: { type: String }, // 联系人
+  phone: { type: String }, // 联系电话
+  email: { type: String }, // 邮箱
+  fax: { type: String }, // 传真
+  objective: { type: String }, // 评价目的
+  stage: { type: String }, // 成果所处阶段
+  output: { type: String }, // 经济效益产值
+  profit: { type: String }, // 经济效益利润
+  revenue: { type: String }, // 经济效益税收
+});
+base.index({ id: 1 });
+// 内容简介
+const brief = new Schema({
+  achieve_brief: { type: String }, // 成果简介
+  field: { type: String }, // 应用领域和技术原理
+  kpi_index: { type: String }, // 性能指标
+  revenue: { type: String }, // 经济效益税收
+  compare: { type: String }, // 与国内外同类技术比较
+  advanced: { type: String }, // 成果的创造性,先进性
+  sense: { type: String }, // 作用意义
+  prospect: { type: String }, // 推广应用的范围,条件和前景
+  opinion: { type: String }, // 存在的问题和改进意见
+});
+
+brief.index({ id: 1 });
+// 主研人员名单
+const research = new Schema({
+  research_name: { type: String }, // 姓名
+  card: { type: String }, // 证件号码
+  gender: { type: String }, // 性别
+  position: { type: String }, // 技术职称
+  education: { type: String }, // 文化程度
+  degree: { type: String }, // 学位
+  abroad: { type: String }, // 是否留学归国
+  research_company: { type: String }, // 工作单位
+  devote: { type: String }, // 对成果创造性贡献
+});
+research.index({ id: 1 });
+// 委托方提供资料清单
+const datalist = new Schema({
+  work_report: { type: String, required: true }, // 研究工作报告(必备)
+  techol_report: { type: String, required: true }, // 研究技术报告(必备)
+  benefit: { type: String, required: true }, // 经济效益分析(必备)
+  science_report: { type: String, required: true }, // 科技查新报告(科技项目成果,必备)
+  assess_report: { type: String, required: true }, // 法律价值评估报告(专利成果,必备)
+  app_prove: { type: String, required: true }, // 推广应用证明(两家以上应用单位,必备)
+  techol_ppt: { type: String, required: true }, // 成果技术汇报PPT(必备)
+  testing_report: { type: String }, // 检测报告(根据项目需要提供)
+  quality: { type: String }, // 质量标准(检测报告所依据的标准,企业标准,行业标准,国家标准,国际标准)
+  patent: { type: String }, // 与本成果相关的授权专利证书
+  special: { type: String }, // 特殊行业需要提供的相应证明材料
+  budget: { type: String }, // 项目经费预算书
+  final: { type: String }, // 项目经费决算书
+});
+
+datalist.index({ id: 1 });
+
+// 成果评价申请表
+const achieve_apply = {
+  basic: { type: base },
+  brief: { type: brief },
+  research: { type: [ research ] },
+  datalist: { type: datalist },
+  remark: { type: String, maxLength: 200 },
+  create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
+};
+const schema = new Schema(achieve_apply, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Achieve_apply', schema, 'achieve_apply');
+};

+ 9 - 0
app/router.js

@@ -0,0 +1,9 @@
+'use strict';
+
+/**
+ * @param {Egg.Application} app - egg application
+ */
+module.exports = app => {
+  const { router, controller } = app;
+  router.get('/', controller.home.index);
+};

+ 14 - 0
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

+ 67 - 0
config/config.default.js

@@ -0,0 +1,67 @@
+/* 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 + '_1615359726812_6846';
+
+  // add your middleware config here
+  config.middleware = [];
+
+  // add your user config here
+  const userConfig = {
+    // myAppName: 'egg',
+  };
+  config.cluster = {
+    listen: {
+      port: 9102,
+    },
+  };
+
+  config.dbName = 'platform';
+  config.mongoose = {
+    url: `mongodb://localhost:27017/${config.dbName}`,
+    options: {
+      // user: 'admin',
+      // pass: '111111',
+      // authSource: 'admin',
+      // useNewUrlParser: true,
+      // useCreateIndex: true,
+    },
+  };
+
+  config.amqp = {
+    client: {
+      hostname: '127.0.0.1',
+      username: 'visit',
+      password: 'visit',
+      vhost: 'platform',
+    },
+    app: true,
+    agent: true,
+  };
+
+  config.redis = {
+    client: {
+      port: 6379, // Redis port
+      host: '127.0.0.1', // Redis host
+      password: 123456,
+      db: 1,
+    },
+  };
+
+  return {
+    ...config,
+    ...userConfig,
+  };
+};

+ 9 - 0
config/plugin.js

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

+ 52 - 0
package.json

@@ -0,0 +1,52 @@
+{
+  "name": "service-achieve",
+  "version": "1.0.0",
+  "description": "成果评价系统-服务端",
+  "private": true,
+  "egg": {
+    "framework": "naf-framework-mongoose"
+  },
+  "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"
+  },
+  "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",
+    "jsonwebtoken": "^8.5.1"
+  },
+  "engines": {
+    "node": ">=10.0.0"
+  },
+  "scripts": {
+    "start": "egg-scripts start --daemon --title=egg-server-service-achive",
+    "stop": "egg-scripts stop --title=egg-server-service-achive",
+    "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": "lrf",
+  "license": "MIT"
+}

+ 20 - 0
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);
+  });
+});