mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2025-12-15 03:42:51 +00:00
111
This commit is contained in:
parent
d942aacccb
commit
0f0890e210
15
Dockerfile
Normal file
15
Dockerfile
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
FROM node:12
|
||||||
|
|
||||||
|
WORKDIR /home
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# 如果各公司有自己的私有源,可以替换registry地址
|
||||||
|
RUN yarn
|
||||||
|
|
||||||
|
RUN yarn build
|
||||||
|
|
||||||
|
# 如果端口更换,这边可以更新一下
|
||||||
|
EXPOSE 7001
|
||||||
|
|
||||||
|
CMD ["npm", "run", "start"]
|
||||||
@ -7,6 +7,7 @@
|
|||||||
"@midwayjs/decorator": "^2.3.0",
|
"@midwayjs/decorator": "^2.3.0",
|
||||||
"@midwayjs/orm": "^1.3.0",
|
"@midwayjs/orm": "^1.3.0",
|
||||||
"@midwayjs/web": "^2.3.0",
|
"@midwayjs/web": "^2.3.0",
|
||||||
|
"axios": "^0.21.1",
|
||||||
"egg": "^2.0.0",
|
"egg": "^2.0.0",
|
||||||
"egg-scripts": "^2.10.0",
|
"egg-scripts": "^2.10.0",
|
||||||
"mysql": "^2.18.1"
|
"mysql": "^2.18.1"
|
||||||
@ -27,10 +28,10 @@
|
|||||||
"node": ">=12.0.0"
|
"node": ">=12.0.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"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",
|
"stop": "egg-scripts stop --title=midway-server-my_midway_project",
|
||||||
"start_build": "npm run build && cross-env NODE_ENV=development midway-bin dev",
|
"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",
|
"test": "midway-bin test",
|
||||||
"cov": "midway-bin cov",
|
"cov": "midway-bin cov",
|
||||||
"lint": "mwts check",
|
"lint": "mwts check",
|
||||||
|
|||||||
@ -7,10 +7,10 @@ export default (appInfo: EggAppInfo) => {
|
|||||||
|
|
||||||
config.orm = {
|
config.orm = {
|
||||||
type: 'mysql',
|
type: 'mysql',
|
||||||
host: '127.0.0.1',
|
host: '139.196.196.203',
|
||||||
port: 3306,
|
port: 3306,
|
||||||
username: 'root',
|
username: 'midway',
|
||||||
password: '123123',
|
password: 'Yxd8mJYE4p8BytHF',
|
||||||
database: 'midway',
|
database: 'midway',
|
||||||
synchronize: true,
|
synchronize: true,
|
||||||
logging: false,
|
logging: false,
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import { UserService } from '../service/user';
|
|||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
import { User } from '../model/user';
|
import { User } from '../model/user';
|
||||||
import { InjectEntityModel } from '@midwayjs/orm';
|
import { InjectEntityModel } from '@midwayjs/orm';
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
@Provide()
|
@Provide()
|
||||||
@Controller('/api')
|
@Controller('/api')
|
||||||
@ -19,10 +20,24 @@ export class APIController {
|
|||||||
|
|
||||||
@Get('/get_user')
|
@Get('/get_user')
|
||||||
async getUser(@Query() uid) {
|
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} };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,6 @@ export class ReportMiddleware implements IWebMiddleware {
|
|||||||
resolve() {
|
resolve() {
|
||||||
return async (ctx: Context, next: IMidwayWebNext) => {
|
return async (ctx: Context, next: IMidwayWebNext) => {
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
console.log(666)
|
|
||||||
await next();
|
await next();
|
||||||
console.log('请求时间', Date.now() - startTime);
|
console.log('请求时间', Date.now() - startTime);
|
||||||
};
|
};
|
||||||
|
|||||||
24
src/model/sys/role.ts
Normal file
24
src/model/sys/role.ts
Normal 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;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user