cgserver 13.3.4 → 14.0.1

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.
@@ -1,49 +1,16 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
2
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
23
7
  };
24
- var __importStar = (this && this.__importStar) || (function () {
25
- var ownKeys = function(o) {
26
- ownKeys = Object.getOwnPropertyNames || function (o) {
27
- var ar = [];
28
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
- return ar;
30
- };
31
- return ownKeys(o);
32
- };
33
- return function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- })();
41
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
42
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
43
10
  };
44
11
  Object.defineProperty(exports, "__esModule", { value: true });
45
12
  exports.GMongoAutoIdsSer = exports.MongoBaseService = void 0;
46
- const mongoose_1 = __importStar(require("mongoose"));
13
+ const mongoose_1 = __importDefault(require("mongoose"));
47
14
  const Log_1 = require("../../Logic/Log");
48
15
  const MongoManager_1 = require("./MongoManager");
49
16
  const SyncCall_1 = require("../../Decorator/SyncCall");
@@ -103,8 +70,8 @@ class MongoBaseService {
103
70
  let ret = await this.mongo.create(this.model, doc);
104
71
  return ret;
105
72
  }
106
- async insert(doc) {
107
- let ret = await this.mongo.insert(this.model, doc);
73
+ async insert(doc, options) {
74
+ let ret = await this.mongo.insert(this.model, doc, options);
108
75
  return ret;
109
76
  }
110
77
  async updateOne(filter, update, options) {
@@ -147,7 +114,7 @@ class MongoBaseService {
147
114
  }
148
115
  }
149
116
  exports.MongoBaseService = MongoBaseService;
150
- const autoIdSchema = new mongoose_1.Schema({
117
+ const autoIdSchema = new mongoose_1.default.Schema({
151
118
  _id: { type: String },
152
119
  autoid: { type: Number, required: true, default: 0 }
153
120
  }, { id: false });
@@ -10,10 +10,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.gMongoMgr = exports.MongoExt = exports.MongoManager = exports.MgReturn = exports.MrResult = exports.MongoConfig = void 0;
13
- const mongoose_1 = require("mongoose");
14
13
  const Core_1 = require("../../Core/Core");
15
14
  const Log_1 = require("../../Logic/Log");
16
- const mongoose_2 = __importDefault(require("mongoose"));
15
+ const mongoose_1 = __importDefault(require("mongoose"));
17
16
  const MongoActionCheck_1 = require("../../Decorator/MongoActionCheck");
18
17
  class MongoConfig {
19
18
  open = false;
@@ -141,15 +140,15 @@ class MongoExt {
141
140
  this._inited = true;
142
141
  Log_1.gLog.info("mongo config=" + JSON.stringify(this._mongocfg));
143
142
  this._mongocfg.options.dbName = this._mongocfg.database;
144
- this._connection = mongoose_2.default.createConnection("mongodb://" + this._mongocfg.host + ":" + this._mongocfg.port, this._mongocfg.options);
143
+ this._connection = mongoose_1.default.createConnection("mongodb://" + this._mongocfg.host + ":" + this._mongocfg.port, this._mongocfg.options);
145
144
  this._connection = this._connection.useDb(this._mongocfg.database);
146
145
  this._connection.once("open", this.onOpen.bind(this));
147
146
  this._connection.on("close", this.onClose.bind(this));
148
147
  this._connection.on("connectionCreated", this.onConnect.bind(this));
149
148
  this._connection.on("connectionClosed", this.onDisconnect.bind(this));
150
149
  await this._connection.asPromise();
151
- while (this._connection.readyState != mongoose_1.ConnectionStates.connected) {
152
- if (this._connection.readyState != mongoose_1.ConnectionStates.connecting) {
150
+ while (this._connection.readyState != mongoose_1.default.ConnectionStates.connected) {
151
+ if (this._connection.readyState != mongoose_1.default.ConnectionStates.connecting) {
153
152
  Log_1.gLog.error("MongoDB connection is not ready, please check the connection settings. Current state: " + this._connection.readyState);
154
153
  return false;
155
154
  }
@@ -236,12 +235,12 @@ class MongoExt {
236
235
  let one = await newDoc.save();
237
236
  return one;
238
237
  }
239
- async insert(model, doc) {
238
+ async insert(model, doc, options) {
240
239
  if (!model) {
241
240
  Log_1.gLog.error("Model is not defined");
242
241
  return null;
243
242
  }
244
- const newDoc = await model.insertOne(doc);
243
+ const newDoc = await model.insertOne(doc, options);
245
244
  return newDoc;
246
245
  }
247
246
  async updateOne(model, filter, update, options) {
@@ -322,7 +321,7 @@ class MongoExt {
322
321
  return {};
323
322
  }
324
323
  if (filter.id && typeof filter.id === 'string') {
325
- filter._id = new mongoose_1.Types.ObjectId(filter.id);
324
+ filter._id = new mongoose_1.default.Types.ObjectId(filter.id);
326
325
  delete filter.id;
327
326
  }
328
327
  else if (filter.id) {
@@ -335,7 +334,7 @@ class MongoExt {
335
334
  if (!one) {
336
335
  return one;
337
336
  }
338
- if (typeof one._id === 'object' && one._id instanceof mongoose_1.Types.ObjectId) {
337
+ if (typeof one._id === 'object' && one._id instanceof mongoose_1.default.Types.ObjectId) {
339
338
  one.id = one._id.toString();
340
339
  }
341
340
  else {
@@ -32,9 +32,12 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
35
38
  Object.defineProperty(exports, "__esModule", { value: true });
36
39
  exports.gHttpTool = exports.HttpTool = void 0;
37
- const request = __importStar(require("request"));
40
+ const axios_1 = __importDefault(require("axios"));
38
41
  const qs = __importStar(require("querystring"));
39
42
  const Core_1 = require("../Core/Core");
40
43
  const Log_1 = require("./Log");
@@ -46,91 +49,129 @@ class HttpTool {
46
49
  set debug(value) {
47
50
  this._debug = value;
48
51
  }
49
- get(options_url) {
50
- let time = Date.now();
51
- let options = null;
52
- if (Core_1.core.isString(options_url)) {
53
- options = { url: options_url };
52
+ get(config) {
53
+ const time = Date.now();
54
+ config.method = 'GET';
55
+ // Support legacy qs/form style fields passed in config
56
+ if (config.qs && Core_1.core.isObject(config.qs)) {
57
+ const q = qs.stringify(config.qs);
58
+ config.url = config.url + (config.url.indexOf('?') === -1 ? '?' + q : '&' + q);
54
59
  }
55
- else {
56
- options = options_url;
60
+ if (config.form && Core_1.core.isObject(config.form)) {
61
+ config.headers = { ...(config.headers || {}), 'Content-Type': 'application/x-www-form-urlencoded' };
62
+ config.data = qs.stringify(config.form);
57
63
  }
58
64
  if (this._debug) {
59
- Log_1.gLog.info("prepare get:" + options.url);
65
+ Log_1.gLog.info("prepare get:" + config.url);
60
66
  }
61
- return new Promise((resolve, reject) => {
62
- request.get(options, (error, response, body) => {
63
- let originbody = body;
64
- if (error) {
65
- Log_1.gLog.error("get:" + options.url);
66
- Log_1.gLog.error(error);
67
- }
67
+ return (0, axios_1.default)(config).then(resp => {
68
+ let originbody = resp.data;
69
+ let body = originbody;
70
+ if (Core_1.core.isString(originbody)) {
68
71
  try {
69
- if (Core_1.core.isString(body)) {
70
- body = JSON.parse(body);
71
- }
72
+ body = JSON.parse(originbody);
72
73
  }
73
74
  catch (e) {
74
75
  try {
75
- body = qs.parse(body);
76
+ body = qs.parse(originbody);
76
77
  }
77
- catch (e) {
78
+ catch (e2) {
78
79
  body = originbody;
79
80
  }
80
81
  }
81
- if (this._debug) {
82
- Log_1.gLog.info({
83
- dttime: (Date.now() - time) + "ms",
84
- url: options.url,
85
- originbody: originbody
86
- });
82
+ }
83
+ if (this._debug) {
84
+ Log_1.gLog.info({ dttime: (Date.now() - time) + "ms", url: config.url, originbody });
85
+ }
86
+ return { error: null, response: resp, body, originbody };
87
+ }).catch(err => {
88
+ const resp = err.response || null;
89
+ let originbody = resp ? resp.data : null;
90
+ let body = originbody;
91
+ if (Core_1.core.isString(originbody)) {
92
+ try {
93
+ body = JSON.parse(originbody);
94
+ }
95
+ catch (e) {
96
+ try {
97
+ body = qs.parse(originbody);
98
+ }
99
+ catch (e2) {
100
+ body = originbody;
101
+ }
87
102
  }
88
- resolve({ error, response, body, originbody });
89
- });
103
+ }
104
+ Log_1.gLog.error("get:" + config.url);
105
+ Log_1.gLog.error(err);
106
+ if (this._debug) {
107
+ Log_1.gLog.info({ dttime: (Date.now() - time) + "ms", url: config.url, originbody });
108
+ }
109
+ return { error: err, response: resp, body, originbody };
90
110
  });
91
111
  }
92
- post(options_url) {
93
- let time = Date.now();
94
- let options = null;
95
- if (Core_1.core.isString(options_url)) {
96
- options = { url: options_url };
112
+ post(config) {
113
+ const time = Date.now();
114
+ config.method = 'POST';
115
+ // Legacy fields mapping
116
+ if (config.qs && Core_1.core.isObject(config.qs)) {
117
+ const q = qs.stringify(config.qs);
118
+ config.url = config.url + (config.url.indexOf('?') === -1 ? '?' + q : '&' + q);
119
+ }
120
+ if (config.formData && Core_1.core.isObject(config.formData)) {
121
+ // If user wants multipart they should provide FormData or appropriate headers; keep raw assignment
122
+ config.data = config.formData;
97
123
  }
98
- else {
99
- options = options_url;
124
+ else if (config.form && Core_1.core.isObject(config.form)) {
125
+ config.headers = { ...(config.headers || {}), 'Content-Type': 'application/x-www-form-urlencoded' };
126
+ config.data = qs.stringify(config.form);
100
127
  }
101
128
  if (this._debug) {
102
- Log_1.gLog.info("prepare post:" + options.url);
103
- Log_1.gLog.info("prepare post data:" + JSON.stringify(options.json || options.body || options.formData || options.form || options.qs));
129
+ Log_1.gLog.info("prepare post:" + config.url);
130
+ Log_1.gLog.info("prepare post data:" + JSON.stringify(config.data));
104
131
  }
105
- return new Promise((resolve, reject) => {
106
- request.post(options, (error, response, body) => {
107
- let originbody = body;
108
- if (error) {
109
- Log_1.gLog.error("post:" + options.url);
110
- Log_1.gLog.error(error);
111
- }
132
+ return (0, axios_1.default)(config).then(resp => {
133
+ let originbody = resp.data;
134
+ let body = originbody;
135
+ if (Core_1.core.isString(originbody)) {
112
136
  try {
113
- if (Core_1.core.isString(body)) {
114
- body = JSON.parse(body);
115
- }
137
+ body = JSON.parse(originbody);
116
138
  }
117
139
  catch (e) {
118
140
  try {
119
- body = qs.parse(body);
141
+ body = qs.parse(originbody);
120
142
  }
121
- catch (e) {
143
+ catch (e2) {
122
144
  body = originbody;
123
145
  }
124
146
  }
125
- if (this._debug) {
126
- Log_1.gLog.info({
127
- dttime: (Date.now() - time) + "ms",
128
- url: options.url,
129
- originbody: originbody
130
- });
147
+ }
148
+ if (this._debug) {
149
+ Log_1.gLog.info({ dttime: (Date.now() - time) + "ms", url: config.url, originbody });
150
+ }
151
+ return { error: null, response: resp, body, originbody };
152
+ }).catch(err => {
153
+ const resp = err.response || null;
154
+ let originbody = resp ? resp.data : null;
155
+ let body = originbody;
156
+ if (Core_1.core.isString(originbody)) {
157
+ try {
158
+ body = JSON.parse(originbody);
159
+ }
160
+ catch (e) {
161
+ try {
162
+ body = qs.parse(originbody);
163
+ }
164
+ catch (e2) {
165
+ body = originbody;
166
+ }
131
167
  }
132
- resolve({ error, response, body, originbody });
133
- });
168
+ }
169
+ Log_1.gLog.error("post:" + config.url);
170
+ Log_1.gLog.error(err);
171
+ if (this._debug) {
172
+ Log_1.gLog.info({ dttime: (Date.now() - time) + "ms", url: config.url, originbody });
173
+ }
174
+ return { error: err, response: resp, body, originbody };
134
175
  });
135
176
  }
136
177
  }
@@ -103,7 +103,7 @@ class Response {
103
103
  let size = stats.size;
104
104
  var f = fs.createReadStream(fullPath);
105
105
  this._res.writeHead(200, {
106
- 'Content-Type': mime.getType(fullPath) || 'application/octet-stream',
106
+ 'Content-Type': mime.default.getType(fullPath) || 'application/octet-stream',
107
107
  'Content-Disposition': 'attachment; filename=' + fileName,
108
108
  'Content-Length': size
109
109
  });
@@ -207,12 +207,12 @@ class AppleTool {
207
207
  reqb.password = password;
208
208
  reqb['exclude-old-transactions'] = exclude_old_transactions;
209
209
  //先验证生产环境
210
- var resb = (await HttpTool_1.gHttpTool.post({ url, form: JSON.stringify(reqb) })).body;
210
+ var resb = (await HttpTool_1.gHttpTool.post({ url, data: reqb })).body;
211
211
  Log_1.gLog.info("production end onVerify_Res============================status=" + (resb ? resb.status : "null"));
212
212
  //状态21007表示是沙盒环境
213
213
  if (resb && resb.status == 21007) {
214
214
  url = this._sandboxVerifyUrl;
215
- resb = (await HttpTool_1.gHttpTool.post({ url, form: JSON.stringify(reqb) })).body;
215
+ resb = (await HttpTool_1.gHttpTool.post({ url, data: reqb })).body;
216
216
  Log_1.gLog.info("sandbox end onVerify_Res============================status=" + (resb ? resb.status : "null"));
217
217
  }
218
218
  Log_1.gLog.info(resb);
@@ -46,7 +46,7 @@ class CgRankTool {
46
46
  timeout: timeout,
47
47
  password: this._password
48
48
  };
49
- await HttpTool_1.gHttpTool.post({ url: this._url, json: msg });
49
+ await HttpTool_1.gHttpTool.post({ url: this._url, data: msg });
50
50
  return;
51
51
  }
52
52
  async getTimeout(key) {
@@ -55,7 +55,7 @@ class CgRankTool {
55
55
  key: key,
56
56
  password: this._password
57
57
  };
58
- let rs = await HttpTool_1.gHttpTool.post({ url: this._url, json: msg });
58
+ let rs = await HttpTool_1.gHttpTool.post({ url: this._url, data: msg });
59
59
  return rs.body;
60
60
  }
61
61
  /**
@@ -69,7 +69,7 @@ class CgRankTool {
69
69
  key: key,
70
70
  password: this._password
71
71
  };
72
- let rs = await HttpTool_1.gHttpTool.post({ url: this._url, json: msg });
72
+ let rs = await HttpTool_1.gHttpTool.post({ url: this._url, data: msg });
73
73
  return rs.body;
74
74
  }
75
75
  async saveAllRank() {
@@ -77,7 +77,7 @@ class CgRankTool {
77
77
  cmd: "saveAllRank",
78
78
  password: this._password
79
79
  };
80
- let rs = await HttpTool_1.gHttpTool.post({ url: this._url, json: msg });
80
+ let rs = await HttpTool_1.gHttpTool.post({ url: this._url, data: msg });
81
81
  return rs.body;
82
82
  }
83
83
  async getRankItem(key, id) {
@@ -87,7 +87,7 @@ class CgRankTool {
87
87
  id: id,
88
88
  password: this._password
89
89
  };
90
- let rs = await HttpTool_1.gHttpTool.post({ url: this._url, json: msg });
90
+ let rs = await HttpTool_1.gHttpTool.post({ url: this._url, data: msg });
91
91
  return rs.body;
92
92
  }
93
93
  async getRankItems(key, ids) {
@@ -97,7 +97,7 @@ class CgRankTool {
97
97
  ids: ids,
98
98
  password: this._password
99
99
  };
100
- let rs = await HttpTool_1.gHttpTool.post({ url: this._url, json: msg });
100
+ let rs = await HttpTool_1.gHttpTool.post({ url: this._url, data: msg });
101
101
  return rs.body;
102
102
  }
103
103
  /**
@@ -114,7 +114,7 @@ class CgRankTool {
114
114
  count: count,
115
115
  password: this._password
116
116
  };
117
- let rs = await HttpTool_1.gHttpTool.post({ url: this._url, json: msg });
117
+ let rs = await HttpTool_1.gHttpTool.post({ url: this._url, data: msg });
118
118
  return rs.body;
119
119
  }
120
120
  async getRankCount(key) {
@@ -123,7 +123,7 @@ class CgRankTool {
123
123
  key: key,
124
124
  password: this._password
125
125
  };
126
- let rs = await HttpTool_1.gHttpTool.post({ url: this._url, json: msg });
126
+ let rs = await HttpTool_1.gHttpTool.post({ url: this._url, data: msg });
127
127
  return rs.body;
128
128
  }
129
129
  async getRevRankList(key, start, count) {
@@ -134,7 +134,7 @@ class CgRankTool {
134
134
  count: count,
135
135
  password: this._password
136
136
  };
137
- let rs = await HttpTool_1.gHttpTool.post({ url: this._url, json: msg });
137
+ let rs = await HttpTool_1.gHttpTool.post({ url: this._url, data: msg });
138
138
  return rs.body;
139
139
  }
140
140
  async addToRank(key, id, score, other, isreplace = false) {
@@ -147,7 +147,7 @@ class CgRankTool {
147
147
  isreplace: isreplace,
148
148
  password: this._password
149
149
  };
150
- let rs = await HttpTool_1.gHttpTool.post({ url: this._url, json: msg });
150
+ let rs = await HttpTool_1.gHttpTool.post({ url: this._url, data: msg });
151
151
  return rs.body;
152
152
  }
153
153
  async addsToRank(key, datas, isreplace = false) {
@@ -158,7 +158,7 @@ class CgRankTool {
158
158
  isreplace: isreplace,
159
159
  password: this._password
160
160
  };
161
- let rs = await HttpTool_1.gHttpTool.post({ url: this._url, json: msg });
161
+ let rs = await HttpTool_1.gHttpTool.post({ url: this._url, data: msg });
162
162
  return rs.body;
163
163
  }
164
164
  async removeFromRank(key, id) {
@@ -168,7 +168,7 @@ class CgRankTool {
168
168
  id: id,
169
169
  password: this._password
170
170
  };
171
- let rs = await HttpTool_1.gHttpTool.post({ url: this._url, json: msg });
171
+ let rs = await HttpTool_1.gHttpTool.post({ url: this._url, data: msg });
172
172
  return rs.body;
173
173
  }
174
174
  async updateInRank(key, command) {
@@ -178,7 +178,7 @@ class CgRankTool {
178
178
  command: command,
179
179
  password: this._password
180
180
  };
181
- let rs = await HttpTool_1.gHttpTool.post({ url: this._url, json: msg });
181
+ let rs = await HttpTool_1.gHttpTool.post({ url: this._url, data: msg });
182
182
  return rs.body;
183
183
  }
184
184
  async updatesInRank(key, commands) {
@@ -188,7 +188,7 @@ class CgRankTool {
188
188
  commands: commands,
189
189
  password: this._password
190
190
  };
191
- let rs = await HttpTool_1.gHttpTool.post({ url: this._url, json: msg });
191
+ let rs = await HttpTool_1.gHttpTool.post({ url: this._url, data: msg });
192
192
  return rs.body;
193
193
  }
194
194
  async executeCommand(key, commands) {
@@ -198,7 +198,7 @@ class CgRankTool {
198
198
  commands: commands,
199
199
  password: this._password
200
200
  };
201
- let rs = await HttpTool_1.gHttpTool.post({ url: this._url, json: msg });
201
+ let rs = await HttpTool_1.gHttpTool.post({ url: this._url, data: msg });
202
202
  return rs.body;
203
203
  }
204
204
  async anyCall(call, ...args) {
@@ -207,7 +207,7 @@ class CgRankTool {
207
207
  args: args,
208
208
  password: this._password
209
209
  };
210
- let rs = await HttpTool_1.gHttpTool.post({ url: this._url, json: msg });
210
+ let rs = await HttpTool_1.gHttpTool.post({ url: this._url, data: msg });
211
211
  return rs.body;
212
212
  }
213
213
  }
@@ -115,7 +115,7 @@ class QQTool {
115
115
  //必须 成功授权后的回调地址,必须是注册appid时填写的主域名下的地址,建议设置为网站首页或网站的用户中心
116
116
  let redirect_uri = URLEncode.encode(IServerConfig_1.gServerCfg.qq.redirect_uri);
117
117
  let url = "https://graph.qq.com/oauth2.0/token?code=" + auth_code + "&grant_type=" + grant_type + "&client_id=" + client_id + "&client_secret=" + client_secret + "&redirect_uri=" + redirect_uri;
118
- let rs = await HttpTool_1.gHttpTool.get(url);
118
+ let rs = await HttpTool_1.gHttpTool.get({ url });
119
119
  if (rs.body && rs.body.access_token) {
120
120
  return rs.body.access_token;
121
121
  }
@@ -126,8 +126,8 @@ class QQTool {
126
126
  }
127
127
  async getOpenId(access_token) {
128
128
  let url = "https://graph.qq.com/oauth2.0/me?access_token=" + access_token;
129
- let rs = await HttpTool_1.gHttpTool.get(url);
130
- let body = rs.response ? rs.response.body : null;
129
+ let rs = await HttpTool_1.gHttpTool.get({ url });
130
+ let body = rs.response ? rs.response.data : null;
131
131
  if (body) {
132
132
  body = body.replace("callback( ", "");
133
133
  body = body.replace(" );\n", "");
@@ -136,7 +136,7 @@ class QQTool {
136
136
  }
137
137
  catch (e) { }
138
138
  if (!body.openid) {
139
- Log_1.gLog.error(rs.response.body);
139
+ Log_1.gLog.error(rs.response.data);
140
140
  }
141
141
  return body.openid;
142
142
  }
@@ -151,7 +151,7 @@ class QQTool {
151
151
  return null;
152
152
  }
153
153
  let url = "https://graph.qq.com/user/get_user_info?access_token=" + access_token + "&oauth_consumer_key=" + IServerConfig_1.gServerCfg.qq.app_id + "&openid=" + openid;
154
- let rs = await HttpTool_1.gHttpTool.get(url);
154
+ let rs = await HttpTool_1.gHttpTool.get({ url });
155
155
  if (rs.body) {
156
156
  return rs.body;
157
157
  }
@@ -40,14 +40,6 @@ const IServerConfig_1 = require("../Config/IServerConfig");
40
40
  const Log_1 = require("../Logic/Log");
41
41
  const HttpTool_1 = require("../Logic/HttpTool");
42
42
  class WechatOAMsg {
43
- // <xml>
44
- // <ToUserName><![CDATA[toUser]]></ToUserName>
45
- // <FromUserName><![CDATA[fromUser]]></FromUserName>
46
- // <CreateTime>1348831860</CreateTime>
47
- // <MsgType><![CDATA[text]]></MsgType>
48
- // <Content><![CDATA[this is a test]]></Content>
49
- // <MsgId>1234567890123456</MsgId>
50
- // </xml>
51
43
  toUserName = "";
52
44
  fromUserName = ""; //其实是一个userid
53
45
  createTime = -1;
@@ -97,7 +89,7 @@ class WechatTool {
97
89
  return null;
98
90
  }
99
91
  let url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + IServerConfig_1.gServerCfg.wechat.app_id + "&secret=" + IServerConfig_1.gServerCfg.wechat.app_key + "&code=" + auth_code + "&grant_type=authorization_code";
100
- let rs = await HttpTool_1.gHttpTool.get(url);
92
+ let rs = await HttpTool_1.gHttpTool.get({ url });
101
93
  /*
102
94
  {
103
95
  "access_token":"ACCESS_TOKEN",
@@ -119,7 +111,7 @@ class WechatTool {
119
111
  }
120
112
  async getUserInfo(access_token, openid) {
121
113
  let url = "https://api.weixin.qq.com/sns/userinfo?access_token=" + access_token + "&openid=" + openid;
122
- let rs = await HttpTool_1.gHttpTool.get(url);
114
+ let rs = await HttpTool_1.gHttpTool.get({ url });
123
115
  if (rs.body) {
124
116
  return rs.body;
125
117
  }
@@ -19,7 +19,6 @@ const Alisms_1 = require("./ThirdParty/Alisms");
19
19
  const AppleTool_1 = require("./ThirdParty/AppleTool");
20
20
  const EmailTool_1 = require("./ThirdParty/EmailTool");
21
21
  const QQTool_1 = require("./ThirdParty/QQTool");
22
- const QiniuTool_1 = require("./ThirdParty/QiniuTool");
23
22
  const WechatTool_1 = require("./ThirdParty/WechatTool");
24
23
  const ControllerManager_1 = require("./Server/WebServer/Engine/ControllerManager");
25
24
  const cgserver_1 = require("./cgserver");
@@ -45,7 +44,6 @@ class global {
45
44
  static gByteTool = ByteTool_1.gByteTool;
46
45
  static gSmsTool = Alisms_1.gSMSTool;
47
46
  static gEmailTool = EmailTool_1.gEmailTool;
48
- static gQiniuTool = QiniuTool_1.gQiniuTool;
49
47
  static gQQTool = QQTool_1.gQQTool;
50
48
  static gWechatTool = WechatTool_1.gWechatTool;
51
49
  static gWechatOATool = WechatTool_1.gWechatTool;
@@ -113,6 +113,6 @@ export declare class core {
113
113
  static aesEncode(content: string, key: string, iv: string): string;
114
114
  static aesDecode(base64_str: string, key: string, iv: string): string;
115
115
  static getUuid(): string;
116
- static signatureBase64(private_key: string, rsa_name: string, payload: string): any;
117
- static signatureVerifyBase64(signature: string, private_key: string, rsa_name: string, payload: string): any;
116
+ static signatureBase64(private_key: string, rsa_name: string, payload: string): NonSharedBuffer;
117
+ static signatureVerifyBase64(signature: string, private_key: string, rsa_name: string, payload: string): boolean;
118
118
  }
@@ -1,5 +1,6 @@
1
- import mongoose, { FilterQuery, UpdateQuery, Types, MongooseQueryOptions } from 'mongoose';
1
+ import mongoose from 'mongoose';
2
2
  import { IMongoBaseModel, MongoExt } from './MongoManager';
3
+ export type PartialModel<T> = Partial<mongoose.ApplyBasicCreateCasting<T>>;
3
4
  export declare class MongoBaseService<T extends IMongoBaseModel> {
4
5
  protected _model: mongoose.Model<T>;
5
6
  protected _schema: mongoose.Schema<T>;
@@ -7,21 +8,23 @@ export declare class MongoBaseService<T extends IMongoBaseModel> {
7
8
  protected _dbname: string;
8
9
  protected _mongo: MongoExt;
9
10
  get mongo(): MongoExt;
10
- get model(): mongoose.Model<T, {}, {}, {}, mongoose.IfAny<T, any, mongoose.Document<unknown, {}, T, {}> & mongoose.Default__v<mongoose.Require_id<T>>>, any>;
11
+ get model(): mongoose.Model<T, {}, {}, {}, mongoose.IfAny<T, any, mongoose.Document<unknown, {}, T, {}, mongoose.DefaultSchemaOptions> & mongoose.Require_id<T> & {
12
+ __v: number;
13
+ }>, any, T>;
11
14
  constructor(collection_name: string, schema: mongoose.Schema<T>, dbname?: string);
12
- findOne(filter?: FilterQuery<T>, projection?: any, options?: any): Promise<T | null>;
13
- find(filter?: FilterQuery<T>, projection?: mongoose.ProjectionType<T>, options?: MongooseQueryOptions): Promise<T[]>;
14
- findById(id: string | Types.ObjectId, projection?: mongoose.ProjectionType<T>, options?: MongooseQueryOptions): Promise<T>;
15
+ findOne(filter?: mongoose.QueryFilter<T>, projection?: any, options?: any): Promise<T | null>;
16
+ find(filter?: mongoose.QueryFilter<T>, projection?: mongoose.ProjectionType<T>, options?: mongoose.QueryOptions): Promise<T[]>;
17
+ findById(id: any, projection?: mongoose.ProjectionType<T>, options?: mongoose.QueryOptions): Promise<T>;
15
18
  create(doc: Partial<T>): Promise<T>;
16
- insert(doc: Partial<T>): Promise<T>;
17
- updateOne(filter: FilterQuery<T>, update: UpdateQuery<T>, options?: any): Promise<mongoose.UpdateWriteOpResult>;
18
- updateMany(filter: FilterQuery<T>, update: UpdateQuery<T>, options?: any): Promise<mongoose.UpdateWriteOpResult>;
19
- deleteOne(filter: FilterQuery<T>): Promise<number>;
20
- deleteMany(filter: FilterQuery<T>): Promise<number>;
21
- exists(filter: FilterQuery<T>): Promise<boolean>;
19
+ insert(doc: Partial<T>, options?: mongoose.SaveOptions): Promise<T>;
20
+ updateOne(filter: mongoose.QueryFilter<T>, update: mongoose.UpdateQuery<T>, options?: mongoose.mongo.UpdateOptions): Promise<mongoose.UpdateWriteOpResult>;
21
+ updateMany(filter: mongoose.QueryFilter<T>, update: mongoose.UpdateQuery<T> | mongoose.UpdateWithAggregationPipeline, options?: (mongoose.mongo.UpdateOptions & mongoose.MongooseUpdateQueryOptions<T>) | null): Promise<mongoose.UpdateWriteOpResult>;
22
+ deleteOne(filter: mongoose.QueryFilter<T>): Promise<number>;
23
+ deleteMany(filter: mongoose.QueryFilter<T>): Promise<number>;
24
+ exists(filter: mongoose.QueryFilter<T>): Promise<boolean>;
22
25
  aggregate(pipeline?: any[]): mongoose.Aggregate<any[]>;
23
- findOneAndUpdate(filter: FilterQuery<T>, update: UpdateQuery<T>, options?: MongooseQueryOptions): Promise<T>;
24
- countDocuments(filter?: FilterQuery<T>): Promise<number>;
26
+ findOneAndUpdate(filter: mongoose.QueryFilter<T>, update: mongoose.UpdateQuery<T> | mongoose.UpdateWithAggregationPipeline, options?: mongoose.QueryOptions<T> | null): Promise<T>;
27
+ countDocuments(filter?: mongoose.QueryFilter<T>): Promise<number>;
25
28
  getAutoIds(): Promise<number>;
26
29
  }
27
30
  export interface IAutoIdModel extends IMongoBaseModel {