cgserver 12.3.5 → 13.0.0
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/README.md +3 -1
- package/dist/lib/Framework/Config/_error_.js +33 -24
- package/dist/lib/Framework/Database/Mongo/MongoBaseService.js +151 -128
- package/dist/lib/Framework/Database/Mongo/MongoManager.js +18 -561
- package/dist/lib/Framework/Decorator/JsonAuthorityValidate.js +1 -5
- package/dist/lib/Framework/Decorator/SyncCallServer.js +2 -2
- package/dist/lib/Framework/Logic/Log.js +20 -5
- package/dist/lib/Framework/Server/WebServer/Controller/MongoBaseUserController.js +12 -30
- package/dist/lib/Framework/Server/WebServer/Controller/MysqlBaseUserController.js +0 -30
- package/dist/lib/Framework/Service/MongoAccountService.js +53 -116
- package/dist/lib/Framework/Service/MongoCacheService.js +23 -19
- package/dist/lib/Framework/Service/MongoUserService.js +39 -77
- package/dist/lib/Framework/Service/MysqlUserService.js +3 -12
- package/dist/lib/Framework/Service/ini.js +4 -10
- package/dist/lib/Framework/global.js +0 -2
- package/dist/lib/Framework/index_export_.js +2 -23
- package/dist/types/Framework/Config/_error_.d.ts +28 -92
- package/dist/types/Framework/Database/Mongo/MongoBaseService.d.ts +35 -113
- package/dist/types/Framework/Database/Mongo/MongoManager.d.ts +4 -145
- package/dist/types/Framework/Decorator/JsonAuthorityValidate.d.ts +1 -2
- package/dist/types/Framework/Logic/Log.d.ts +5 -5
- package/dist/types/Framework/Server/WebServer/Controller/MongoBaseUserController.d.ts +4 -8
- package/dist/types/Framework/Server/WebServer/Controller/MysqlBaseUserController.d.ts +0 -4
- package/dist/types/Framework/Service/MongoAccountService.d.ts +15 -17
- package/dist/types/Framework/Service/MongoCacheService.d.ts +6 -5
- package/dist/types/Framework/Service/MongoUserService.d.ts +14 -26
- package/dist/types/Framework/Service/MysqlUserService.d.ts +2 -4
- package/dist/types/Framework/Service/ini.d.ts +3 -8
- package/dist/types/Framework/global.d.ts +0 -1
- package/dist/types/Framework/index_export_.d.ts +5 -13
- package/package.json +2 -1
- package/dist/lib/Framework/Database/Mongo/MongoServiceManager.js +0 -52
- package/dist/lib/Framework/Decorator/AdminValidate.js +0 -18
- package/dist/lib/Framework/Decorator/AuthorityValidate.js +0 -22
- package/dist/lib/Framework/Decorator/CreatorValidate.js +0 -18
- package/dist/lib/Framework/Decorator/JsonCreatorValidate.js +0 -18
- package/dist/types/Framework/Database/Mongo/MongoServiceManager.d.ts +0 -13
- package/dist/types/Framework/Decorator/AdminValidate.d.ts +0 -1
- package/dist/types/Framework/Decorator/AuthorityValidate.d.ts +0 -2
- package/dist/types/Framework/Decorator/CreatorValidate.d.ts +0 -1
- package/dist/types/Framework/Decorator/JsonCreatorValidate.d.ts +0 -1
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
2
|
export declare class MongoConfig {
|
|
3
3
|
open: boolean;
|
|
4
4
|
host: string;
|
|
5
5
|
port: number;
|
|
6
|
-
options:
|
|
6
|
+
options: mongoose.ConnectOptions;
|
|
7
7
|
database: string;
|
|
8
8
|
debug: boolean;
|
|
9
9
|
}
|
|
10
|
-
export
|
|
11
|
-
_id: mongo.ObjectId;
|
|
10
|
+
export interface IMongoBaseModel extends mongoose.Document {
|
|
12
11
|
}
|
|
13
12
|
export declare class MrResult {
|
|
14
13
|
/**
|
|
@@ -50,161 +49,21 @@ export declare class MongoManager {
|
|
|
50
49
|
export declare class MongoExt {
|
|
51
50
|
protected _mongocfg: MongoConfig;
|
|
52
51
|
protected _init_cbs: any[];
|
|
53
|
-
protected _mongoDb: mongo.Db;
|
|
54
|
-
get mongoDb(): mongo.Db;
|
|
55
|
-
protected _mongoClient: mongo.MongoClient;
|
|
56
|
-
get mongoClient(): mongo.MongoClient;
|
|
57
52
|
protected _mongo_init_succ: boolean;
|
|
58
53
|
protected _inited: boolean;
|
|
59
54
|
get isValid(): boolean;
|
|
60
55
|
constructor();
|
|
61
56
|
init(cfg: MongoConfig): Promise<boolean>;
|
|
62
|
-
onConnectionCreated(event: mongo.ConnectionCreatedEvent): void;
|
|
63
|
-
onConnectionReady(event: mongo.ConnectionReadyEvent): void;
|
|
64
|
-
onConnectionClosed(event: mongo.ConnectionClosedEvent): void;
|
|
65
57
|
close(force?: boolean): void;
|
|
66
58
|
registerInitCb(cb: Function): void;
|
|
67
59
|
onOpen(): void;
|
|
68
60
|
onClose(): void;
|
|
61
|
+
onError(err: Error): void;
|
|
69
62
|
/**
|
|
70
63
|
* 获取自增长id
|
|
71
64
|
* @param key
|
|
72
65
|
* @returns 小于等于0为异常
|
|
73
66
|
*/
|
|
74
67
|
getAutoIds(key: string): Promise<number>;
|
|
75
|
-
protected _convertWhere(where?: {
|
|
76
|
-
[key: string]: any;
|
|
77
|
-
}): {
|
|
78
|
-
[key: string]: any;
|
|
79
|
-
};
|
|
80
|
-
toObjectId(id: string): mongo.BSON.ObjectId;
|
|
81
|
-
/**
|
|
82
|
-
* 获取单条消息
|
|
83
|
-
* @param collection
|
|
84
|
-
*/
|
|
85
|
-
findOne(collection: string, where?: {
|
|
86
|
-
[key: string]: any;
|
|
87
|
-
}, property?: {
|
|
88
|
-
[key: string]: any;
|
|
89
|
-
}): Promise<{
|
|
90
|
-
errcode: {
|
|
91
|
-
id: number;
|
|
92
|
-
des: string;
|
|
93
|
-
};
|
|
94
|
-
one: any;
|
|
95
|
-
}>;
|
|
96
|
-
distinct(collection: string, key: string | number, where?: {
|
|
97
|
-
[key: string]: any;
|
|
98
|
-
}): Promise<{
|
|
99
|
-
errcode: {
|
|
100
|
-
id: number;
|
|
101
|
-
des: string;
|
|
102
|
-
};
|
|
103
|
-
lst: any;
|
|
104
|
-
}>;
|
|
105
|
-
findMany(collection: string, where?: {
|
|
106
|
-
[key: string]: any;
|
|
107
|
-
}, property?: {
|
|
108
|
-
[key: string]: any;
|
|
109
|
-
}, sort?: {
|
|
110
|
-
[key: string]: any;
|
|
111
|
-
}, skip?: number, limit?: number): Promise<{
|
|
112
|
-
errcode: {
|
|
113
|
-
id: number;
|
|
114
|
-
des: string;
|
|
115
|
-
};
|
|
116
|
-
list: any[];
|
|
117
|
-
}>;
|
|
118
|
-
countDocuments(collection: string, where?: {
|
|
119
|
-
[key: string]: any;
|
|
120
|
-
}, options?: mongo.CountDocumentsOptions): Promise<{
|
|
121
|
-
errcode: {
|
|
122
|
-
id: number;
|
|
123
|
-
des: string;
|
|
124
|
-
};
|
|
125
|
-
count: number;
|
|
126
|
-
}>;
|
|
127
|
-
deleteOne(collection: string, where: {
|
|
128
|
-
[key: string]: any;
|
|
129
|
-
}): Promise<{
|
|
130
|
-
errcode: {
|
|
131
|
-
id: number;
|
|
132
|
-
des: string;
|
|
133
|
-
};
|
|
134
|
-
count: number;
|
|
135
|
-
}>;
|
|
136
|
-
deleteMany(collection: string, where: {
|
|
137
|
-
[key: string]: any;
|
|
138
|
-
}): Promise<{
|
|
139
|
-
errcode: {
|
|
140
|
-
id: number;
|
|
141
|
-
des: string;
|
|
142
|
-
};
|
|
143
|
-
count: number;
|
|
144
|
-
}>;
|
|
145
|
-
/**
|
|
146
|
-
* 插入数据
|
|
147
|
-
* @param collection
|
|
148
|
-
* @param data
|
|
149
|
-
*/
|
|
150
|
-
insertOne(collection: string, data: any): Promise<{
|
|
151
|
-
errcode: {
|
|
152
|
-
id: number;
|
|
153
|
-
des: string;
|
|
154
|
-
};
|
|
155
|
-
rs: mongo.InsertOneResult<any>;
|
|
156
|
-
}>;
|
|
157
|
-
insertManay(collection: string, data: any[]): Promise<{
|
|
158
|
-
errcode: {
|
|
159
|
-
id: number;
|
|
160
|
-
des: string;
|
|
161
|
-
};
|
|
162
|
-
rs: mongo.InsertManyResult<any>;
|
|
163
|
-
}>;
|
|
164
|
-
updateOne(collection: string, where: {
|
|
165
|
-
[key: string]: any;
|
|
166
|
-
}, model: any, options?: mongo.UpdateOptions): Promise<{
|
|
167
|
-
errcode: {
|
|
168
|
-
id: number;
|
|
169
|
-
des: string;
|
|
170
|
-
};
|
|
171
|
-
rs: mongo.UpdateResult;
|
|
172
|
-
}>;
|
|
173
|
-
updateMany(collection: string, where: {
|
|
174
|
-
[key: string]: any;
|
|
175
|
-
}, model: any, options?: mongo.UpdateOptions): Promise<{
|
|
176
|
-
errcode: {
|
|
177
|
-
id: number;
|
|
178
|
-
des: string;
|
|
179
|
-
};
|
|
180
|
-
rs: mongo.Document | mongo.UpdateResult;
|
|
181
|
-
}>;
|
|
182
|
-
createIndex(collection: string, index: any, options?: mongo.CreateIndexesOptions): Promise<{
|
|
183
|
-
errcode: {
|
|
184
|
-
id: number;
|
|
185
|
-
des: string;
|
|
186
|
-
};
|
|
187
|
-
rs: string;
|
|
188
|
-
}>;
|
|
189
|
-
simpleAggregate(collection: string, where?: {
|
|
190
|
-
[key: string]: any;
|
|
191
|
-
}, property?: {
|
|
192
|
-
[key: string]: any;
|
|
193
|
-
}, size?: number, random_size?: number): Promise<{
|
|
194
|
-
errcode: {
|
|
195
|
-
id: number;
|
|
196
|
-
des: string;
|
|
197
|
-
};
|
|
198
|
-
list: any[];
|
|
199
|
-
}>;
|
|
200
|
-
aggregate(collection: string, pipeline?: Document[], options?: mongo.AggregateOptions): mongo.AggregationCursor<mongo.BSON.Document>;
|
|
201
|
-
/**
|
|
202
|
-
* 快速事务
|
|
203
|
-
* @param collection
|
|
204
|
-
* @param cb
|
|
205
|
-
*/
|
|
206
|
-
quickTransaction(cb: Function, options?: mongo.TransactionOptions): Promise<false | any>;
|
|
207
|
-
bulkWrite(collection: string, operations: mongo.AnyBulkWriteOperation<mongo.BSON.Document>[], options?: mongo.BulkWriteOptions): Promise<mongo.BulkWriteResult>;
|
|
208
|
-
findOneAndUpdate(collection: string, filter: any, update: any, options?: mongo.FindOneAndUpdateOptions): Promise<any>;
|
|
209
68
|
}
|
|
210
69
|
export declare let gMongoMgr: MongoManager;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare let JsonAuthorityValidate: (rg?: ERoleGroup) => (target: any, propertyName: string, descriptor: TypedPropertyDescriptor<Function>) => void;
|
|
1
|
+
export declare let JsonAuthorityValidate: () => (target: any, propertyName: string, descriptor: TypedPropertyDescriptor<Function>) => void;
|
|
@@ -6,11 +6,11 @@ export declare class Log {
|
|
|
6
6
|
protected _inited: boolean;
|
|
7
7
|
init(cfg?: log4js.Configuration): void;
|
|
8
8
|
protected _convertMsg(message?: any): any;
|
|
9
|
-
error(message?: any): void;
|
|
10
|
-
info(message: any): void;
|
|
11
|
-
warn(message?: any): void;
|
|
12
|
-
record(message?: any): void;
|
|
13
|
-
clientLog(message?: any): void;
|
|
9
|
+
error(message: any, obj?: any): void;
|
|
10
|
+
info(message: any, obj?: any): void;
|
|
11
|
+
warn(message: any, obj?: any): void;
|
|
12
|
+
record(message: any, obj?: any): void;
|
|
13
|
+
clientLog(message: any, obj?: any): void;
|
|
14
14
|
protected _isObject(param: any): boolean;
|
|
15
15
|
protected _isString(param: any): boolean;
|
|
16
16
|
protected _isNumber(param: any): boolean;
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { BaseController } from './BaseController';
|
|
2
|
-
import {
|
|
3
|
-
export declare class MongoBaseUserController<T extends
|
|
2
|
+
import { IMongoUserModel, MongoUserService } from '../../../Service/MongoUserService';
|
|
3
|
+
export declare class MongoBaseUserController<T extends IMongoUserModel> extends BaseController {
|
|
4
4
|
protected _user_session_id: string;
|
|
5
5
|
protected _self_user: T;
|
|
6
6
|
protected _user: T;
|
|
7
7
|
protected _session_id: string;
|
|
8
|
-
protected _userser: MongoUserService<MongoUserModel>;
|
|
9
8
|
get selfUser(): T;
|
|
10
9
|
get isSelf(): boolean;
|
|
11
10
|
get isLogin(): boolean;
|
|
12
|
-
get
|
|
13
|
-
get isAdmin(): boolean;
|
|
14
|
-
get isProxy(): boolean;
|
|
15
|
-
get isCommon(): boolean;
|
|
11
|
+
get userService(): MongoUserService<T>;
|
|
16
12
|
init(): Promise<void>;
|
|
17
13
|
protected _getUserBySession(session: string): Promise<T>;
|
|
18
14
|
protected _logout(): void;
|
|
@@ -21,7 +17,7 @@ export declare class MongoBaseUserController<T extends MongoUserModel> extends B
|
|
|
21
17
|
* 已经被启用
|
|
22
18
|
*/
|
|
23
19
|
protected _update_session(): Promise<void>;
|
|
24
|
-
update_user(user_id:
|
|
20
|
+
update_user(user_id: string): Promise<void>;
|
|
25
21
|
protected _init_data(datas: any): {
|
|
26
22
|
model: any;
|
|
27
23
|
};
|
|
@@ -8,10 +8,6 @@ export declare class MysqlBaseUserController<T extends MysqlUserModel> extends B
|
|
|
8
8
|
get selfUser(): T;
|
|
9
9
|
get isSelf(): boolean;
|
|
10
10
|
get isLogin(): boolean;
|
|
11
|
-
get isCreator(): boolean;
|
|
12
|
-
get isAdmin(): boolean;
|
|
13
|
-
get isProxy(): boolean;
|
|
14
|
-
get isCommon(): boolean;
|
|
15
11
|
init(): Promise<void>;
|
|
16
12
|
protected _getUserBySession(session: string): Promise<T>;
|
|
17
13
|
protected _logout(): void;
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
import { Errcode } from '../Config/_error_';
|
|
1
3
|
import { MongoBaseService } from '../Database/Mongo/MongoBaseService';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export declare class MongoAccountModel extends MongoBaseModel {
|
|
6
|
-
id: number;
|
|
4
|
+
import { EAccountFrom, EAccountState } from './ini';
|
|
5
|
+
import { IMongoUserModel, MongoUserService } from './MongoUserService';
|
|
6
|
+
export interface IMongoAccountModel extends mongoose.Document {
|
|
7
7
|
phone: string;
|
|
8
8
|
email: string;
|
|
9
9
|
name: string;
|
|
10
10
|
password: string;
|
|
11
11
|
unionid: string;
|
|
12
12
|
openid: string;
|
|
13
|
-
create_time:
|
|
13
|
+
create_time: Date;
|
|
14
14
|
create_ip: string;
|
|
15
|
-
login_time:
|
|
15
|
+
login_time: Date;
|
|
16
16
|
login_ip: string;
|
|
17
|
-
from:
|
|
18
|
-
state:
|
|
17
|
+
from: EAccountFrom;
|
|
18
|
+
state: EAccountState;
|
|
19
19
|
}
|
|
20
|
-
export declare class MongoAccountService<T extends
|
|
20
|
+
export declare class MongoAccountService<T extends IMongoAccountModel> extends MongoBaseService<T> {
|
|
21
|
+
get userService(): MongoUserService<IMongoUserModel>;
|
|
22
|
+
constructor(extaccountdef: mongoose.SchemaDefinition<T>);
|
|
21
23
|
/**
|
|
22
24
|
* 注册新账号
|
|
23
25
|
* @param unionid
|
|
@@ -25,7 +27,7 @@ export declare class MongoAccountService<T extends MongoAccountModel> extends Mo
|
|
|
25
27
|
* @param ip
|
|
26
28
|
* @param from
|
|
27
29
|
*/
|
|
28
|
-
add(
|
|
30
|
+
add(key: string, pass: string, ip: string, from: EAccountFrom): Promise<T>;
|
|
29
31
|
/**
|
|
30
32
|
* 通过第三方信息获取账号
|
|
31
33
|
* @param unionid
|
|
@@ -51,12 +53,8 @@ export declare class MongoAccountService<T extends MongoAccountModel> extends Mo
|
|
|
51
53
|
account: T;
|
|
52
54
|
is_new: boolean;
|
|
53
55
|
}>;
|
|
54
|
-
protected _login(
|
|
55
|
-
errcode:
|
|
56
|
+
protected _login(key: string, pass: string, from: EAccountFrom): Promise<{
|
|
57
|
+
errcode: Errcode;
|
|
56
58
|
account: T;
|
|
57
59
|
}>;
|
|
58
|
-
register(type: EAccountFrom, key: string, password: string, ip: string, extra?: any): Promise<{
|
|
59
|
-
user: MongoUserModel;
|
|
60
|
-
errcode: any;
|
|
61
|
-
}>;
|
|
62
60
|
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
1
2
|
import { MongoBaseService } from "../Database/Mongo/MongoBaseService";
|
|
2
|
-
|
|
3
|
-
export declare class MongoCacheModel extends MongoBaseModel {
|
|
3
|
+
export interface IMongoCacheModel extends mongoose.Document {
|
|
4
4
|
key: string;
|
|
5
5
|
data: any;
|
|
6
|
-
expireAt:
|
|
6
|
+
expireAt: Date;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* mongo版本的缓存服务
|
|
10
10
|
* 可以用来缓存kv数据
|
|
11
11
|
*/
|
|
12
|
-
export declare class MongoCacheService extends MongoBaseService<
|
|
12
|
+
export declare class MongoCacheService extends MongoBaseService<IMongoCacheModel> {
|
|
13
|
+
constructor();
|
|
13
14
|
getData(key: string): Promise<any>;
|
|
14
|
-
addData(key: string, data: any, expireAt?:
|
|
15
|
+
addData(key: string, data: any, expireAt?: Date): Promise<IMongoCacheModel>;
|
|
15
16
|
}
|
|
16
17
|
export declare let gMongoCacheSer: MongoCacheService;
|
|
@@ -1,31 +1,19 @@
|
|
|
1
1
|
import { MongoBaseService } from "../Database/Mongo/MongoBaseService";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import mongoose from "mongoose";
|
|
3
|
+
import { EUserState } from "./ini";
|
|
4
|
+
export interface IMongoUserModel extends mongoose.Document {
|
|
5
|
+
account_id: string;
|
|
6
|
+
state: EUserState;
|
|
7
|
+
is_robot: boolean;
|
|
8
|
+
create_time: Date;
|
|
9
|
+
login_time: Date;
|
|
10
|
+
create_ip: string;
|
|
11
|
+
login_ip: string;
|
|
7
12
|
nickname: string;
|
|
8
|
-
sex: number;
|
|
9
13
|
logo: string;
|
|
10
|
-
|
|
11
|
-
role_group: number;
|
|
12
|
-
role: number;
|
|
13
|
-
phone: string;
|
|
14
|
-
wechat: string;
|
|
15
|
-
qq: string;
|
|
16
|
-
email: string;
|
|
17
|
-
about: string;
|
|
18
|
-
pre_user_id: number;
|
|
19
|
-
exp: number;
|
|
20
|
-
level: number;
|
|
21
|
-
vip_exp: number;
|
|
22
|
-
vip_level: number;
|
|
23
|
-
is_robot: number;
|
|
24
|
-
create_time: number;
|
|
14
|
+
sex: number;
|
|
25
15
|
}
|
|
26
|
-
export declare class MongoUserService<T extends
|
|
27
|
-
|
|
28
|
-
add(account_id:
|
|
29
|
-
getByAccountId(account_id: number): Promise<T>;
|
|
30
|
-
updateBaseInfoByAccount(account_id: number, nickname: string, sex: number, logo: string): Promise<string>;
|
|
16
|
+
export declare class MongoUserService<T extends IMongoUserModel> extends MongoBaseService<T> {
|
|
17
|
+
constructor(extuserdef: mongoose.SchemaDefinition<T>);
|
|
18
|
+
add(account_id: string, nickname?: string, sex?: number, logo?: string): Promise<T>;
|
|
31
19
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { MysqlBaseService, BaseModel } from "../Database/Mysql/MysqlBaseService";
|
|
2
|
-
import { ERoleGroup } from "./ini";
|
|
3
2
|
export declare class MysqlUserModel extends BaseModel {
|
|
4
3
|
id: number;
|
|
5
4
|
account_id: number;
|
|
@@ -25,9 +24,8 @@ export declare class MysqlUserService<T extends MysqlUserModel> extends MysqlBas
|
|
|
25
24
|
constructor(type: {
|
|
26
25
|
new (): T;
|
|
27
26
|
});
|
|
28
|
-
protected _createNewUser(account_id: number, nickname: string, sex: number, logo: string
|
|
27
|
+
protected _createNewUser(account_id: number, nickname: string, sex: number, logo: string): Promise<T>;
|
|
29
28
|
updateBaseInfoByAccount(account_id: number, nickname: string, sex: number, logo: string): Promise<string>;
|
|
30
|
-
add(account_id: number, nickname: string, sex: number, logo: string
|
|
31
|
-
updateRoleGroup(user_id: number, role_group: ERoleGroup): Promise<string>;
|
|
29
|
+
add(account_id: number, nickname: string, sex: number, logo: string): Promise<any>;
|
|
32
30
|
getByAccountId(account_id: number): Promise<T>;
|
|
33
31
|
}
|
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
export declare enum ERoleGroup {
|
|
2
|
-
Creator = 1,//创始人
|
|
3
|
-
Admin = 2,//管理员
|
|
4
|
-
Proxy = 3,//代理
|
|
5
|
-
Common = 4
|
|
6
|
-
}
|
|
7
1
|
export declare enum EUserState {
|
|
2
|
+
Delete = -2,
|
|
8
3
|
Ban = -1,
|
|
9
4
|
Waitting = 0,
|
|
10
|
-
|
|
5
|
+
Normal = 1
|
|
11
6
|
}
|
|
12
7
|
export declare enum EAccountState {
|
|
13
8
|
Delete = -2,
|
|
14
9
|
Ban = -1,
|
|
15
10
|
Waitting = 0,
|
|
16
|
-
|
|
11
|
+
Normal = 1
|
|
17
12
|
}
|
|
18
13
|
export declare enum EAccountFrom {
|
|
19
14
|
Guest = 0,
|
|
@@ -3,7 +3,6 @@ import { core } from "./Core/Core";
|
|
|
3
3
|
* cg引擎的,全局对象
|
|
4
4
|
*/
|
|
5
5
|
export declare class global {
|
|
6
|
-
static gMongoServiceMgr: import("./Database/Mongo/MongoServiceManager").MongoServiceManager;
|
|
7
6
|
static gCgServer: import("./cgserver").CgServer;
|
|
8
7
|
static gDbCache: import("./Database/Decorator/DBCache").DBCache;
|
|
9
8
|
static gTriggerMgr: import("./AI/TriggerMgr").TriggerManager;
|
|
@@ -2,7 +2,6 @@ export { EAlipayExecType, AlipayAppPayParams } from './ThirdParty/AlipayTool';
|
|
|
2
2
|
export { AlipaySdk, AlipaySdkCommonResult, AlipaySdkConfig } from 'alipay-sdk';
|
|
3
3
|
export { AliSmsConfig } from './ThirdParty/Alisms';
|
|
4
4
|
export { CgRankTool, CgRankCommandItem, CgRankRankItem, CgRankRankData } from './ThirdParty/CgRankTool';
|
|
5
|
-
export { MongoServiceManager } from './Database/Mongo/MongoServiceManager';
|
|
6
5
|
export { AiObject } from "./AI/AiObject";
|
|
7
6
|
export { AStar } from "./AI/Astar";
|
|
8
7
|
export { BehaviorAI } from "./AI/BehaviorAI";
|
|
@@ -24,17 +23,17 @@ export { Type } from './Database/Decorator/Type';
|
|
|
24
23
|
export { EPropertyType } from './Database/Decorator/Property';
|
|
25
24
|
export { MongoBaseService } from './Database/Mongo/MongoBaseService';
|
|
26
25
|
export { BaseModel as MysqlBaseModel } from './Database/Mysql/MysqlBaseService';
|
|
27
|
-
export {
|
|
26
|
+
export { IMongoBaseModel, MongoManager, MongoExt } from './Database/Mongo/MongoManager';
|
|
28
27
|
export { MysqlBaseService } from './Database/Mysql/MysqlBaseService';
|
|
29
28
|
export { SqlReturn, SqlReturns } from './Database/Mysql/MysqlManager';
|
|
30
|
-
export {
|
|
29
|
+
export { EUserState, EAccountFrom } from './Service/ini';
|
|
31
30
|
export { MysqlAccountService } from './Service/MysqlAccountService';
|
|
32
|
-
export { MongoAccountService } from './Service/MongoAccountService';
|
|
31
|
+
export { IMongoAccountModel, MongoAccountService } from './Service/MongoAccountService';
|
|
33
32
|
export { MysqlUserService } from './Service/MysqlUserService';
|
|
34
33
|
export { MongoUserService } from './Service/MongoUserService';
|
|
35
34
|
export { MysqlUserModel } from './Service/MysqlUserService';
|
|
36
|
-
export {
|
|
37
|
-
export {
|
|
35
|
+
export { IMongoUserModel } from './Service/MongoUserService';
|
|
36
|
+
export { IMongoCacheModel, MongoCacheService } from './Service/MongoCacheService';
|
|
38
37
|
export { DbConfig } from './Config/DbConfig';
|
|
39
38
|
export { MSSqlConfig } from './Database/MSSql/MSSqlManager';
|
|
40
39
|
export { MongoConfig } from './Database/Mongo/MongoManager';
|
|
@@ -50,16 +49,9 @@ export { IWebSocketServer, WebSocketServerConfig } from './Server/WebSocketServe
|
|
|
50
49
|
export { IWebSocket, BaseMsg } from './Server/WebSocketServer/IWebSocket';
|
|
51
50
|
export { IWebServer } from './Server/WebServer/IWebServer';
|
|
52
51
|
export { BaseController } from './Server/WebServer/Controller/BaseController';
|
|
53
|
-
export { MysqlBaseUserController } from './Server/WebServer/Controller/MysqlBaseUserController';
|
|
54
52
|
export { MongoBaseUserController } from './Server/WebServer/Controller/MongoBaseUserController';
|
|
55
53
|
export { MysqlAccountModel } from './Service/MysqlAccountService';
|
|
56
|
-
export { MongoAccountModel } from './Service/MongoAccountService';
|
|
57
|
-
export { AdminValidate } from './Decorator/AdminValidate';
|
|
58
|
-
export { AuthorityValidate } from './Decorator/AuthorityValidate';
|
|
59
|
-
export { CreatorValidate } from './Decorator/CreatorValidate';
|
|
60
|
-
export { JsonAdminValidate } from './Decorator/JsonAdminValidate';
|
|
61
54
|
export { JsonAuthorityValidate } from './Decorator/JsonAuthorityValidate';
|
|
62
|
-
export { JsonCreatorValidate } from './Decorator/JsonCreatorValidate';
|
|
63
55
|
export { Engine } from './Server/WebServer/Engine/Engine';
|
|
64
56
|
export { RazorJs } from './Server/WebServer/Engine/RazorJs';
|
|
65
57
|
export { Request } from './Server/WebServer/Engine/Request';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cgserver",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"author": "trojan",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"description": "free for all.Websocket or Http",
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"mime": "^3.0.0",
|
|
66
66
|
"minimist": "^1.2.8",
|
|
67
67
|
"mongodb": "^6.15.0",
|
|
68
|
+
"mongoose": "^8.16.5",
|
|
68
69
|
"mssql": "^11.0.1",
|
|
69
70
|
"mysql2": "^3.10.2",
|
|
70
71
|
"nodemailer": "^6.9.10",
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gMongoServiceMgr = exports.MongoServiceManager = void 0;
|
|
4
|
-
const index_export_1 = require("../../index_export_");
|
|
5
|
-
const MongoManager_1 = require("./MongoManager");
|
|
6
|
-
class MongoServiceManager {
|
|
7
|
-
_services = {};
|
|
8
|
-
addService(service) {
|
|
9
|
-
let dbname = service.dbname;
|
|
10
|
-
dbname = this._tryDef(dbname);
|
|
11
|
-
let table = service.table;
|
|
12
|
-
if (!this._services[dbname][table]) {
|
|
13
|
-
this._services[dbname][table] = service;
|
|
14
|
-
}
|
|
15
|
-
return this._services[dbname][table];
|
|
16
|
-
}
|
|
17
|
-
_tryDef(dbname) {
|
|
18
|
-
if (!dbname) {
|
|
19
|
-
dbname = MongoManager_1.gMongoMgr.defdbname;
|
|
20
|
-
if (dbname && !this._services[dbname]) {
|
|
21
|
-
this._services[dbname] = this._services[""];
|
|
22
|
-
delete this._services[""];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
if (dbname == MongoManager_1.gMongoMgr.defdbname && !this._services[dbname]) {
|
|
27
|
-
this._services[dbname] = this._services[""];
|
|
28
|
-
delete this._services[""];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
if (!this._services[dbname]) {
|
|
32
|
-
this._services[dbname] = {};
|
|
33
|
-
}
|
|
34
|
-
return dbname;
|
|
35
|
-
}
|
|
36
|
-
getService(table, dbname = "") {
|
|
37
|
-
dbname = this._tryDef(dbname);
|
|
38
|
-
let tablename = "";
|
|
39
|
-
if (index_export_1.core.isString(table)) {
|
|
40
|
-
tablename = table;
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
tablename = table.table;
|
|
44
|
-
}
|
|
45
|
-
if (!this._services[dbname][tablename]) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
return this._services[dbname][tablename];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.MongoServiceManager = MongoServiceManager;
|
|
52
|
-
exports.gMongoServiceMgr = new MongoServiceManager();
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AdminValidate = AdminValidate;
|
|
4
|
-
function AdminValidate(target, propertyName, descriptor) {
|
|
5
|
-
let method = descriptor.value;
|
|
6
|
-
descriptor.value = function () {
|
|
7
|
-
let self = this;
|
|
8
|
-
if (!self.isLogin) {
|
|
9
|
-
self.redirect(null, "Login");
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
if (!self.isAdmin) {
|
|
13
|
-
self.showText("需要管理员权限");
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
return method.apply(this, arguments);
|
|
17
|
-
};
|
|
18
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AuthorityValidate = void 0;
|
|
4
|
-
let AuthorityValidate = function (rg, ctr_name) {
|
|
5
|
-
ctr_name = ctr_name || "Wechat";
|
|
6
|
-
return function (target, propertyName, descriptor) {
|
|
7
|
-
let method = descriptor.value;
|
|
8
|
-
descriptor.value = function () {
|
|
9
|
-
let self = this;
|
|
10
|
-
if (!self.isLogin) {
|
|
11
|
-
self.redirect(null, ctr_name);
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
if (rg && self.selfUser.role_group != rg) {
|
|
15
|
-
self.redirect(null, ctr_name); //权限不足
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
return method.apply(this, arguments);
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
exports.AuthorityValidate = AuthorityValidate;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CreatorValidate = CreatorValidate;
|
|
4
|
-
function CreatorValidate(target, propertyName, descriptor) {
|
|
5
|
-
let method = descriptor.value;
|
|
6
|
-
descriptor.value = function () {
|
|
7
|
-
let self = this;
|
|
8
|
-
if (!self.isLogin) {
|
|
9
|
-
self.redirect(null, "Login");
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
if (!self.isCreator) {
|
|
13
|
-
self.showText("需要创始人权限");
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
return method.apply(this, arguments);
|
|
17
|
-
};
|
|
18
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JsonCreatorValidate = JsonCreatorValidate;
|
|
4
|
-
function JsonCreatorValidate(target, propertyName, descriptor) {
|
|
5
|
-
let method = descriptor.value;
|
|
6
|
-
descriptor.value = function () {
|
|
7
|
-
let self = this;
|
|
8
|
-
if (!self.isLogin) {
|
|
9
|
-
self.showJson({ errcode: { id: 1, des: "请登陆后尝试" }, err: "请登陆后尝试" });
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
if (!self.isCreator) {
|
|
13
|
-
self.showJson({ errcode: { id: 1, des: "需要创始人权限" }, err: "需要创始人权限" });
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
return method.apply(this, arguments);
|
|
17
|
-
};
|
|
18
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { MongoBaseService } from "./MongoBaseService";
|
|
2
|
-
import { MongoBaseModel } from "./MongoManager";
|
|
3
|
-
export declare class MongoServiceManager {
|
|
4
|
-
protected _services: {
|
|
5
|
-
[dbname: string]: {
|
|
6
|
-
[table: string]: MongoBaseService<MongoBaseModel>;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
addService<T extends MongoBaseService<MongoBaseModel>>(service: T): T;
|
|
10
|
-
protected _tryDef(dbname: string): string;
|
|
11
|
-
getService<T extends MongoBaseService<MongoBaseModel>>(table: T | string, dbname?: string): T;
|
|
12
|
-
}
|
|
13
|
-
export declare let gMongoServiceMgr: MongoServiceManager;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function AdminValidate(target: any, propertyName: string, descriptor: TypedPropertyDescriptor<Function>): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function CreatorValidate(target: any, propertyName: string, descriptor: TypedPropertyDescriptor<Function>): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function JsonCreatorValidate(target: any, propertyName: string, descriptor: TypedPropertyDescriptor<Function>): void;
|