Commit ef1a1e5c by 胡悦

first

1 parent 91cdcec0
# 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
sudo: false
language: node_js language: node_js
node_js: node_js:
- '10' - '10'
......
/*
* @Author: huyue
* @Date: 2020-06-15 11:10:54
* @Last Modified by: huyue
* @Last Modified time: 2020-08-24 16:04:13
*/
"use strict";
const Controller = require("egg").Controller;
/**
* @Controller biz/project
* @Description 配置文件
*/
class projectController extends Controller {
constructor(ctx) {
super(ctx);
this.validate = ctx.app.validate.validate;
this.request = ctx.request;
this.helper = ctx.helper;
this.redis = ctx.app.redis;
this.projectService = ctx.service.biz.project;
// this.CacheService = ctx.service.cache; //redis 缓存服务
this.ServerResponseCode = ctx.response.ServerResponseCode;
this.ServerResponse = ctx.response.ServerResponse;
}
/**
* @summary 查询配置文件列表
* @Router POST /biz/project/findAll
* @Description 查询商机明细
* @Request pager
* @Request searcher
* @Response 200 response ok
*/
async findAll({ request: { body: { pager, searcher } } }) { //get : async findAll( {query: { pager, searcher } })
const result = await this.projectService.findAll({ pager, searcher });
this.ctx.body = this.ServerResponse.Success(result);
}
}
module.exports = projectController;
\ No newline at end of file \ No newline at end of file
/* indent size: 2 */
module.exports = app => {
const DataTypes = app.Sequelize;
const Model = app.model.define('glsx_web_project', {
id: {
type: DataTypes.INTEGER(11),
allowNull: false,
primaryKey: true
},
project_name: {
type: DataTypes.STRING(255),
allowNull: false
},
project_url: {
type: DataTypes.STRING(255),
allowNull: false
},
create_name: {
type: DataTypes.STRING(255),
allowNull: false
},
create_date: {
type: DataTypes.DATE,
allowNull: false
},
update_date: {
type: DataTypes.DATE,
allowNull: false
}
}, {
tableName: 'glsx_web_project'
});
Model.associate = function() {
}
return Model;
};
/* /*
* @Author: limin * @Author: limin
* @Date: 2019-11-21 11:19:15 * @Date: 2019-11-21 11:19:15
* @Last Modified by: chenwq * @Last Modified by: huyue
* @Last Modified time: 2020-06-19 11:45:09 * @Last Modified time: 2020-08-24 15:58:44
*/ */
module.exports = (app) => { module.exports = (app) => {
...@@ -17,4 +17,5 @@ module.exports = (app) => { ...@@ -17,4 +17,5 @@ module.exports = (app) => {
app.router.get("/biz/clues/findAll", app.controller.biz.clues.findAll); app.router.get("/biz/clues/findAll", app.controller.biz.clues.findAll);
app.router.get("/biz/opportunity/findAll", app.controller.biz.opportunity.findAll); app.router.get("/biz/opportunity/findAll", app.controller.biz.opportunity.findAll);
app.router.get("/biz/opportunity/findCount", app.controller.biz.opportunity.findCount); app.router.get("/biz/opportunity/findCount", app.controller.biz.opportunity.findCount);
app.router.get("/biz/project/findAll", app.controller.biz.project.findAll);
}; };
/*
* @Author: huyue
* @Date: 2020-06-15 10:57:33
* @Last Modified by: huyue
* @Last Modified time: 2020-08-24 16:08:40
*/
const Service = require("egg").Service
class ProjectService extends Service {
constructor(ctx) {
super(ctx)
this.helper = ctx.helper
this._reg_models_alias_()
}
/**
* 绑定model 在 this 上的 别名
*/
_reg_models_alias_() {
const {
GlsxWebProject
} = this.app.model.Biz;
this.MGWP = GlsxWebProject;
}
/**
* 绑定表关系
*/
_associate_() {}
/**
* @param field {String}
* @param value {String}
* @return {Promise.<boolean>}
* @Description 查询所有
*/
async findAll({
pager = {},
searcher = {}
}) {
const {
current = 1, size = 10
} = pager
const {
projectName
} = searcher
const offset = (current - 1) * size
const {
Op,
col
} = this.app.Sequelize
let where = {}
if (projectName) {
where.project_name = projectName
}
return await this.MGWP.findAndCountAll({
offset,
limint: +size,
where,
raw: true
})
}
}
module.exports = ProjectService;
\ No newline at end of file \ No newline at end of file
/* /*
* @Author: limin * @Author: limin
* @Date: 2019-11-16 09:26:53 * @Date: 2019-11-16 09:26:53
* @Last Modified by: chenwq * @Last Modified by: huyue
* @Last Modified time: 2020-06-18 14:13:05 * @Last Modified time: 2020-09-01 15:13:57
*/ */
/* eslint valid-jsdoc: "off" */ /* eslint valid-jsdoc: "off" */
"use strict"; 'use strict'
/** /**
* @param {Egg.EggAppInfo} app app info * @param {Egg.EggAppInfo} app app info
...@@ -17,82 +17,89 @@ module.exports = app => { ...@@ -17,82 +17,89 @@ module.exports = app => {
* built-in config * built-in config
* @type {Egg.EggAppConfig} * @type {Egg.EggAppConfig}
**/ **/
const config = (exports = {}); const config = (exports = {})
// use for cookie sign key, should change to your own and keep security // use for cookie sign key, should change to your own and keep security
config.keys = app.name + "_1573615133248_6253"; config.keys = app.name + '_1573615133248_6253'
// add your middleware config here // add your middleware config here
// config.middleware = [ 'errorHandler']; // config.middleware = [ 'errorHandler']
config.onerror = { config.onerror = {
//全局异常捕获 // 全局异常捕获
all(err, ctx) { all(err, ctx) {
// 在此处定义针对所有响应类型的错误处理方法 // 在此处定义针对所有响应类型的错误处理方法
// 注意,定义了 config.all 之后,其他错误处理方法不会再生效 // 注意,定义了 config.all 之后,其他错误处理方法不会再生效
// 所有的异常都在 app 上触发一个 error 事件,框架会记录一条错误日志 // 所有的异常都在 app 上触发一个 error 事件,框架会记录一条错误日志
ctx.app.emit("error", err, ctx); ctx.app.emit('error', err, ctx)
const status = err.status || 500; const status = err.status || 500
// 生产环境时 500 错误的详细错误内容不返回给客户端,因为可能包含敏感信息 // 生产环境时 500 错误的详细错误内容不返回给客户端,因为可能包含敏感信息
const error = const error =
status === 500 && ctx.app.config.env === "prod" status === 500 && ctx.app.config.env === 'prod'
? "Internal Server Error" ? 'Internal Server Error'
: err.message; : err.message
// 从 error 对象上读出各个属性,设置到响应中 // 从 error 对象上读出各个属性,设置到响应中
ctx.body = JSON.stringify( ctx.body = JSON.stringify(
ctx.response.ServerResponse.Error({ message: error }) ctx.response.ServerResponse.Error({ message: error })
); )
if (status === 422) { if (status === 422) {
ctx.body.detail = err.errors; ctx.body.detail = err.errors
} }
ctx.status = status; ctx.status = status
} }
// html(err, ctx) { // html(err, ctx) {
// // html hander // // html hander
// ctx.body = '<h3>error</h3>'; // ctx.body = '<h3>error</h3>'
// ctx.status = 500; // ctx.status = 500
// }, // },
// json(err, ctx) { // json(err, ctx) {
// // json hander // // json hander
// ctx.body = { message: 'error' }; // ctx.body = { message: 'error' }
// ctx.status = 500; // ctx.status = 500
// }, // },
// jsonp(err, ctx) { // jsonp(err, ctx) {
// // 一般来说,不需要特殊针对 jsonp 进行错误定义,jsonp 的错误处理会自动调用 json 错误处理,并包装成 jsonp 的响应格式 // // 一般来说,不需要特殊针对 jsonp 进行错误定义,jsonp 的错误处理会自动调用 json 错误处理,并包装成 jsonp 的响应格式
// }, // },
}; }
// add your user config here // add your user config here
// const userConfig = { // const userConfig = {
config.jwt = { config.jwt = {
secret: "glsx-insurence-egg-server" //自定义 token 的加密条件字符串 secret: 'glsx-insurence-egg-server' // 自定义 token 的加密条件字符串
}; }
config.cors = { config.cors = {
// origin: "http://192.168.2.222:8085", // origin: "http://192.168.2.222:8085",
credentials: true, credentials: true,
allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH' allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH'
}; }
config.security = { config.security = {
csrf: { csrf: {
enable: false, enable: false,
ignoreJSON: true ignoreJSON: true
}, },
// domainWhiteList: ["http://192.168.2.222:8085"] //允许访问接口的白名单 // domainWhiteList: ["http://192.168.2.222:8085"] //允许访问接口的白名单
domainWhiteList: ["http://localhost:8085", "http://192.168.2.201:8085", "http://192.168.2.27:8085"] //允许访问接口的白名单 domainWhiteList: ['http://localhost:8080', 'http://192.168.2.201:8085', 'http://192.168.2.27:8085'] // 允许访问接口的白名单
}; }
config.redis = { config.redis = {
client: { client: {
port: 6379, // Redis port port: 6379, // Redis port
host: "127.0.0.1", // Redis host host: '127.0.0.1', // Redis host
password: "", password: '',
db: 0 db: 0
} }
}; }
config.cluster = {
listen: {
path: '',
port: 7002,
hostname: '0.0.0.0'
}
}
config.validate = { config.validate = {
// convert: false, // convert: false,
// validateRoot: false, // validateRoot: false,
}; }
config.sequelize = { config.sequelize = {
timezone: '+08:00', timezone: '+08:00',
define: { define: {
...@@ -101,26 +108,26 @@ module.exports = app => { ...@@ -101,26 +108,26 @@ module.exports = app => {
timestamps: false // 不自动维护时间戳 [ created_at、updated_at ] timestamps: false // 不自动维护时间戳 [ created_at、updated_at ]
}, },
dialectOptions: { dialectOptions: {
dateStrings: true, //格式化datetime dateStrings: true, // 格式化datetime
typeCast: true typeCast: true
} }
}; }
config.swaggerdoc = { config.swaggerdoc = {
dirScanner: "./app/controller", dirScanner: './app/controller',
apiInfo: { apiInfo: {
title: "广联运营", title: '广联运营',
description: "swagger-ui for egg", description: 'swagger-ui for egg',
version: "1.0.0" version: '1.0.0'
}, },
schemes: ["http", "https"], schemes: ['http', 'https'],
consumes: ["application/json"], consumes: ['application/json'],
produces: ["application/json"], produces: ['application/json'],
securityDefinitions: {}, securityDefinitions: {},
enableSecurity: false, enableSecurity: false,
// enableValidate: true, // enableValidate: true,
routerMap: true, routerMap: true,
enable: true enable: true
}; }
return config; return config
}; }
/* /*
* @Author: limin * @Author: limin
* @Date: 2019-11-16 09:26:47 * @Date: 2019-11-16 09:26:47
* @Last Modified by: limin * @Last Modified by: huyue
* @Last Modified time: 2020-04-15 10:59:34 * @Last Modified time: 2020-08-24 10:04:28
*/ */
/* eslint valid-jsdoc: "off" */ /* eslint valid-jsdoc: "off" */
...@@ -27,10 +27,10 @@ module.exports = appInfo => { ...@@ -27,10 +27,10 @@ module.exports = appInfo => {
// myAppName: 'egg', // myAppName: 'egg',
config.sequelize = { config.sequelize = {
dialect: "mysql", dialect: "mysql",
host: "192.168.3.153", host: "192.168.0.39",
port: "3308", port: "3306",
database: "glsx_audit", database: "qd_config",
username: "apuser", username: "root",
password: "123456" password: "123456"
}; };
return config; return config;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!