This commit is contained in:
啊平 2021-01-26 18:43:31 +08:00
parent d942aacccb
commit 0f0890e210
6 changed files with 63 additions and 9 deletions

15
Dockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM node:12
WORKDIR /home
COPY . .
# 如果各公司有自己的私有源可以替换registry地址
RUN yarn
RUN yarn build
# 如果端口更换,这边可以更新一下
EXPOSE 7001
CMD ["npm", "run", "start"]

View File

@ -7,6 +7,7 @@
"@midwayjs/decorator": "^2.3.0",
"@midwayjs/orm": "^1.3.0",
"@midwayjs/web": "^2.3.0",
"axios": "^0.21.1",
"egg": "^2.0.0",
"egg-scripts": "^2.10.0",
"mysql": "^2.18.1"
@ -27,10 +28,10 @@
"node": ">=12.0.0"
},
"scripts": {
"start": "egg-scripts start --daemon --title=midway-server-my_midway_project --framework=@midwayjs/web",
"start": "egg-scripts start --title=midway-server-my_midway_project --framework=@midwayjs/web",
"stop": "egg-scripts stop --title=midway-server-my_midway_project",
"start_build": "npm run build && cross-env NODE_ENV=development midway-bin dev",
"dev": "cross-env ets && cross-env NODE_ENV=local midway-bin dev --ts",
"dev": "cross-env ets && cross-env NODE_ENV=local TS_NODE_TYPE_CHECK=false TS_NODE_TRANSPILE_ONLY=true midway-bin dev --ts --port=8001",
"test": "midway-bin test",
"cov": "midway-bin cov",
"lint": "mwts check",

View File

@ -7,10 +7,10 @@ export default (appInfo: EggAppInfo) => {
config.orm = {
type: 'mysql',
host: '127.0.0.1',
host: '139.196.196.203',
port: 3306,
username: 'root',
password: '123123',
username: 'midway',
password: 'Yxd8mJYE4p8BytHF',
database: 'midway',
synchronize: true,
logging: false,

View File

@ -4,6 +4,7 @@ import { UserService } from '../service/user';
import { Repository } from 'typeorm';
import { User } from '../model/user';
import { InjectEntityModel } from '@midwayjs/orm';
import axios from 'axios';
@Provide()
@Controller('/api')
@ -19,10 +20,24 @@ export class APIController {
@Get('/get_user')
async getUser(@Query() uid) {
const user = await this.userService.getUser({ uid });
// const user = await this.userService.getUser({ uid });
console.log(await this.userModel.findOne({id: 1}))
// console.log(await this.userModel.findOne({id: 1}))
return { success: true, message: 'OK', data: user };
// const result = await axios.get('https://docs-admin-cloud.cool-js.com/api/get_user?uid=1')
let index = 0;
while(true){
try {
index++;
const startTime = Date.now();
const result = await axios.get('https://m.cool-js.com/api/get_user?uid=1')
console.log(index,'请求时间', Date.now() - startTime, result.data);
} catch (error) {
console.log(6666666666666666666666666666666666666666)
continue;
}
}
// return { success: true, message: 'OK', data: {uid, a: result.data} };
}
}

View File

@ -8,7 +8,6 @@ export class ReportMiddleware implements IWebMiddleware {
resolve() {
return async (ctx: Context, next: IMidwayWebNext) => {
const startTime = Date.now();
console.log(666)
await next();
console.log('请求时间', Date.now() - startTime);
};

24
src/model/sys/role.ts Normal file
View File

@ -0,0 +1,24 @@
import { EntityModel } from '@midwayjs/orm';
import { Column, Index } from 'typeorm';
import { BaseModel } from '@midwayjs/cool-core';
/**
*
*/
@EntityModel('sys_role')
export class SysRole extends BaseModel{
// 名称
@Column()
userId: string;
// 名称
@Index({ unique: true })
@Column()
name: string;
// 角色标签
@Index({ unique: true })
@Column({ nullable: true, length: 50 })
label: string;
// 备注
@Column({ nullable: true })
remark: string;
}