refactor: syncMessageTemplate函数名改为syncWechatTemplate

This commit is contained in:
wkj 2025-12-23 10:00:09 +08:00
parent 6aff242687
commit 97fd741a3b
22 changed files with 37 additions and 35 deletions

View File

@ -538,7 +538,7 @@ export type AspectDict<ED extends EntityDict> = {
* @param applicationId ID
* @returns
*/
syncMessageTemplate: (params: {
syncWechatTemplate: (params: {
applicationId: string;
}, context: BackendRuntimeContext<ED>) => Promise<any>;
/**

View File

@ -2,7 +2,7 @@ import { bindByEmail, bindByMobile, loginByAccount, loginByEmail, loginByMobile,
import { getInfoByUrl } from './extraFile';
import { getApplication, signatureJsSDK, uploadWechatMedia, batchGetArticle, getArticle, batchGetMaterialList, getMaterial, deleteMaterial } from './application';
import { updateConfig, updateApplicationConfig, updateStyle } from './config';
import { syncMessageTemplate, getMessageType } from './template';
import { syncWechatTemplate, getMessageType } from './template';
import { syncSmsTemplate } from './sms';
import { mergeUser, getChangePasswordChannels, updateUserPassword } from './user';
import { createWechatLogin } from './wechatLogin';
@ -63,7 +63,7 @@ declare const aspectDict: {
getTags: typeof getTags;
editTag: typeof editTag;
deleteTag: typeof deleteTag;
syncMessageTemplate: typeof syncMessageTemplate;
syncWechatTemplate: typeof syncWechatTemplate;
getMessageType: typeof getMessageType;
syncTag: typeof syncTag;
oneKeySync: typeof oneKeySync;

View File

@ -2,7 +2,7 @@ import { bindByEmail, bindByMobile, loginByAccount, loginByEmail, loginByMobile,
import { getInfoByUrl } from './extraFile';
import { getApplication, signatureJsSDK, uploadWechatMedia, batchGetArticle, getArticle, batchGetMaterialList, getMaterial, deleteMaterial, } from './application';
import { updateConfig, updateApplicationConfig, updateStyle } from './config';
import { syncMessageTemplate, getMessageType } from './template';
import { syncWechatTemplate, getMessageType } from './template';
import { syncSmsTemplate } from './sms';
import { mergeUser, getChangePasswordChannels, updateUserPassword } from './user';
import { createWechatLogin } from './wechatLogin';
@ -63,7 +63,7 @@ const aspectDict = {
getTags,
editTag,
deleteTag,
syncMessageTemplate,
syncWechatTemplate,
getMessageType,
syncTag,
oneKeySync,

View File

@ -2,7 +2,7 @@ import { EntityDict } from '../oak-app-domain';
import { BRC } from '../types/RuntimeCxt';
export declare function registerMessageType(messageType: string[]): void;
export declare function getMessageType(): Promise<string[]>;
export declare function syncMessageTemplate<ED extends EntityDict>(params: {
export declare function syncWechatTemplate<ED extends EntityDict>(params: {
applicationId: string;
}, context: BRC<ED>): Promise<{
wechatId: string;

View File

@ -33,7 +33,7 @@ function analyseContent(content) {
}
return result;
}
export async function syncMessageTemplate(params, context) {
export async function syncWechatTemplate(params, context) {
const applicationId = params?.applicationId;
const [application] = await context.select('application', {
data: {

View File

@ -15,7 +15,7 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
type?: ButtonProps['type'] | AmButtonProps['type'];
executeText?: string | undefined;
buttonProps?: (ButtonProps & {
color?: "default" | "success" | "primary" | "warning" | "danger" | undefined;
color?: "default" | "success" | "warning" | "primary" | "danger" | undefined;
fill?: "none" | "solid" | "outline" | undefined;
size?: "small" | "large" | "middle" | "mini" | undefined;
block?: boolean | undefined;

View File

@ -76,7 +76,7 @@ export default OakComponent({
methods: {
async syncTemplate() {
const applicationId = this.props.applicationId;
await this.features.template.syncMessageTemplate(applicationId);
await this.features.template.syncWechatTemplate(applicationId);
const { data: wechatTemplates } = await this.features.cache.refresh('wechatTemplate', {
data: {
id: 1,

View File

@ -9,6 +9,6 @@ export declare class Template<ED extends EntityDict> extends Feature {
result: any;
message: string | null | undefined;
}>;
syncMessageTemplate(applicationId: string): Promise<void>;
syncWechatTemplate(applicationId: string): Promise<void>;
syncSmsTemplate(systemId: string, origin: string): Promise<void>;
}

View File

@ -10,8 +10,8 @@ export class Template extends Feature {
async getMessageType() {
return await this.cache.exec('getMessageType', {});
}
async syncMessageTemplate(applicationId) {
const result = await this.cache.exec('syncMessageTemplate', {
async syncWechatTemplate(applicationId) {
const result = await this.cache.exec('syncWechatTemplate', {
applicationId
});
this.publish();

View File

@ -538,7 +538,7 @@ export type AspectDict<ED extends EntityDict> = {
* @param applicationId ID
* @returns
*/
syncMessageTemplate: (params: {
syncWechatTemplate: (params: {
applicationId: string;
}, context: BackendRuntimeContext<ED>) => Promise<any>;
/**

View File

@ -2,7 +2,7 @@ import { bindByEmail, bindByMobile, loginByAccount, loginByEmail, loginByMobile,
import { getInfoByUrl } from './extraFile';
import { getApplication, signatureJsSDK, uploadWechatMedia, batchGetArticle, getArticle, batchGetMaterialList, getMaterial, deleteMaterial } from './application';
import { updateConfig, updateApplicationConfig, updateStyle } from './config';
import { syncMessageTemplate, getMessageType } from './template';
import { syncWechatTemplate, getMessageType } from './template';
import { syncSmsTemplate } from './sms';
import { mergeUser, getChangePasswordChannels, updateUserPassword } from './user';
import { createWechatLogin } from './wechatLogin';
@ -63,7 +63,7 @@ declare const aspectDict: {
getTags: typeof getTags;
editTag: typeof editTag;
deleteTag: typeof deleteTag;
syncMessageTemplate: typeof syncMessageTemplate;
syncWechatTemplate: typeof syncWechatTemplate;
getMessageType: typeof getMessageType;
syncTag: typeof syncTag;
oneKeySync: typeof oneKeySync;

View File

@ -65,7 +65,7 @@ const aspectDict = {
getTags: wechatPublicTag_1.getTags,
editTag: wechatPublicTag_1.editTag,
deleteTag: wechatPublicTag_1.deleteTag,
syncMessageTemplate: template_1.syncMessageTemplate,
syncWechatTemplate: template_1.syncWechatTemplate,
getMessageType: template_1.getMessageType,
syncTag: wechatPublicTag_1.syncTag,
oneKeySync: wechatPublicTag_1.oneKeySync,

View File

@ -2,7 +2,7 @@ import { EntityDict } from '../oak-app-domain';
import { BRC } from '../types/RuntimeCxt';
export declare function registerMessageType(messageType: string[]): void;
export declare function getMessageType(): Promise<string[]>;
export declare function syncMessageTemplate<ED extends EntityDict>(params: {
export declare function syncWechatTemplate<ED extends EntityDict>(params: {
applicationId: string;
}, context: BRC<ED>): Promise<{
wechatId: string;

View File

@ -1,8 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerMessageType = registerMessageType;
exports.getMessageType = getMessageType;
exports.syncMessageTemplate = syncMessageTemplate;
exports.syncWechatTemplate = exports.getMessageType = exports.registerMessageType = void 0;
const tslib_1 = require("tslib");
const assert_1 = require("oak-domain/lib/utils/assert");
const uuid_1 = require("oak-domain/lib/utils/uuid");
@ -13,9 +11,11 @@ function registerMessageType(messageType) {
let messageTypes2 = messageTypes.concat(messageType);
messageTypes = (0, lodash_1.uniq)(messageTypes2);
}
exports.registerMessageType = registerMessageType;
async function getMessageType() {
return messageTypes;
}
exports.getMessageType = getMessageType;
function analyseContent(content) {
let content2 = content;
let result = {};
@ -39,7 +39,7 @@ function analyseContent(content) {
}
return result;
}
async function syncMessageTemplate(params, context) {
async function syncWechatTemplate(params, context) {
const applicationId = params?.applicationId;
const [application] = await context.select('application', {
data: {
@ -129,3 +129,4 @@ async function syncMessageTemplate(params, context) {
}
return template_list;
}
exports.syncWechatTemplate = syncWechatTemplate;

View File

@ -1,7 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.create = create;
exports.initialize = initialize;
exports.initialize = exports.create = void 0;
const tslib_1 = require("tslib");
const token_1 = require("./token");
const extraFile_1 = require("./extraFile");
@ -38,6 +37,7 @@ function create(basicFeatures) {
userWechatPublicTag,
};
}
exports.create = create;
const selectionRewriter_1 = require("../utils/selectionRewriter");
async function initialize(features, access, config, clazzes) {
features.cache.registerSelectionRewriter(selectionRewriter_1.rewriteSelection);
@ -56,3 +56,4 @@ async function initialize(features, access, config, clazzes) {
}
}
}
exports.initialize = initialize;

View File

@ -9,6 +9,6 @@ export declare class Template<ED extends EntityDict> extends Feature {
result: any;
message: string | null | undefined;
}>;
syncMessageTemplate(applicationId: string): Promise<void>;
syncWechatTemplate(applicationId: string): Promise<void>;
syncSmsTemplate(systemId: string, origin: string): Promise<void>;
}

View File

@ -13,8 +13,8 @@ class Template extends Feature_1.Feature {
async getMessageType() {
return await this.cache.exec('getMessageType', {});
}
async syncMessageTemplate(applicationId) {
const result = await this.cache.exec('syncMessageTemplate', {
async syncWechatTemplate(applicationId) {
const result = await this.cache.exec('syncWechatTemplate', {
applicationId
});
this.publish();

View File

@ -731,7 +731,7 @@ export type AspectDict<ED extends EntityDict> = {
* @param applicationId ID
* @returns
*/
syncMessageTemplate: (
syncWechatTemplate: (
params: {
applicationId: string;
},

View File

@ -33,7 +33,7 @@ import {
deleteMaterial,
} from './application';
import { updateConfig, updateApplicationConfig, updateStyle } from './config';
import { syncMessageTemplate, getMessageType } from './template';
import { syncWechatTemplate, getMessageType } from './template';
import { syncSmsTemplate } from './sms';
import { mergeUser, getChangePasswordChannels, updateUserPassword } from './user';
import { createWechatLogin } from './wechatLogin';
@ -120,7 +120,7 @@ const aspectDict = {
getTags,
editTag,
deleteTag,
syncMessageTemplate,
syncWechatTemplate,
getMessageType,
syncTag,
oneKeySync,

View File

@ -3,7 +3,7 @@ import { assert } from 'oak-domain/lib/utils/assert';
import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
import WechatSDK, { WechatMpInstance, WechatPublicInstance } from 'oak-external-sdk/lib/WechatSDK';
import { WechatPublicConfig } from '../oak-app-domain/Application/Schema';
import { WechatPublicConfig, WechatMpConfig } from '../oak-app-domain/Application/Schema';
import { BRC } from '../types/RuntimeCxt';
import { uniq } from 'oak-domain/lib/utils/lodash';
@ -43,7 +43,7 @@ function analyseContent(content: string): Object {
}
return result;
}
export async function syncMessageTemplate<ED extends EntityDict>(
export async function syncWechatTemplate<ED extends EntityDict>(
params: {
applicationId: string;
},
@ -94,7 +94,7 @@ export async function syncMessageTemplate<ED extends EntityDict>(
);
} else {
let appId: string, appSecret: string;
const config2 = config as WechatPublicConfig;
const config2 = config as WechatMpConfig;
appId = config2.appId;
appSecret = config2.appSecret;
const wechatMpInstance = WechatSDK.getInstance(

View File

@ -79,7 +79,7 @@ export default OakComponent({
methods: {
async syncTemplate() {
const applicationId = this.props.applicationId;
await this.features.template.syncMessageTemplate(applicationId!);
await this.features.template.syncWechatTemplate(applicationId!);
const { data: wechatTemplates } = await this.features.cache.refresh('wechatTemplate', {
data: {
id: 1,

View File

@ -14,8 +14,8 @@ export class Template<ED extends EntityDict> extends Feature {
async getMessageType() {
return await this.cache.exec('getMessageType', {});
}
async syncMessageTemplate(applicationId: string) {
const result = await this.cache.exec('syncMessageTemplate', {
async syncWechatTemplate(applicationId: string) {
const result = await this.cache.exec('syncWechatTemplate', {
applicationId
});
this.publish();