Merge branch 'dev' of codeup.aliyun.com:61c14a7efa282c88e103c23f/oak-general-business into dev
This commit is contained in:
commit
70825388c5
|
|
@ -8,6 +8,7 @@ var Exception_2 = require("oak-domain/lib/types/Exception");
|
|||
var constants_1 = require("../constants");
|
||||
var AsyncRowStore_1 = require("oak-domain/lib/store/AsyncRowStore");
|
||||
var uuid_1 = require("oak-domain/lib/utils/uuid");
|
||||
var wechatQrCode_1 = require("../aspects/wechatQrCode");
|
||||
/**
|
||||
* general数据结构要求的后台上下文
|
||||
*/
|
||||
|
|
@ -18,33 +19,74 @@ var BackendRuntimeContext = /** @class */ (function (_super) {
|
|||
}
|
||||
BackendRuntimeContext.prototype.refineOpRecords = function () {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var _a, _b, opRecord, d, entity;
|
||||
var e_1, _c;
|
||||
return tslib_1.__generator(this, function (_d) {
|
||||
try {
|
||||
for (_a = tslib_1.__values(this.opRecords), _b = _a.next(); !_b.done; _b = _a.next()) {
|
||||
var _a, _b, opRecord, d, _c, _d, _i, entity, wechatQrCodeListObj, _e, _f, _g, id, wechatQrCodeData, buffer, e_1_1;
|
||||
var e_1, _h;
|
||||
return tslib_1.__generator(this, function (_j) {
|
||||
switch (_j.label) {
|
||||
case 0:
|
||||
_j.trys.push([0, 11, 12, 13]);
|
||||
_a = tslib_1.__values(this.opRecords), _b = _a.next();
|
||||
_j.label = 1;
|
||||
case 1:
|
||||
if (!!_b.done) return [3 /*break*/, 10];
|
||||
opRecord = _b.value;
|
||||
if (opRecord.a === 's') {
|
||||
d = opRecord.d;
|
||||
for (entity in d) {
|
||||
if (entity === 'wechatQrCode') {
|
||||
// todo 小程序码此时去微信服务器获得码数据
|
||||
}
|
||||
else if (['application', 'system', 'platform'].includes(entity)) {
|
||||
// todo 删除掉config中的敏感返回信息
|
||||
}
|
||||
}
|
||||
if (!(opRecord.a === 's')) return [3 /*break*/, 9];
|
||||
d = opRecord.d;
|
||||
_c = [];
|
||||
for (_d in d)
|
||||
_c.push(_d);
|
||||
_i = 0;
|
||||
_j.label = 2;
|
||||
case 2:
|
||||
if (!(_i < _c.length)) return [3 /*break*/, 9];
|
||||
entity = _c[_i];
|
||||
if (!(entity === 'wechatQrCode')) return [3 /*break*/, 7];
|
||||
wechatQrCodeListObj = d[entity];
|
||||
_e = [];
|
||||
for (_f in wechatQrCodeListObj)
|
||||
_e.push(_f);
|
||||
_g = 0;
|
||||
_j.label = 3;
|
||||
case 3:
|
||||
if (!(_g < _e.length)) return [3 /*break*/, 6];
|
||||
id = _e[_g];
|
||||
wechatQrCodeData = wechatQrCodeListObj[id];
|
||||
if (!(wechatQrCodeData.type === 'wechatMpWxaCode')) return [3 /*break*/, 5];
|
||||
return [4 /*yield*/, (0, wechatQrCode_1.getMpUnlimitWxaCode)(id, this)];
|
||||
case 4:
|
||||
buffer = _j.sent();
|
||||
Object.assign(wechatQrCodeData, {
|
||||
buffer: buffer,
|
||||
});
|
||||
_j.label = 5;
|
||||
case 5:
|
||||
_g++;
|
||||
return [3 /*break*/, 3];
|
||||
case 6: return [3 /*break*/, 8];
|
||||
case 7:
|
||||
if (['application', 'system', 'platform'].includes(entity)) {
|
||||
// todo 删除掉config中的敏感返回信息
|
||||
}
|
||||
}
|
||||
_j.label = 8;
|
||||
case 8:
|
||||
_i++;
|
||||
return [3 /*break*/, 2];
|
||||
case 9:
|
||||
_b = _a.next();
|
||||
return [3 /*break*/, 1];
|
||||
case 10: return [3 /*break*/, 13];
|
||||
case 11:
|
||||
e_1_1 = _j.sent();
|
||||
e_1 = { error: e_1_1 };
|
||||
return [3 /*break*/, 13];
|
||||
case 12:
|
||||
try {
|
||||
if (_b && !_b.done && (_h = _a.return)) _h.call(_a);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
return [7 /*endfinally*/];
|
||||
case 13: return [2 /*return*/];
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
return [2 /*return*/];
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ import { ROOT_TOKEN_ID, ROOT_USER_ID } from '../constants';
|
|||
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
||||
import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
|
||||
import { SelectOpResult } from 'oak-domain/lib/types';
|
||||
|
||||
import {
|
||||
getMpUnlimitWxaCode,
|
||||
} from '../aspects/wechatQrCode';
|
||||
/**
|
||||
* general数据结构要求的后台上下文
|
||||
*/
|
||||
|
|
@ -27,6 +29,23 @@ export class BackendRuntimeContext<ED extends EntityDict> extends AsyncContext<E
|
|||
for (const entity in d) {
|
||||
if (entity === 'wechatQrCode') {
|
||||
// todo 小程序码此时去微信服务器获得码数据
|
||||
const wechatQrCodeListObj = d[entity];
|
||||
for (const id in wechatQrCodeListObj) {
|
||||
const wechatQrCodeData = wechatQrCodeListObj[id] as Partial<EntityDict['wechatQrCode']['OpSchema']>;
|
||||
if (wechatQrCodeData.type === 'wechatMpWxaCode') {
|
||||
const buffer = await getMpUnlimitWxaCode(
|
||||
id,
|
||||
this as BackendRuntimeContext<EntityDict>,
|
||||
);
|
||||
Object.assign(
|
||||
wechatQrCodeData, {
|
||||
buffer,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else if (['application', 'system', 'platform'].includes(entity)) {
|
||||
// todo 删除掉config中的敏感返回信息
|
||||
|
|
@ -100,7 +119,7 @@ export class BackendRuntimeContext<ED extends EntityDict> extends AsyncContext<E
|
|||
this.amIRoot = (userRole$user as any).length > 0 && (userRole$user as any).find(
|
||||
(ele: any) => ele.role.name === 'root'
|
||||
);
|
||||
const { userRole$user: userRole$player} = player!;
|
||||
const { userRole$user: userRole$player } = player!;
|
||||
this.amIReallyRoot = (userRole$player as any).length > 0 && (userRole$player as any).find(
|
||||
(ele: any) => ele.role.name === 'root'
|
||||
);
|
||||
|
|
@ -163,7 +182,7 @@ export class BackendRuntimeContext<ED extends EntityDict> extends AsyncContext<E
|
|||
}
|
||||
await this.commit();
|
||||
}
|
||||
catch(err) {
|
||||
catch (err) {
|
||||
await this.rollback();
|
||||
throw err;
|
||||
}
|
||||
|
|
@ -250,7 +269,7 @@ export class BackendRuntimeContext<ED extends EntityDict> extends AsyncContext<E
|
|||
dontCollect: true,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
allowUserUpdate(): boolean {
|
||||
if (this.isReallyRoot()) {
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue