进行message处理的时候,考虑没有platform的情形

This commit is contained in:
Xu Chang 2023-08-18 10:54:39 +08:00
parent ff0280493d
commit 89e4ae99a1
6 changed files with 57 additions and 24 deletions

View File

@ -255,11 +255,11 @@ var i18ns = [
}
},
{
id: "7a96eb13e533aeab2eba87643ed834b3",
namespace: "oak-general-business-l-Common",
id: "e07ce685f0383e7f7f3ce86501567f28",
namespace: "oak-general-business-l-common",
language: "zh-CN",
module: "oak-general-business",
position: "locales/Common",
position: "locales/common",
data: {
"noData": "暂无数据",
"areYouSure": "请确认",

View File

@ -1,7 +1,7 @@
import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "oak-domain/lib/types/Demand";
import { OneOf } from "oak-domain/lib/types/Polyfill";
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction } from "oak-domain/lib/types/Entity";
import { GenericAction } from "oak-domain/lib/actions/action";
import { ReadOnlyAction } from "oak-domain/lib/actions/action";
import { String } from "oak-domain/lib/types/DataType";
import { EntityShape } from "oak-domain/lib/types/Entity";
export declare type OpSchema = EntityShape & {
@ -91,7 +91,7 @@ export declare type I18nIdSubQuery = Selection<I18nIdProjection>;
export declare type EntityDef = {
Schema: Schema;
OpSchema: OpSchema;
Action: OakMakeAction<GenericAction> | string;
Action: OakMakeAction<ReadOnlyAction> | string;
Selection: Selection;
Aggregation: Aggregation;
Operation: Operation;

View File

@ -37,6 +37,23 @@ exports.desc = {
type: "object"
}
},
actionType: "crud",
actions: action_1.genericActions
static: true,
actionType: "readOnly",
actions: action_1.readOnlyActions,
indexes: [
{
name: 'namespace_language',
attributes: [
{
name: 'namespace'
},
{
name: 'language'
}
],
config: {
unique: true
}
}
]
};

View File

@ -63,7 +63,7 @@ function tryMakeSmsNotification(message, context) {
exports.tryMakeSmsNotification = tryMakeSmsNotification;
function createNotification(message, context) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var restriction, userId, weight, type, entity, entityId, application, platformId, userSystems, systems, messageTypeTemplateIds, channels, messageSentCount, messageSystemDatas, _a;
var restriction, userId, weight, type, entity, entityId, application, platformId, systemId, filter, userSystems, systems, messageTypeTemplateIds, channels, messageSentCount, messageSystemDatas, _a;
var _b;
var _this = this;
return tslib_1.__generator(this, function (_c) {
@ -73,6 +73,19 @@ function createNotification(message, context) {
(0, assert_1.assert)(userId);
application = context.getApplication();
platformId = application.system.platformId;
systemId = application.systemId;
filter = {
userId: userId,
};
if (platformId) {
filter.system = {
platformId: platformId,
};
}
else {
(0, assert_1.assert)(systemId);
filter.systemId = systemId;
}
return [4 /*yield*/, context.select('userSystem', {
data: {
id: 1,
@ -89,12 +102,7 @@ function createNotification(message, context) {
},
},
},
filter: {
userId: userId,
system: {
platformId: platformId,
}
},
filter: filter,
}, { dontCollect: true })];
case 1:
userSystems = _c.sent();

View File

@ -255,11 +255,11 @@ const i18ns: I18n[] = [
}
},
{
id: "7a96eb13e533aeab2eba87643ed834b3",
namespace: "oak-general-business-l-Common",
id: "e07ce685f0383e7f7f3ce86501567f28",
namespace: "oak-general-business-l-common",
language: "zh-CN",
module: "oak-general-business",
position: "locales/Common",
position: "locales/common",
data: {
"noData": "暂无数据",
"areYouSure": "请确认",

View File

@ -61,9 +61,22 @@ async function createNotification(message: CreateMessageData, context: BRC) {
const { restriction, userId, weight, type, entity, entityId } = message;
assert(userId);
// 根据用户所关联的system和定义限制选择将要发送的system。一般来说不可能跨platform
// 根据用户所关联的system和定义限制选择将要发送的system。这里有的应用是到platform级别有的是到system级别
const application = context.getApplication();
const platformId = application!.system!.platformId!;
const systemId = application!.systemId;
const filter: EntityDict['userSystem']['Selection']['filter'] = {
userId,
};
if (platformId) {
filter.system = {
platformId,
};
}
else {
assert(systemId);
filter.systemId = systemId;
}
const userSystems = await context.select('userSystem', {
data: {
id: 1,
@ -80,12 +93,7 @@ async function createNotification(message: CreateMessageData, context: BRC) {
},
},
},
filter: {
userId,
system: {
platformId,
}
},
filter,
}, { dontCollect: true });
// 这里实测线上跑出来多条相同的userSystem还未知道原因 by Xc 20230317