feat: check action data 3

This commit is contained in:
手瓜一十雪
2024-05-18 12:40:41 +08:00
parent 62eee5f05c
commit d6175acd38
12 changed files with 151 additions and 78 deletions

View File

@@ -5,16 +5,23 @@ import BaseAction from '../BaseAction';
import { ActionName } from '../types';
import { NTQQMsgApi } from '@/core/apis/msg';
import { GroupEssenceMsgRet, WebApi } from '@/core/apis/webapi';
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
interface PayloadType {
group_id: number;
pages: number;
}
const SchemaData = {
type: 'object',
properties: {
group_id: { type: 'number' },
pages: { type: 'number' },
},
required: ['group_id', 'pages']
} as const satisfies JSONSchema;
export class GetGroupEssence extends BaseAction<PayloadType, GroupEssenceMsgRet> {
type Payload = FromSchema<typeof SchemaData>;
export class GetGroupEssence extends BaseAction<Payload, GroupEssenceMsgRet> {
actionName = ActionName.GoCQHTTP_GetEssenceMsg;
protected async _handle(payload: PayloadType) {
PayloadSchema = SchemaData;
protected async _handle(payload: Payload) {
const ret = await WebApi.getGroupEssenceMsg(payload.group_id.toString(), payload.pages.toString());
if (!ret) {
throw new Error('获取失败');