application 应用 没有公众号配置 使用web配置
This commit is contained in:
parent
ba996548f0
commit
f80931a7e2
|
|
@ -2,11 +2,12 @@
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.getApplication = void 0;
|
exports.getApplication = void 0;
|
||||||
var tslib_1 = require("tslib");
|
var tslib_1 = require("tslib");
|
||||||
|
var assert_1 = require("oak-domain/lib/utils/assert");
|
||||||
function getApplication(params, context) {
|
function getApplication(params, context) {
|
||||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||||
var type, domain, url, _a, application;
|
var type, domain, url, _a, application, _b, application2;
|
||||||
return tslib_1.__generator(this, function (_b) {
|
return tslib_1.__generator(this, function (_c) {
|
||||||
switch (_b.label) {
|
switch (_c.label) {
|
||||||
case 0:
|
case 0:
|
||||||
type = params.type, domain = params.domain;
|
type = params.type, domain = params.domain;
|
||||||
url = context.getHeader('host');
|
url = context.getHeader('host');
|
||||||
|
|
@ -51,8 +52,61 @@ function getApplication(params, context) {
|
||||||
},
|
},
|
||||||
}, {})];
|
}, {})];
|
||||||
case 1:
|
case 1:
|
||||||
_a = tslib_1.__read.apply(void 0, [_b.sent(), 1]), application = _a[0];
|
_a = tslib_1.__read.apply(void 0, [_c.sent(), 1]), application = _a[0];
|
||||||
return [2 /*return*/, application.id];
|
if (!(type === 'wechatMp')) return [3 /*break*/, 2];
|
||||||
|
(0, assert_1.assert)(application, '微信小程序环境下 application必须存在小程序相关配置');
|
||||||
|
return [3 /*break*/, 6];
|
||||||
|
case 2:
|
||||||
|
if (!(type === 'wechatPublic')) return [3 /*break*/, 5];
|
||||||
|
if (!!application) return [3 /*break*/, 4];
|
||||||
|
return [4 /*yield*/, context.select('application', {
|
||||||
|
data: {
|
||||||
|
id: 1,
|
||||||
|
name: 1,
|
||||||
|
config: 1,
|
||||||
|
type: 1,
|
||||||
|
systemId: 1,
|
||||||
|
style: 1,
|
||||||
|
system: {
|
||||||
|
id: 1,
|
||||||
|
name: 1,
|
||||||
|
config: 1,
|
||||||
|
platformId: 1,
|
||||||
|
style: 1,
|
||||||
|
folder: 1,
|
||||||
|
platform: {
|
||||||
|
id: 1,
|
||||||
|
config: 1,
|
||||||
|
style: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
type: 'web',
|
||||||
|
system: {
|
||||||
|
id: {
|
||||||
|
$in: {
|
||||||
|
entity: 'domain',
|
||||||
|
data: {
|
||||||
|
systemId: 1,
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
url: domain,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}, {})];
|
||||||
|
case 3:
|
||||||
|
_b = tslib_1.__read.apply(void 0, [_c.sent(), 1]), application2 = _b[0];
|
||||||
|
(0, assert_1.assert)(application2, '微信公众号环境下 application不存在公众号配置,但必须存在web相关配置');
|
||||||
|
return [2 /*return*/, application2.id];
|
||||||
|
case 4: return [3 /*break*/, 6];
|
||||||
|
case 5:
|
||||||
|
(0, assert_1.assert)(application, 'web环境下 application必须存在web相关配置');
|
||||||
|
_c.label = 6;
|
||||||
|
case 6: return [2 /*return*/, application.id];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { assert } from 'oak-domain/lib/utils/assert';
|
||||||
import { EntityDict } from "../general-app-domain";
|
import { EntityDict } from "../general-app-domain";
|
||||||
import { AppType } from "../general-app-domain/Application/Schema";
|
import { AppType } from "../general-app-domain/Application/Schema";
|
||||||
import { BackendRuntimeContext } from "../context/BackendRuntimeContext";
|
import { BackendRuntimeContext } from "../context/BackendRuntimeContext";
|
||||||
|
|
@ -60,5 +61,72 @@ export async function getApplication<
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//微信小程序环境下 没有就报错
|
||||||
|
if (type === 'wechatMp') {
|
||||||
|
assert(
|
||||||
|
application,
|
||||||
|
'微信小程序环境下 application必须存在小程序相关配置'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
//web 或 wechatPublic
|
||||||
|
if (type === 'wechatPublic') {
|
||||||
|
// 如果微信公众号环境下 application不存在公众号配置,但又在公众号访问,这时可以使用web的application
|
||||||
|
if (!application) {
|
||||||
|
const [application2] = await context.select(
|
||||||
|
'application',
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
id: 1,
|
||||||
|
name: 1,
|
||||||
|
config: 1,
|
||||||
|
type: 1,
|
||||||
|
systemId: 1,
|
||||||
|
style: 1,
|
||||||
|
system: {
|
||||||
|
id: 1,
|
||||||
|
name: 1,
|
||||||
|
config: 1,
|
||||||
|
platformId: 1,
|
||||||
|
style: 1,
|
||||||
|
folder: 1,
|
||||||
|
platform: {
|
||||||
|
id: 1,
|
||||||
|
config: 1,
|
||||||
|
style: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
type: 'web',
|
||||||
|
system: {
|
||||||
|
id: {
|
||||||
|
$in: {
|
||||||
|
entity: 'domain',
|
||||||
|
data: {
|
||||||
|
systemId: 1,
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
url: domain,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
|
||||||
|
assert(
|
||||||
|
application2,
|
||||||
|
'微信公众号环境下 application不存在公众号配置,但必须存在web相关配置'
|
||||||
|
);
|
||||||
|
|
||||||
|
return application2.id as string;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
assert(application, 'web环境下 application必须存在web相关配置');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return application.id as string;
|
return application.id as string;
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue