cgserver 6.2.4 → 6.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/Core/Core.js +6 -0
- package/dist/lib/Database/MongoBaseService.js +79 -0
- package/dist/lib/Database/MysqlBaseService.js +281 -0
- package/dist/lib/Service/AccountService.js +3 -3
- package/dist/lib/Service/MongoAccountService.js +2 -2
- package/dist/lib/Service/MongoCacheService.js +2 -2
- package/dist/lib/Service/MongoUserService.js +2 -2
- package/dist/lib/Service/UserService.js +3 -3
- package/dist/lib/SocketServer/IWebSocket.js +23 -5
- package/dist/lib/WebServer/Engine/Engine.js +13 -1
- package/dist/lib/WebServer/Engine/Response.js +4 -1
- package/dist/lib/cgserver.js +21 -7
- package/dist/types/Core/Core.d.ts +1 -0
- package/dist/types/Database/MongoBaseService.d.ts +67 -0
- package/dist/types/Database/MysqlBaseService.d.ts +34 -0
- package/dist/types/Service/AccountService.d.ts +2 -2
- package/dist/types/Service/MongoAccountService.d.ts +2 -2
- package/dist/types/Service/MongoCacheService.d.ts +2 -2
- package/dist/types/Service/MongoUserService.d.ts +2 -2
- package/dist/types/Service/UserService.d.ts +2 -2
- package/dist/types/WebServer/Engine/Response.d.ts +1 -0
- package/dist/types/cgserver.d.ts +9 -3
- package/package.json +1 -1
package/dist/lib/Core/Core.js
CHANGED
|
@@ -32,6 +32,12 @@ class core {
|
|
|
32
32
|
static isString(param) {
|
|
33
33
|
return typeof (param) === "string";
|
|
34
34
|
}
|
|
35
|
+
static isAsyncFunc(fun) {
|
|
36
|
+
if (!this.isFunction(fun)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
return fun[Symbol.toStringTag] === "AsyncFunction";
|
|
40
|
+
}
|
|
35
41
|
/**
|
|
36
42
|
* 深度拷贝
|
|
37
43
|
* @param obj
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MongoBaseService = void 0;
|
|
4
|
+
const MongoManager_1 = require("./MongoManager");
|
|
5
|
+
class MongoBaseService {
|
|
6
|
+
_table = "";
|
|
7
|
+
get table() {
|
|
8
|
+
return this._table;
|
|
9
|
+
}
|
|
10
|
+
_inited = false;
|
|
11
|
+
get isInited() {
|
|
12
|
+
return this._inited;
|
|
13
|
+
}
|
|
14
|
+
get mongo() {
|
|
15
|
+
return MongoManager_1.GMongoMgr.mongo;
|
|
16
|
+
}
|
|
17
|
+
_t_type = null;
|
|
18
|
+
constructor(table, type) {
|
|
19
|
+
this._t_type = type;
|
|
20
|
+
this._table = table;
|
|
21
|
+
}
|
|
22
|
+
async getNextId() {
|
|
23
|
+
let id = await MongoManager_1.GMongoMgr.getAutoIds(this._table);
|
|
24
|
+
return id;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 没有id(非_id)的表不能使用该函数
|
|
28
|
+
* @param id
|
|
29
|
+
*/
|
|
30
|
+
async getById(id) {
|
|
31
|
+
let rs = await MongoManager_1.GMongoMgr.findOne(this._table, null, { id: id });
|
|
32
|
+
return rs.one;
|
|
33
|
+
}
|
|
34
|
+
async get(proterty, where, sort) {
|
|
35
|
+
let rs = await MongoManager_1.GMongoMgr.findOne(this._table, proterty, where, sort);
|
|
36
|
+
return rs.one;
|
|
37
|
+
}
|
|
38
|
+
async countDocuments(where, options) {
|
|
39
|
+
let rs = await MongoManager_1.GMongoMgr.countDocuments(this._table, where);
|
|
40
|
+
return rs.count;
|
|
41
|
+
}
|
|
42
|
+
async gets(property, where, sort, skip = 0, limit = 0) {
|
|
43
|
+
let rs = await MongoManager_1.GMongoMgr.findMany(this._table, property, where, sort, skip, limit);
|
|
44
|
+
return rs.list;
|
|
45
|
+
}
|
|
46
|
+
async getRandoms(num, proterty, where) {
|
|
47
|
+
let rs = await MongoManager_1.GMongoMgr.simpleAggregate(this._table, proterty, where, null, num);
|
|
48
|
+
return rs.list;
|
|
49
|
+
}
|
|
50
|
+
async updateOne(model, where, upsert = false) {
|
|
51
|
+
let rs = await MongoManager_1.GMongoMgr.updateOne(this._table, model, where, upsert);
|
|
52
|
+
return rs;
|
|
53
|
+
}
|
|
54
|
+
async updateMany(models, where) {
|
|
55
|
+
let rs = await MongoManager_1.GMongoMgr.updateMany(this._table, models, where);
|
|
56
|
+
return rs;
|
|
57
|
+
}
|
|
58
|
+
async insert(model) {
|
|
59
|
+
let rs = await MongoManager_1.GMongoMgr.insertOne(this._table, model);
|
|
60
|
+
return rs;
|
|
61
|
+
}
|
|
62
|
+
async deleteOne(where) {
|
|
63
|
+
let rs = await MongoManager_1.GMongoMgr.deleteOne(this._table, where);
|
|
64
|
+
return rs;
|
|
65
|
+
}
|
|
66
|
+
async deleteMany(where) {
|
|
67
|
+
let rs = await MongoManager_1.GMongoMgr.deleteMany(this._table, where);
|
|
68
|
+
return rs;
|
|
69
|
+
}
|
|
70
|
+
async createIndex(index, options) {
|
|
71
|
+
let rs = await MongoManager_1.GMongoMgr.createIndex(this._table, index, options);
|
|
72
|
+
return rs;
|
|
73
|
+
}
|
|
74
|
+
aggregate(pipeline, options) {
|
|
75
|
+
let ret = MongoManager_1.GMongoMgr.aggregate(this._table, pipeline, options);
|
|
76
|
+
return ret;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.MongoBaseService = MongoBaseService;
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MysqlBaseService = exports.BaseModel = void 0;
|
|
4
|
+
const Property_1 = require("./Decorator/Property");
|
|
5
|
+
const MysqlManager_1 = require("./MysqlManager");
|
|
6
|
+
const Log_1 = require("../Logic/Log");
|
|
7
|
+
const DBCache_1 = require("./Decorator/DBCache");
|
|
8
|
+
const FrameworkConfig_1 = require("../Config/FrameworkConfig");
|
|
9
|
+
class BaseModel {
|
|
10
|
+
}
|
|
11
|
+
exports.BaseModel = BaseModel;
|
|
12
|
+
class MysqlBaseService {
|
|
13
|
+
_table = "";
|
|
14
|
+
get table() {
|
|
15
|
+
return this._table;
|
|
16
|
+
}
|
|
17
|
+
get version() {
|
|
18
|
+
let table = this._t_type.prototype[Property_1.TableProperty.key];
|
|
19
|
+
return table.version;
|
|
20
|
+
}
|
|
21
|
+
_inited = false;
|
|
22
|
+
get isInited() {
|
|
23
|
+
return this._inited;
|
|
24
|
+
}
|
|
25
|
+
_t_type = null;
|
|
26
|
+
constructor(type) {
|
|
27
|
+
this._t_type = type;
|
|
28
|
+
if (MysqlManager_1.GMysqlMgr.isValid) {
|
|
29
|
+
this._init();
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
MysqlManager_1.GMysqlMgr.registerInitCb(this._init.bind(this));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async _init() {
|
|
36
|
+
if (this._inited) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
this._inited = true;
|
|
40
|
+
let table = this._t_type.prototype[Property_1.TableProperty.key];
|
|
41
|
+
if (!table || !table.table) {
|
|
42
|
+
throw new Error("数据表的类必须要具有Table装饰器");
|
|
43
|
+
}
|
|
44
|
+
this._table = "`" + table.table + "`";
|
|
45
|
+
if (!FrameworkConfig_1.GFCfg.db.mysql.auto) {
|
|
46
|
+
//未开启自动创建数据表
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
let droped = await this._checkDropTable(table.version);
|
|
50
|
+
if (!droped) {
|
|
51
|
+
Log_1.GLog.info("table(" + this._table + ")无需升级...", true);
|
|
52
|
+
//既然版本号没变,就快速返回
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
let primary_key = null;
|
|
56
|
+
let sql = "create table if not exists " + this._table + " (";
|
|
57
|
+
for (let key in table.items) {
|
|
58
|
+
let item = table.items[key];
|
|
59
|
+
sql += "`" + key + "`" + " " + item.type;
|
|
60
|
+
if (item.type == Property_1.EPropertyType.Varchar
|
|
61
|
+
|| item.type == Property_1.EPropertyType.Char
|
|
62
|
+
|| item.type == Property_1.EPropertyType.NVarchar) {
|
|
63
|
+
sql += "(" + item.type_len + ")";
|
|
64
|
+
}
|
|
65
|
+
if (item.is_notnull) {
|
|
66
|
+
sql += " not null";
|
|
67
|
+
}
|
|
68
|
+
if (item.default != undefined && !item.is_primary) {
|
|
69
|
+
sql += " default \'" + item.default + "\'";
|
|
70
|
+
}
|
|
71
|
+
if (item.auto_increment) {
|
|
72
|
+
sql += " auto_increment";
|
|
73
|
+
}
|
|
74
|
+
if (item.is_primary) {
|
|
75
|
+
primary_key = key;
|
|
76
|
+
}
|
|
77
|
+
sql += ",";
|
|
78
|
+
}
|
|
79
|
+
if (primary_key) {
|
|
80
|
+
sql += "primary key (`" + primary_key + "`),";
|
|
81
|
+
sql += "unique key `" + primary_key + "_unique` (`" + primary_key + "`)";
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
//去掉最后一个逗号
|
|
85
|
+
sql = sql.substr(0, sql.length - 1);
|
|
86
|
+
}
|
|
87
|
+
sql += ")";
|
|
88
|
+
sql += " engine=" + table.engine;
|
|
89
|
+
if (table.auto_increment != null) {
|
|
90
|
+
sql += " auto_increment=" + table.auto_increment;
|
|
91
|
+
}
|
|
92
|
+
sql += " default charset=" + table.charset;
|
|
93
|
+
if (table.comment) {
|
|
94
|
+
sql += " comment=\'" + table.comment + "\';";
|
|
95
|
+
}
|
|
96
|
+
let sr = await MysqlManager_1.GMysqlMgr.query(sql);
|
|
97
|
+
if (sr.error) {
|
|
98
|
+
Log_1.GLog.error(sr.error);
|
|
99
|
+
throw Error("table(" + this._table + ")创建失败...");
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
DBCache_1.GDBCache.setVersion(this.table, table.version);
|
|
103
|
+
Log_1.GLog.info("table(" + this._table + ")初始化成功...", true);
|
|
104
|
+
await this._onReCreated();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async _onReCreated() {
|
|
108
|
+
}
|
|
109
|
+
async _onDroped() {
|
|
110
|
+
}
|
|
111
|
+
async _checkDropTable(cur_version) {
|
|
112
|
+
let local_version = DBCache_1.GDBCache.getVersion(this._table);
|
|
113
|
+
if (local_version == cur_version) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
let sql = "drop table if exists " + this._table;
|
|
117
|
+
let sr = await MysqlManager_1.GMysqlMgr.query(sql);
|
|
118
|
+
if (sr.error) {
|
|
119
|
+
Log_1.GLog.error(sr.error);
|
|
120
|
+
throw Error(sr.error);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
Log_1.GLog.info("table(" + this._table + ")删除成功...", true);
|
|
124
|
+
await this._onDroped();
|
|
125
|
+
}
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* 没有id的表不能使用该函数
|
|
130
|
+
* @param id
|
|
131
|
+
*/
|
|
132
|
+
async getById(id) {
|
|
133
|
+
let tm = null;
|
|
134
|
+
let sr = await MysqlManager_1.GMysqlMgr.query("select * from " + this._table + " where id=? limit 1", [id]);
|
|
135
|
+
if (sr.error || sr.results.length <= 0) {
|
|
136
|
+
return tm;
|
|
137
|
+
}
|
|
138
|
+
tm = sr.results[0];
|
|
139
|
+
return tm;
|
|
140
|
+
}
|
|
141
|
+
async get(proterty, where, args) {
|
|
142
|
+
let sql = "select ";
|
|
143
|
+
sql += proterty || "*";
|
|
144
|
+
sql += " from " + this._table;
|
|
145
|
+
if (where) {
|
|
146
|
+
sql += " where " + where;
|
|
147
|
+
}
|
|
148
|
+
sql += " limit 1";
|
|
149
|
+
let tm = null;
|
|
150
|
+
let sr = await MysqlManager_1.GMysqlMgr.query(sql, args);
|
|
151
|
+
if (sr.list && sr.list.length > 0) {
|
|
152
|
+
tm = sr.list[0];
|
|
153
|
+
}
|
|
154
|
+
return tm;
|
|
155
|
+
}
|
|
156
|
+
async getTotal(where, args) {
|
|
157
|
+
let sql = "select ";
|
|
158
|
+
sql += "count(*) as num";
|
|
159
|
+
sql += " from " + this._table;
|
|
160
|
+
if (where) {
|
|
161
|
+
sql += " where " + where;
|
|
162
|
+
}
|
|
163
|
+
let total = 0;
|
|
164
|
+
let sr = await MysqlManager_1.GMysqlMgr.query(sql, args);
|
|
165
|
+
if (sr.list && sr.list.length > 0) {
|
|
166
|
+
total = sr.list[0].num || 0;
|
|
167
|
+
}
|
|
168
|
+
return total;
|
|
169
|
+
}
|
|
170
|
+
async gets(proterty, where, args) {
|
|
171
|
+
let sql = "select ";
|
|
172
|
+
sql += proterty || "*";
|
|
173
|
+
sql += " from " + this._table;
|
|
174
|
+
if (where) {
|
|
175
|
+
sql += " where " + where;
|
|
176
|
+
}
|
|
177
|
+
let tms = null;
|
|
178
|
+
let sr = await MysqlManager_1.GMysqlMgr.query(sql, args);
|
|
179
|
+
tms = sr.list;
|
|
180
|
+
return tms;
|
|
181
|
+
}
|
|
182
|
+
async getCount(where, args) {
|
|
183
|
+
let sql = "select count(*) as num from " + this._table;
|
|
184
|
+
if (where) {
|
|
185
|
+
sql += " where " + where;
|
|
186
|
+
}
|
|
187
|
+
let sr = await MysqlManager_1.GMysqlMgr.query(sql, args);
|
|
188
|
+
if (sr.error || sr.results.length <= 0) {
|
|
189
|
+
return 0;
|
|
190
|
+
}
|
|
191
|
+
return sr.results[0]["num"] || 0;
|
|
192
|
+
}
|
|
193
|
+
async getRandoms(num, proterty, where, args) {
|
|
194
|
+
num = num || 5;
|
|
195
|
+
let sql = "select ";
|
|
196
|
+
sql += proterty || "*";
|
|
197
|
+
sql += " from " + this._table;
|
|
198
|
+
if (where) {
|
|
199
|
+
sql += " where " + where;
|
|
200
|
+
}
|
|
201
|
+
sql += " order by rand() limit ?";
|
|
202
|
+
args = args || [];
|
|
203
|
+
args.push(num);
|
|
204
|
+
let tms = null;
|
|
205
|
+
let sr = await MysqlManager_1.GMysqlMgr.query(sql, args);
|
|
206
|
+
tms = sr.list;
|
|
207
|
+
return tms;
|
|
208
|
+
}
|
|
209
|
+
async updateProperty(set, where, args, limit) {
|
|
210
|
+
let sql = "update " + this._table + " set ";
|
|
211
|
+
if (set) {
|
|
212
|
+
sql += set;
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
sql += "?";
|
|
216
|
+
}
|
|
217
|
+
if (where) {
|
|
218
|
+
sql += " where " + where;
|
|
219
|
+
}
|
|
220
|
+
if (limit) {
|
|
221
|
+
sql += " limit " + limit;
|
|
222
|
+
}
|
|
223
|
+
let sr = await MysqlManager_1.GMysqlMgr.query(sql, args);
|
|
224
|
+
return sr;
|
|
225
|
+
}
|
|
226
|
+
async update(model, where, args, limit) {
|
|
227
|
+
let sql = "update " + this._table + " set ?";
|
|
228
|
+
if (!where) {
|
|
229
|
+
where = " id=?";
|
|
230
|
+
}
|
|
231
|
+
sql += " where " + where;
|
|
232
|
+
let id = model["id"];
|
|
233
|
+
delete model["id"];
|
|
234
|
+
let u_m = JSON.parse(JSON.stringify(model));
|
|
235
|
+
if (!args) {
|
|
236
|
+
args = [u_m, id];
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
args.unshift(u_m);
|
|
240
|
+
}
|
|
241
|
+
if (limit) {
|
|
242
|
+
sql += " limit " + limit;
|
|
243
|
+
}
|
|
244
|
+
let sr = await MysqlManager_1.GMysqlMgr.query(sql, args);
|
|
245
|
+
if (id) {
|
|
246
|
+
model["id"] = id;
|
|
247
|
+
}
|
|
248
|
+
return sr;
|
|
249
|
+
}
|
|
250
|
+
async insert(model, ip) {
|
|
251
|
+
let table = model[Property_1.TableProperty.key];
|
|
252
|
+
let id_property = table.items["id"];
|
|
253
|
+
if (id_property) {
|
|
254
|
+
if (id_property.auto_increment) {
|
|
255
|
+
delete model["id"];
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (table.items["create_time"] && model["create_time"] <= 0) {
|
|
259
|
+
model["create_time"] = Date.now();
|
|
260
|
+
}
|
|
261
|
+
if (table.items["create_ip"] && ip) {
|
|
262
|
+
model["create_ip"] = ip;
|
|
263
|
+
}
|
|
264
|
+
let sql = "insert into " + this._table + " set ?";
|
|
265
|
+
//这步的做法是为了去掉model种的TableProperty.key(___table___)
|
|
266
|
+
model = JSON.parse(JSON.stringify(model));
|
|
267
|
+
let sr = await MysqlManager_1.GMysqlMgr.query(sql, [model]);
|
|
268
|
+
return sr;
|
|
269
|
+
}
|
|
270
|
+
async removeById(id) {
|
|
271
|
+
let sql = "delete from " + this._table + " where id=?";
|
|
272
|
+
let sr = await MysqlManager_1.GMysqlMgr.query(sql, [id]);
|
|
273
|
+
return sr;
|
|
274
|
+
}
|
|
275
|
+
async remove(where, args) {
|
|
276
|
+
let sql = "delete from " + this._table + " where " + where;
|
|
277
|
+
let sr = await MysqlManager_1.GMysqlMgr.query(sql, args);
|
|
278
|
+
return sr;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
exports.MysqlBaseService = MysqlBaseService;
|
|
@@ -8,7 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.AccountService = exports.GAccountSer = exports.AccountModel = void 0;
|
|
10
10
|
const Property_1 = require("./../Database/Decorator/Property");
|
|
11
|
-
const
|
|
11
|
+
const MysqlBaseService_1 = require("../Database/MysqlBaseService");
|
|
12
12
|
const CacheTool_1 = require("../Logic/CacheTool");
|
|
13
13
|
const _error_1 = require("../Config/_error_");
|
|
14
14
|
const OpenSocial_1 = require("../ThirdParty/OpenSocial");
|
|
@@ -21,7 +21,7 @@ const NotNull_1 = require("../Database/Decorator/NotNull");
|
|
|
21
21
|
const Type_1 = require("../Database/Decorator/Type");
|
|
22
22
|
const AutoIncrement_1 = require("../Database/Decorator/AutoIncrement");
|
|
23
23
|
const ini_1 = require("./ini");
|
|
24
|
-
let AccountModel = class AccountModel extends
|
|
24
|
+
let AccountModel = class AccountModel extends MysqlBaseService_1.BaseModel {
|
|
25
25
|
id = -1;
|
|
26
26
|
phone = "";
|
|
27
27
|
email = "";
|
|
@@ -96,7 +96,7 @@ AccountModel = __decorate([
|
|
|
96
96
|
exports.AccountModel = AccountModel;
|
|
97
97
|
//暂时不实例化,方便重写
|
|
98
98
|
exports.GAccountSer = null;
|
|
99
|
-
class AccountService extends
|
|
99
|
+
class AccountService extends MysqlBaseService_1.MysqlBaseService {
|
|
100
100
|
_account_cache_key_pre = "table_account_";
|
|
101
101
|
_account_cache_time_sec = 1 * 60 * 60 * 1000;
|
|
102
102
|
constructor() {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AccountService = exports.GAccountSer = exports.AccountModel = void 0;
|
|
4
4
|
const _error_1 = require("../Config/_error_");
|
|
5
|
-
const
|
|
5
|
+
const MongoBaseService_1 = require("../Database/MongoBaseService");
|
|
6
6
|
const MongoManager_1 = require("../Database/MongoManager");
|
|
7
7
|
const CacheTool_1 = require("../Logic/CacheTool");
|
|
8
8
|
const OpenSocial_1 = require("../ThirdParty/OpenSocial");
|
|
@@ -28,7 +28,7 @@ class AccountModel extends MongoManager_1.MongoBaseModel {
|
|
|
28
28
|
exports.AccountModel = AccountModel;
|
|
29
29
|
//暂时不实例化,方便重写
|
|
30
30
|
exports.GAccountSer = null;
|
|
31
|
-
class AccountService extends
|
|
31
|
+
class AccountService extends MongoBaseService_1.MongoBaseService {
|
|
32
32
|
_account_cache_key_pre = "table_account_";
|
|
33
33
|
_account_cache_time_sec = 1 * 60 * 60 * 1000;
|
|
34
34
|
constructor() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GMongoCacheSer = exports.MongoCacheModel = void 0;
|
|
4
|
-
const
|
|
4
|
+
const MongoBaseService_1 = require("../Database/MongoBaseService");
|
|
5
5
|
const MongoManager_1 = require("../Database/MongoManager");
|
|
6
6
|
//暂时就用这个了,反正没啥用户
|
|
7
7
|
class MongoCacheModel extends MongoManager_1.MongoBaseModel {
|
|
@@ -11,7 +11,7 @@ class MongoCacheModel extends MongoManager_1.MongoBaseModel {
|
|
|
11
11
|
}
|
|
12
12
|
exports.MongoCacheModel = MongoCacheModel;
|
|
13
13
|
exports.GMongoCacheSer = null;
|
|
14
|
-
class MongoCacheService extends
|
|
14
|
+
class MongoCacheService extends MongoBaseService_1.MongoBaseService {
|
|
15
15
|
constructor() {
|
|
16
16
|
super("cache", MongoCacheModel);
|
|
17
17
|
this.createIndex({ "expireAt": 1 }, { expireAfterSeconds: 0 });
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UserService = exports.GUserSer = exports.UserModel = void 0;
|
|
4
4
|
const _ = require("underscore");
|
|
5
|
-
const
|
|
5
|
+
const MongoBaseService_1 = require("../Database/MongoBaseService");
|
|
6
6
|
const MongoManager_1 = require("../Database/MongoManager");
|
|
7
7
|
const ini_1 = require("./ini");
|
|
8
8
|
class UserModel extends MongoManager_1.MongoBaseModel {
|
|
@@ -30,7 +30,7 @@ class UserModel extends MongoManager_1.MongoBaseModel {
|
|
|
30
30
|
exports.UserModel = UserModel;
|
|
31
31
|
//暂时不实例化,方便重写
|
|
32
32
|
exports.GUserSer = null;
|
|
33
|
-
class UserService extends
|
|
33
|
+
class UserService extends MongoBaseService_1.MongoBaseService {
|
|
34
34
|
constructor(type) {
|
|
35
35
|
super("user", type);
|
|
36
36
|
exports.GUserSer = this;
|
|
@@ -8,13 +8,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.UserService = exports.GUserSer = exports.UserModel = void 0;
|
|
10
10
|
const _ = require("underscore");
|
|
11
|
-
const
|
|
11
|
+
const MysqlBaseService_1 = require("../Database/MysqlBaseService");
|
|
12
12
|
const PrimaryKey_1 = require("../Database/Decorator/PrimaryKey");
|
|
13
13
|
const NotNull_1 = require("../Database/Decorator/NotNull");
|
|
14
14
|
const Property_1 = require("../Database/Decorator/Property");
|
|
15
15
|
const Type_1 = require("../Database/Decorator/Type");
|
|
16
16
|
const ini_1 = require("./ini");
|
|
17
|
-
class UserModel extends
|
|
17
|
+
class UserModel extends MysqlBaseService_1.BaseModel {
|
|
18
18
|
id = -1;
|
|
19
19
|
account_id = -1;
|
|
20
20
|
nickname = "";
|
|
@@ -120,7 +120,7 @@ __decorate([
|
|
|
120
120
|
exports.UserModel = UserModel;
|
|
121
121
|
//暂时不实例化,方便重写
|
|
122
122
|
exports.GUserSer = null;
|
|
123
|
-
class UserService extends
|
|
123
|
+
class UserService extends MysqlBaseService_1.MysqlBaseService {
|
|
124
124
|
constructor(type) {
|
|
125
125
|
super(type);
|
|
126
126
|
exports.GUserSer = this;
|
|
@@ -146,14 +146,24 @@ class IWebSocket {
|
|
|
146
146
|
}
|
|
147
147
|
async _onMessage(data) {
|
|
148
148
|
let jsonData = data;
|
|
149
|
+
let func = this["receive_" + jsonData.cmd];
|
|
149
150
|
let ret = this.filterMsg(jsonData);
|
|
150
151
|
if (!ret) {
|
|
151
152
|
return;
|
|
152
153
|
}
|
|
153
|
-
else if (!
|
|
154
|
-
|
|
154
|
+
else if (!func) {
|
|
155
|
+
let otherfunc = this["receive_other_all"];
|
|
156
|
+
if (otherfunc) {
|
|
155
157
|
try {
|
|
156
|
-
|
|
158
|
+
if (Core_1.core.isAsyncFunc(otherfunc)) {
|
|
159
|
+
//默认支持其他所有处理消息
|
|
160
|
+
await otherfunc(jsonData).catch((reason) => {
|
|
161
|
+
Log_1.GLog.error(reason);
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
otherfunc(jsonData);
|
|
166
|
+
}
|
|
157
167
|
}
|
|
158
168
|
catch (e) {
|
|
159
169
|
Log_1.GLog.error(this.tipKey + e.stack);
|
|
@@ -165,7 +175,15 @@ class IWebSocket {
|
|
|
165
175
|
}
|
|
166
176
|
else {
|
|
167
177
|
try {
|
|
168
|
-
|
|
178
|
+
if (Core_1.core.isAsyncFunc(func)) {
|
|
179
|
+
//默认支持其他所有处理消息
|
|
180
|
+
await func(jsonData).catch((reason) => {
|
|
181
|
+
Log_1.GLog.error(reason);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
func(jsonData);
|
|
186
|
+
}
|
|
169
187
|
}
|
|
170
188
|
catch (e) {
|
|
171
189
|
Log_1.GLog.error(this.tipKey + " error msg:data=" + JSON.stringify(jsonData) + "\n" + e.stack);
|
|
@@ -175,7 +193,7 @@ class IWebSocket {
|
|
|
175
193
|
onOpen(e) {
|
|
176
194
|
}
|
|
177
195
|
onError(e) {
|
|
178
|
-
Log_1.GLog.
|
|
196
|
+
Log_1.GLog.error(this.tipKey + " onError:" + e.message);
|
|
179
197
|
}
|
|
180
198
|
onClose(reasonCode, description) {
|
|
181
199
|
Log_1.GLog.info(this.tipKey + " onClose resonCode=" + reasonCode + " des=" + description);
|
|
@@ -60,7 +60,19 @@ class Engine {
|
|
|
60
60
|
credentials: this._cfg.cors.credentials || false
|
|
61
61
|
}));
|
|
62
62
|
}
|
|
63
|
-
this._app.all("/*",
|
|
63
|
+
this._app.all("/*", (_req, _res) => {
|
|
64
|
+
this._all(_req, _res).catch((reason) => {
|
|
65
|
+
Log_1.GLog.error(reason);
|
|
66
|
+
let res = new Response_1.Response(_res, this._cfg);
|
|
67
|
+
let method = _req.method.toLowerCase();
|
|
68
|
+
if (method == "post") {
|
|
69
|
+
res.renderJson500();
|
|
70
|
+
}
|
|
71
|
+
else if (method == "get") {
|
|
72
|
+
res.render500();
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
64
76
|
}
|
|
65
77
|
async _all(_req, _res) {
|
|
66
78
|
let req = new Request_1.Request(_req, this._cfg);
|
|
@@ -53,7 +53,10 @@ class Response {
|
|
|
53
53
|
this._res.send(html || "");
|
|
54
54
|
}
|
|
55
55
|
render404(html) {
|
|
56
|
-
this._res.status(404).send("没找到该页面");
|
|
56
|
+
this._res.status(404).send(html || "没找到该页面");
|
|
57
|
+
}
|
|
58
|
+
render500(html) {
|
|
59
|
+
this._res.status(500).send(html || "服务器内部错误500");
|
|
57
60
|
}
|
|
58
61
|
renderOptions(method, origin) {
|
|
59
62
|
this._res.sendStatus(204);
|
package/dist/lib/cgserver.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.JsonProtoFilter = exports.GoogleProtoFilter = exports.MongoCacheModel = exports.GMongoCacheSer = exports.MongoUserModel = exports.MysqlUserModel = exports.MongoUserService = exports.MysqlUserService = exports.GMongoAccountSer = exports.MongoAccountService = exports.GMysqlAccountSer = exports.MysqlAccountService = exports.EAccountFrom = exports.EUserState = exports.ERoleGroup = exports.GLog = exports.GHttpTool = exports.GCacheTool = exports.RedisManager = exports.GRedisMgr = exports.GMysqlMgr = exports.MysqlBaseService = exports.GMSSqlMgr = exports.GMongoMgr = exports.MongoBaseModel = exports.MysqlBaseModel = exports.MongoBaseService = exports.EPropertyType = exports.Type = exports.Table = exports.Property = exports.PrimaryKey = exports.NotNull = exports.AutoIncrement = exports.Timer = exports.core = exports.ServerConfig = exports.GFCfg = exports.FrameworkConfig = exports.Config = exports.FrameworkErrorCode = exports.GTriggerMgr = exports.Trigger = exports.Point = exports.Entity = exports.BehaviorAI = exports.AStar = exports.AiObject = exports.GDBCache = exports.GProtoFactory = void 0;
|
|
4
|
-
exports.WebServerConfig = exports.Response = exports.Request = exports.RazorJs = exports.Engine = exports.GCtrMgr = exports.JsonCreatorValidate = exports.JsonAuthorityValidate = exports.JsonAdminValidate = exports.CreatorValidate = exports.AuthorityValidate = exports.AdminValidate = exports.MongoAccountModel = exports.MysqlAccountModel = exports.MongoBaseUserController = exports.BaseUserController = exports.BaseController = exports.IWebServer = exports.GWechatTool = exports.GWechatOATool = exports.GQQTool = exports.GQiniuTool = exports.GOpenSocial = exports.GEmailTool = exports.GAppleTool = exports.GSmsTool = exports.GAlipayTool = exports.IWebSocket = exports.ISocketServer = exports.IServerWebSocket = exports.IClientWebSocket = void 0;
|
|
4
|
+
exports.GCgServer = exports.WebServerConfig = exports.Response = exports.Request = exports.RazorJs = exports.Engine = exports.GCtrMgr = exports.JsonCreatorValidate = exports.JsonAuthorityValidate = exports.JsonAdminValidate = exports.CreatorValidate = exports.AuthorityValidate = exports.AdminValidate = exports.MongoAccountModel = exports.MysqlAccountModel = exports.MongoBaseUserController = exports.BaseUserController = exports.BaseController = exports.IWebServer = exports.GWechatTool = exports.GWechatOATool = exports.GQQTool = exports.GQiniuTool = exports.GOpenSocial = exports.GEmailTool = exports.GAppleTool = exports.GSmsTool = exports.GAlipayTool = exports.IWebSocket = exports.ISocketServer = exports.IServerWebSocket = exports.IClientWebSocket = void 0;
|
|
5
5
|
var ProtoFactory_1 = require("./SocketServer/ProtoFilter/ProtoFactory");
|
|
6
6
|
Object.defineProperty(exports, "GProtoFactory", { enumerable: true, get: function () { return ProtoFactory_1.GProtoFactory; } });
|
|
7
7
|
var DBCache_1 = require("./Database/Decorator/DBCache");
|
|
@@ -47,18 +47,18 @@ var Type_1 = require("./Database/Decorator/Type");
|
|
|
47
47
|
Object.defineProperty(exports, "Type", { enumerable: true, get: function () { return Type_1.Type; } });
|
|
48
48
|
var Property_2 = require("./Database/Decorator/Property");
|
|
49
49
|
Object.defineProperty(exports, "EPropertyType", { enumerable: true, get: function () { return Property_2.EPropertyType; } });
|
|
50
|
-
var
|
|
51
|
-
Object.defineProperty(exports, "MongoBaseService", { enumerable: true, get: function () { return
|
|
52
|
-
var
|
|
53
|
-
Object.defineProperty(exports, "MysqlBaseModel", { enumerable: true, get: function () { return
|
|
50
|
+
var MongoBaseService_1 = require("./Database/MongoBaseService");
|
|
51
|
+
Object.defineProperty(exports, "MongoBaseService", { enumerable: true, get: function () { return MongoBaseService_1.MongoBaseService; } });
|
|
52
|
+
var MysqlBaseService_1 = require("./Database/MysqlBaseService");
|
|
53
|
+
Object.defineProperty(exports, "MysqlBaseModel", { enumerable: true, get: function () { return MysqlBaseService_1.BaseModel; } });
|
|
54
54
|
var MongoManager_1 = require("./Database/MongoManager");
|
|
55
55
|
Object.defineProperty(exports, "MongoBaseModel", { enumerable: true, get: function () { return MongoManager_1.MongoBaseModel; } });
|
|
56
56
|
var MongoManager_2 = require("./Database/MongoManager");
|
|
57
57
|
Object.defineProperty(exports, "GMongoMgr", { enumerable: true, get: function () { return MongoManager_2.GMongoMgr; } });
|
|
58
58
|
var MSSqlManager_1 = require("./Database/MSSqlManager");
|
|
59
59
|
Object.defineProperty(exports, "GMSSqlMgr", { enumerable: true, get: function () { return MSSqlManager_1.GMSSqlMgr; } });
|
|
60
|
-
var
|
|
61
|
-
Object.defineProperty(exports, "MysqlBaseService", { enumerable: true, get: function () { return
|
|
60
|
+
var MysqlBaseService_2 = require("./Database/MysqlBaseService");
|
|
61
|
+
Object.defineProperty(exports, "MysqlBaseService", { enumerable: true, get: function () { return MysqlBaseService_2.MysqlBaseService; } });
|
|
62
62
|
var MysqlManager_1 = require("./Database/MysqlManager");
|
|
63
63
|
Object.defineProperty(exports, "GMysqlMgr", { enumerable: true, get: function () { return MysqlManager_1.GMysqlMgr; } });
|
|
64
64
|
var RedisManager_1 = require("./Database/RedisManager");
|
|
@@ -157,3 +157,17 @@ var Response_1 = require("./WebServer/Engine/Response");
|
|
|
157
157
|
Object.defineProperty(exports, "Response", { enumerable: true, get: function () { return Response_1.Response; } });
|
|
158
158
|
var FrameworkConfig_2 = require("./Config/FrameworkConfig");
|
|
159
159
|
Object.defineProperty(exports, "WebServerConfig", { enumerable: true, get: function () { return FrameworkConfig_2.WebServerConfig; } });
|
|
160
|
+
const Log_2 = require("./Logic/Log");
|
|
161
|
+
class CgServer {
|
|
162
|
+
constructor() {
|
|
163
|
+
this.init();
|
|
164
|
+
}
|
|
165
|
+
init() {
|
|
166
|
+
process.on("uncaughtException", this.onUnCaughtException.bind(this));
|
|
167
|
+
process.env.TZ = "Asia/Shanghai";
|
|
168
|
+
}
|
|
169
|
+
onUnCaughtException(e) {
|
|
170
|
+
Log_2.GLog.error(e.stack);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
exports.GCgServer = new CgServer();
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as mongo from 'mongodb';
|
|
2
|
+
export declare class MongoBaseService<T> {
|
|
3
|
+
protected _table: string;
|
|
4
|
+
get table(): string;
|
|
5
|
+
protected _inited: boolean;
|
|
6
|
+
get isInited(): boolean;
|
|
7
|
+
get mongo(): mongo.Db;
|
|
8
|
+
protected _t_type: {
|
|
9
|
+
new (): T;
|
|
10
|
+
};
|
|
11
|
+
constructor(table: string, type: {
|
|
12
|
+
new (): T;
|
|
13
|
+
});
|
|
14
|
+
getNextId(): Promise<any>;
|
|
15
|
+
/**
|
|
16
|
+
* 没有id(非_id)的表不能使用该函数
|
|
17
|
+
* @param id
|
|
18
|
+
*/
|
|
19
|
+
getById(id: any): Promise<any>;
|
|
20
|
+
get(proterty?: {}, where?: {}, sort?: {}): Promise<any>;
|
|
21
|
+
countDocuments(where?: {}, options?: mongo.CountDocumentsOptions): Promise<number>;
|
|
22
|
+
gets(property?: {}, where?: {}, sort?: {}, skip?: number, limit?: number): Promise<any[]>;
|
|
23
|
+
getRandoms(num: number, proterty?: {}, where?: {}): Promise<any[]>;
|
|
24
|
+
updateOne(model: any, where?: {}, upsert?: boolean): Promise<{
|
|
25
|
+
errcode: {
|
|
26
|
+
id: number;
|
|
27
|
+
des: string;
|
|
28
|
+
};
|
|
29
|
+
rs: mongo.UpdateResult;
|
|
30
|
+
}>;
|
|
31
|
+
updateMany(models: [], where?: {}): Promise<{
|
|
32
|
+
errcode: {
|
|
33
|
+
id: number;
|
|
34
|
+
des: string;
|
|
35
|
+
};
|
|
36
|
+
rs: mongo.Document | mongo.UpdateResult;
|
|
37
|
+
}>;
|
|
38
|
+
insert(model: T): Promise<{
|
|
39
|
+
errcode: {
|
|
40
|
+
id: number;
|
|
41
|
+
des: string;
|
|
42
|
+
};
|
|
43
|
+
rs: mongo.InsertOneResult<any>;
|
|
44
|
+
}>;
|
|
45
|
+
deleteOne(where: any): Promise<{
|
|
46
|
+
errcode: {
|
|
47
|
+
id: number;
|
|
48
|
+
des: string;
|
|
49
|
+
};
|
|
50
|
+
count: number;
|
|
51
|
+
}>;
|
|
52
|
+
deleteMany(where: any): Promise<{
|
|
53
|
+
errcode: {
|
|
54
|
+
id: number;
|
|
55
|
+
des: string;
|
|
56
|
+
};
|
|
57
|
+
count: number;
|
|
58
|
+
}>;
|
|
59
|
+
createIndex(index: any, options?: mongo.CreateIndexesOptions): Promise<{
|
|
60
|
+
errcode: {
|
|
61
|
+
id: number;
|
|
62
|
+
des: string;
|
|
63
|
+
};
|
|
64
|
+
rs: string;
|
|
65
|
+
}>;
|
|
66
|
+
aggregate(pipeline?: Document[], options?: mongo.AggregateOptions): mongo.AggregationCursor<mongo.Document>;
|
|
67
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare class BaseModel {
|
|
2
|
+
}
|
|
3
|
+
export declare class MysqlBaseService<T extends BaseModel> {
|
|
4
|
+
protected _table: string;
|
|
5
|
+
get table(): string;
|
|
6
|
+
get version(): number;
|
|
7
|
+
protected _inited: boolean;
|
|
8
|
+
get isInited(): boolean;
|
|
9
|
+
protected _t_type: {
|
|
10
|
+
new (): T;
|
|
11
|
+
};
|
|
12
|
+
constructor(type: {
|
|
13
|
+
new (): T;
|
|
14
|
+
});
|
|
15
|
+
protected _init(): Promise<void>;
|
|
16
|
+
protected _onReCreated(): Promise<void>;
|
|
17
|
+
protected _onDroped(): Promise<void>;
|
|
18
|
+
protected _checkDropTable(cur_version: number): Promise<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* 没有id的表不能使用该函数
|
|
21
|
+
* @param id
|
|
22
|
+
*/
|
|
23
|
+
getById(id: any): Promise<T>;
|
|
24
|
+
get(proterty?: string, where?: string, args?: Array<any>): Promise<any>;
|
|
25
|
+
getTotal(where?: string, args?: Array<any>): Promise<number>;
|
|
26
|
+
gets(proterty?: string, where?: string, args?: Array<any>): Promise<any[]>;
|
|
27
|
+
getCount(where?: string, args?: Array<any>): Promise<any>;
|
|
28
|
+
getRandoms(num: number, proterty?: string, where?: string, args?: Array<any>): Promise<any[]>;
|
|
29
|
+
updateProperty(set: string, where?: string, args?: Array<any>, limit?: number): Promise<import("./MysqlManager").SqlReturn>;
|
|
30
|
+
update(model: T, where?: string, args?: Array<any>, limit?: number): Promise<import("./MysqlManager").SqlReturn>;
|
|
31
|
+
insert(model: T, ip?: string): Promise<import("./MysqlManager").SqlReturn>;
|
|
32
|
+
removeById(id: any): Promise<import("./MysqlManager").SqlReturn>;
|
|
33
|
+
remove(where: string, args?: Array<any>): Promise<import("./MysqlManager").SqlReturn>;
|
|
34
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseModel,
|
|
1
|
+
import { BaseModel, MysqlBaseService } from '../Database/MysqlBaseService';
|
|
2
2
|
import { UserModel } from './UserService';
|
|
3
3
|
import { EAccountFrom } from './ini';
|
|
4
4
|
export declare class AccountModel extends BaseModel {
|
|
@@ -17,7 +17,7 @@ export declare class AccountModel extends BaseModel {
|
|
|
17
17
|
state: number;
|
|
18
18
|
}
|
|
19
19
|
export declare let GAccountSer: AccountService;
|
|
20
|
-
export declare class AccountService extends
|
|
20
|
+
export declare class AccountService extends MysqlBaseService<AccountModel> {
|
|
21
21
|
protected _account_cache_key_pre: string;
|
|
22
22
|
protected _account_cache_time_sec: number;
|
|
23
23
|
constructor();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MongoBaseService } from '../Database/MongoBaseService';
|
|
2
2
|
import { MongoBaseModel } from '../Database/MongoManager';
|
|
3
3
|
import { EAccountFrom } from './ini';
|
|
4
4
|
import { UserModel } from './MongoUserService';
|
|
@@ -18,7 +18,7 @@ export declare class AccountModel extends MongoBaseModel {
|
|
|
18
18
|
state: number;
|
|
19
19
|
}
|
|
20
20
|
export declare let GAccountSer: AccountService;
|
|
21
|
-
export declare class AccountService extends
|
|
21
|
+
export declare class AccountService extends MongoBaseService<AccountModel> {
|
|
22
22
|
protected _account_cache_key_pre: string;
|
|
23
23
|
protected _account_cache_time_sec: number;
|
|
24
24
|
constructor();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MongoBaseService } from "../Database/MongoBaseService";
|
|
2
2
|
import { MongoBaseModel } from "../Database/MongoManager";
|
|
3
3
|
export declare class MongoCacheModel extends MongoBaseModel {
|
|
4
4
|
key: string;
|
|
@@ -6,7 +6,7 @@ export declare class MongoCacheModel extends MongoBaseModel {
|
|
|
6
6
|
expireAt: number;
|
|
7
7
|
}
|
|
8
8
|
export declare let GMongoCacheSer: MongoCacheService;
|
|
9
|
-
declare class MongoCacheService extends
|
|
9
|
+
declare class MongoCacheService extends MongoBaseService<MongoCacheModel> {
|
|
10
10
|
constructor();
|
|
11
11
|
getData(key: string): Promise<any>;
|
|
12
12
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MongoBaseService } from "../Database/MongoBaseService";
|
|
2
2
|
import { MongoBaseModel } from "../Database/MongoManager";
|
|
3
3
|
import { ERoleGroup } from "./ini";
|
|
4
4
|
export declare class UserModel extends MongoBaseModel {
|
|
@@ -24,7 +24,7 @@ export declare class UserModel extends MongoBaseModel {
|
|
|
24
24
|
create_time: number;
|
|
25
25
|
}
|
|
26
26
|
export declare let GUserSer: UserService<UserModel>;
|
|
27
|
-
export declare class UserService<T extends UserModel> extends
|
|
27
|
+
export declare class UserService<T extends UserModel> extends MongoBaseService<T> {
|
|
28
28
|
constructor(type: {
|
|
29
29
|
new (): T;
|
|
30
30
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MysqlBaseService, BaseModel } from "../Database/MysqlBaseService";
|
|
2
2
|
import { ERoleGroup } from "./ini";
|
|
3
3
|
export declare class UserModel extends BaseModel {
|
|
4
4
|
id: number;
|
|
@@ -23,7 +23,7 @@ export declare class UserModel extends BaseModel {
|
|
|
23
23
|
create_time: number;
|
|
24
24
|
}
|
|
25
25
|
export declare let GUserSer: UserService<UserModel>;
|
|
26
|
-
export declare class UserService<T extends UserModel> extends
|
|
26
|
+
export declare class UserService<T extends UserModel> extends MysqlBaseService<T> {
|
|
27
27
|
constructor(type: {
|
|
28
28
|
new (): T;
|
|
29
29
|
});
|
|
@@ -20,6 +20,7 @@ export declare class Response {
|
|
|
20
20
|
renderJson500(origin?: string | string[] | undefined): void;
|
|
21
21
|
renderHtml(html: string): void;
|
|
22
22
|
render404(html?: string): void;
|
|
23
|
+
render500(html?: string): void;
|
|
23
24
|
renderOptions(method: any, origin: any): void;
|
|
24
25
|
renderFile(fullPath: string): void;
|
|
25
26
|
downloadFile(fullPath: string): void;
|
package/dist/types/cgserver.d.ts
CHANGED
|
@@ -19,12 +19,12 @@ export { Property } from './Database/Decorator/Property';
|
|
|
19
19
|
export { Table } from './Database/Decorator/Table';
|
|
20
20
|
export { Type } from './Database/Decorator/Type';
|
|
21
21
|
export { EPropertyType } from './Database/Decorator/Property';
|
|
22
|
-
export {
|
|
23
|
-
export { BaseModel as MysqlBaseModel } from './Database/
|
|
22
|
+
export { MongoBaseService } from './Database/MongoBaseService';
|
|
23
|
+
export { BaseModel as MysqlBaseModel } from './Database/MysqlBaseService';
|
|
24
24
|
export { MongoBaseModel } from './Database/MongoManager';
|
|
25
25
|
export { GMongoMgr } from './Database/MongoManager';
|
|
26
26
|
export { GMSSqlMgr } from './Database/MSSqlManager';
|
|
27
|
-
export {
|
|
27
|
+
export { MysqlBaseService } from './Database/MysqlBaseService';
|
|
28
28
|
export { GMysqlMgr } from './Database/MysqlManager';
|
|
29
29
|
export { GRedisMgr, RedisManager } from './Database/RedisManager';
|
|
30
30
|
export { GCacheTool } from './Logic/CacheTool';
|
|
@@ -72,3 +72,9 @@ export { RazorJs } from './WebServer/Engine/RazorJs';
|
|
|
72
72
|
export { Request } from './WebServer/Engine/Request';
|
|
73
73
|
export { Response } from './WebServer/Engine/Response';
|
|
74
74
|
export { WebServerConfig } from './Config/FrameworkConfig';
|
|
75
|
+
declare class CgServer {
|
|
76
|
+
constructor();
|
|
77
|
+
init(): void;
|
|
78
|
+
onUnCaughtException(e: any): void;
|
|
79
|
+
}
|
|
80
|
+
export declare let GCgServer: CgServer;
|