Skip to content

Commit e2b5acb

Browse files
wanghaowanghao
authored andcommitted
添加文件上传对比
1 parent be2ae3b commit e2b5acb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+14729
-159
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# dfs-ums-server
2+
3+
14
## 前序准备
25

36
你需要在本地安装 [node](http://nodejs.org/)[egg-reids](https://github.com/eggjs/egg-redis)在Base.ts内配置redis连接。本项目技术栈基于 [typescript](https://www.typescriptlang.org/)[限流](https://github.com/koajs/ratelimit)[BullMQ](https://github.com/OptimalBits/bull#uis)[HyperLogLog](https://juejin.im/post/6844904097666039816)[redis分布式锁](https://redis.io/)[Joi](https://hapi.dev/module/joi/)(egg-Joi配置相对繁琐,项目是自己封装的) 和 [egg-typeorm](https://github.com/eggjs/egg-redis),[自动路由扫描:egg-router-util]
@@ -49,4 +52,16 @@ $ open http://127.0.0.1:9090/
4952
```bash
5053
$ npm run tsc
5154
$ npm start
52-
```
55+
```
56+
57+
egg-ts-typeorm 连接mongo在connect.js内修改源码
58+
for(let e of n){
59+
if(e.options.type=="mysql"){
60+
const o=await e.manager.query("select 1 + 1 as result");
61+
o&&o.length&&2==+o[0].result&&t.logger.info(`[egg-typeorm] connection ${e.name} is ready`)
62+
}
63+
if(e.options.type=="mongodb"){
64+
t.logger.info(`[egg-typeorm] connection ${e.name} is ready`)
65+
}
66+
67+
}};

app/config/StaticStr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class StaticStr {
7373
/**
7474
* 注册错误提示
7575
*/
76-
public static INSERT_ERR_MSG = "用户已存在";
76+
public static INSERT_ERR_MSG = "名称已存在";
7777
/**
7878
* 获取等级贡献配置表ervice
7979
*/

app/config/base.ts

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,35 @@
55
*/
66

77
export class BaseConfig {
8-
/**
9-
* 服务器端口配置
10-
*/
8+
/**
9+
* 服务器端口配置
10+
*/
1111
public static PORT = 9090;
12-
/**
13-
* redis配置
14-
*/
12+
public static SERVE_HOST = "192.168.12.245";
13+
/**
14+
* redis配置
15+
*/
1516
// public static REDIS_HOST = "";
1617
public static REDIS_HOST = "127.0.0.1";
17-
/**
18-
* redis端口配置
19-
*/
18+
/**
19+
* redis端口配置
20+
*/
2021
public static REDIS_PORT = 6379;
21-
/**
22-
* redis密码配置(需要在redisTool打开注释)
23-
*/
22+
/**
23+
* redis密码配置(需要在redisTool打开注释)
24+
*/
2425
public static REDIS_PASSWORD = "123456";
25-
/**
26-
* redis db配置(项目使用)
27-
*/
26+
/**
27+
* redis db配置(项目使用)
28+
*/
2829
public static SYSTEM_DB = 1;
29-
/**
30-
* redis db配置(MQ使用)
31-
*/
30+
/**
31+
* redis db配置(MQ使用)
32+
*/
3233
public static BULLMQ_DB = 2;
33-
/**
34+
/**
3435
* token验证白名单Url
35-
*/
36+
*/
3637
public static OPEN_URL = [
3738
"/auth/login",
3839
"/auth/insert",
@@ -47,23 +48,24 @@ export class BaseConfig {
4748
* 文件URL
4849
*/
4950
public static OPEN_FILE_URL = "/common/download";
50-
/**
51+
/**
5152
* 记录日志Urld对应的记录名称
52-
*/
53-
public static LOG_URL:any = {
53+
*/
54+
public static LOG_URL: any = {
5455
"/auth/user": "用户",
5556
"/auth/Mod": "模块",
5657
"/auth/role": "角色",
5758
"/game/game": "游戏",
59+
"/cfg/cfg": "配置文件",
5860
};
5961
/**
6062
* 这里处理特殊返回没有状态码的Url地址打印时显示正常
6163
*/
62-
public static OPEN_LOG_URL ="/auth/captchaCode";
64+
public static OPEN_LOG_URL = "/auth/captchaCode";
6365
/**
6466
* 1
6567
*/
66-
public static OPEN_LOG_URL1 ="/common/download/";
68+
public static OPEN_LOG_URL1 = "/common/download/";
6769
/**
6870
* 新注册玩家默认权限id
6971
*/

app/config/environments.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { ConnectionOptions } from "typeorm";
1+
import { ConnectionOptions} from "typeorm";
22
/**
33
* Created by wh on 2020/7/15
44
* author: wanghao
55
* @desc:数据库配置文件(utils>database文件内切换程序数据库)
66
*/
77
export const mysqlConfig: ConnectionOptions = {
8-
"name": "default",
8+
"name": "mysql",
99
"type": "mysql",
10-
"host": "0.0.0.0",
10+
"host": "148.70.34.67",
1111
"port": 3307,
1212
"username": "root",
1313
"password": "123456",
1414
"database": "test",
15-
"logging": true,
15+
logging: false,
1616
// synchronize: true,
1717
"timezone": "+08:00",
1818
"dateStrings": true,
@@ -21,16 +21,9 @@ export const mysqlConfig: ConnectionOptions = {
2121
export const mongodbConfig: ConnectionOptions = {
2222
"name": "mongodb",
2323
"type": "mongodb",
24-
"host": "0.0.0.0",
24+
"host": "148.70.34.67",
2525
"port": 27017,
2626
"database": "test",
27-
"useUnifiedTopology": true,
28-
"entities": ["src/entity/mongo/*.ts"],
29-
// "subscribers": ["src/subscriber/*.ts"],
30-
// "migrations": ["src/migration/*.ts"],
31-
"cli": {
32-
"entitiesDir": "src/entity/mongo",
33-
"migrationsDir": "src/migration",
34-
"subscribersDir": "src/subscriber",
35-
},
36-
};
27+
"entities": ["app/entity/mongo/*.ts"],
28+
29+
};

app/controller/AuthController.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import { Controller } from 'egg';
77
import { Paging } from "../format/Type";
88
import { Validate } from "../utils/ReqValidate";
99
import { ReturnResult } from "../utils/ReturnResult";
10-
import { BaseMod } from "../entity/mysql/auth/BaseMod";
11-
import { BaseRole } from "../entity/mysql/auth/BaseRole";
12-
import { BaseUser } from "../entity/mysql/auth/BaseUser";
10+
import BaseMod from "../entity/mysql/auth/BaseMod";
11+
import BaseRole from "../entity/mysql/auth/BaseRole";
12+
import BaseUser from "../entity/mysql/auth/BaseUser";
1313

1414
/**
1515
* Created by wh on 2020/7/15
@@ -206,9 +206,9 @@ export default class AuthController extends Controller {
206206
await Validate.verifyAuth(ctx, "Mod");
207207
const mod: BaseMod = ctx.params;
208208
mod.updatedBy = ctx.user.id;
209-
const users = await this.service.accountService.updateMod(mod);
209+
const data = await this.service.accountService.updateMod(mod);
210210

211-
return ctx.body = ReturnResult.successData(users);
211+
return ctx.body = ReturnResult.successData(data);
212212
}
213213
/**
214214
* 查询模块
@@ -246,9 +246,9 @@ export default class AuthController extends Controller {
246246
public async roles() {
247247
const { ctx } = this;
248248
await Validate.verifyAuth(ctx, "role");
249-
const users = await this.service.accountService.roles();
249+
const data = await this.service.accountService.roles();
250250

251-
return ctx.body = ReturnResult.successData(users);
251+
return ctx.body = ReturnResult.successData(data);
252252
}
253253
/**
254254
* 获取角色页面
@@ -260,9 +260,9 @@ export default class AuthController extends Controller {
260260
await Validate.verifyAuth(ctx, "role");
261261
const paging: Paging = ctx.params;
262262
paging.condition = JSON.parse(paging.condition);
263-
const users = await this.service.accountService.rolesPage(paging);
263+
const data = await this.service.accountService.rolesPage(paging);
264264

265-
return ctx.body = ReturnResult.successData(users);
265+
return ctx.body = ReturnResult.successData(data);
266266
}
267267
/**
268268
* 创建角色列表
@@ -274,9 +274,9 @@ export default class AuthController extends Controller {
274274
await Validate.verifyAuth(ctx, "role");
275275
const role: BaseRole = ctx.params;
276276
role.createdBy = ctx.user.id;
277-
const users = await this.service.accountService.createRole(role);
277+
const data = await this.service.accountService.createRole(role);
278278

279-
return ctx.body = ReturnResult.successData(users);
279+
return ctx.body = ReturnResult.successData(data);
280280
}
281281
/**
282282
* 删除角色列表
@@ -287,9 +287,9 @@ export default class AuthController extends Controller {
287287
const { ctx } = this;
288288
await Validate.verifyAuth(ctx, "role");
289289
const role: BaseRole = ctx.params;
290-
const users = await this.service.accountService.delectRole(role);
290+
const data = await this.service.accountService.delectRole(role);
291291

292-
return ctx.body = ReturnResult.successData(users);
292+
return ctx.body = ReturnResult.successData(data);
293293
}
294294
/**
295295
* 修改角色列表
@@ -301,9 +301,9 @@ export default class AuthController extends Controller {
301301
await Validate.verifyAuth(ctx, "role");
302302
const role: BaseRole = ctx.params;
303303
role.updatedBy = ctx.user.id;
304-
const users = await this.service.accountService.updateRole(role);
304+
const data = await this.service.accountService.updateRole(role);
305305

306-
return ctx.body = ReturnResult.successData(users);
306+
return ctx.body = ReturnResult.successData(data);
307307
}
308308
/**
309309
* 获取角色详情模块列表
@@ -315,9 +315,9 @@ export default class AuthController extends Controller {
315315
await Validate.verifyAuth(ctx, "role");
316316
const role: BaseRole = ctx.params;
317317
Validate.isId(role.id);
318-
const users = await this.service.accountService.roleMods(role);
318+
const data = await this.service.accountService.roleMods(role);
319319

320-
return ctx.body = ReturnResult.successData(users);
320+
return ctx.body = ReturnResult.successData(data);
321321
}
322322
/**
323323
* 获取系统操作日志
@@ -329,8 +329,8 @@ export default class AuthController extends Controller {
329329
const paging: Paging = ctx.params;
330330
Validate.isNumber(paging.page);
331331
paging.condition = JSON.parse(paging.condition);
332-
const users = await this.service.accountService.systemLog(paging);
332+
const data = await this.service.accountService.systemLog(paging);
333333

334-
return ctx.body = ReturnResult.successData(users);
334+
return ctx.body = ReturnResult.successData(data);
335335
}
336336
}

app/controller/CfgController.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
2+
3+
import { Delete, Get, Post, Prefix, Put } from 'egg-router-util';
4+
5+
import { Context, Controller } from 'egg';
6+
7+
import { Validate } from "../utils/ReqValidate";
8+
import { ReturnResult } from "../utils/ReturnResult";
9+
import Cfg from '../entity/mongo/Cfg';
10+
11+
/**
12+
* Created by wh on 2020/7/15
13+
* author: wanghao
14+
* @desc:配置Controllers
15+
*/
16+
@Prefix('/cfg')
17+
export default class GameController extends Controller {
18+
19+
/**
20+
* 获取列表
21+
* @param ctx koa中间件
22+
*/
23+
@Get("/cfg")
24+
public async getCfgs(ctx: Context) {
25+
await Validate.verifyAuth(ctx, "cfg");
26+
27+
const data = await this.service.cfgService.getCfgs();
28+
29+
return ctx.body = ReturnResult.successData(data);
30+
}
31+
/**
32+
* 获取列表
33+
* @param ctx koa中间件
34+
*/
35+
@Get("/cfgByCfgId")
36+
public async cfgByCfgId(ctx: Context) {
37+
await Validate.verifyAuth(ctx, "cfg");
38+
const cfg: Cfg = ctx.params;
39+
const data = await this.service.cfgService.cfgByCfgId(cfg);
40+
41+
return ctx.body = ReturnResult.successData(data);
42+
}
43+
/**
44+
* 新增
45+
* @param ctx koa中间件
46+
*/
47+
@Post("/cfg")
48+
public async createCfg(ctx: Context) {
49+
await Validate.verifyAuth(ctx, "cfg");
50+
const cfg: Cfg = ctx.params;
51+
Validate.isFlexValid(cfg.gameId);
52+
cfg.createdBy = ctx.user.id;
53+
const data = await this.service.cfgService.createCfg(cfg);
54+
55+
return ctx.body = ReturnResult.successData(data);
56+
}
57+
/**
58+
* 删除
59+
* @param ctx koa中间件
60+
*/
61+
@Delete("/cfg")
62+
public async delectCfg(ctx: Context) {
63+
await Validate.verifyAuth(ctx, "cfg");
64+
const cfg: Cfg = ctx.params;
65+
cfg.updatedBy = ctx.user.id;
66+
const data = await this.service.cfgService.delectCfg(cfg);
67+
68+
return ctx.body = ReturnResult.successData(data);
69+
}
70+
/**
71+
* 修改
72+
* @param ctx koa中间件
73+
*/
74+
@Put("/cfg")
75+
public async updateCfg(ctx: Context) {
76+
await Validate.verifyAuth(ctx, "cfg");
77+
const cfg: Cfg = ctx.params;
78+
// 创建/新增版本
79+
cfg.updatedBy = ctx.user.id;
80+
cfg.createdBy = ctx.user.id;
81+
const data = await this.service.cfgService.updateCfg(cfg);
82+
83+
return ctx.body = ReturnResult.successData(data);
84+
}
85+
}

0 commit comments

Comments
 (0)