feat: mp api
parent
4f4d4972c5
commit
c7f207034f
|
@ -0,0 +1,59 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MpAccountApi {
|
||||
/** 公众号账号信息 */
|
||||
export interface Account {
|
||||
id?: number;
|
||||
name: string;
|
||||
account: string;
|
||||
appId: string;
|
||||
appSecret: string;
|
||||
token: string;
|
||||
aesKey?: string;
|
||||
qrCodeUrl?: string;
|
||||
remark?: string;
|
||||
createTime?: Date;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询公众号账号列表 */
|
||||
export function getAccountPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MpAccountApi.Account>>(
|
||||
'/mp/account/page',
|
||||
{
|
||||
params,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询公众号账号详情 */
|
||||
export function getAccount(id: number) {
|
||||
return requestClient.get<MpAccountApi.Account>(`/mp/account/get?id=${id}`);
|
||||
}
|
||||
|
||||
/** 新增公众号账号 */
|
||||
export function createAccount(data: MpAccountApi.Account) {
|
||||
return requestClient.post('/mp/account/create', data);
|
||||
}
|
||||
|
||||
/** 修改公众号账号 */
|
||||
export function updateAccount(data: MpAccountApi.Account) {
|
||||
return requestClient.put('/mp/account/update', data);
|
||||
}
|
||||
|
||||
/** 删除公众号账号 */
|
||||
export function deleteAccount(id: number) {
|
||||
return requestClient.delete(`/mp/account/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 生成公众号账号二维码 */
|
||||
export function generateAccountQrCode(id: number) {
|
||||
return requestClient.post(`/mp/account/generate-qr-code?id=${id}`);
|
||||
}
|
||||
|
||||
/** 清空公众号账号 API 配额 */
|
||||
export function clearAccountQuota(id: number) {
|
||||
return requestClient.post(`/mp/account/clear-quota?id=${id}`);
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MpAutoReplyApi {
|
||||
/** 自动回复信息 */
|
||||
export interface AutoReply {
|
||||
id?: number;
|
||||
accountId: number;
|
||||
type: number;
|
||||
keyword: string;
|
||||
content: string;
|
||||
status: number;
|
||||
remark?: string;
|
||||
createTime?: Date;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询自动回复列表 */
|
||||
export function getAutoReplyPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MpAutoReplyApi.AutoReply>>(
|
||||
'/mp/auto-reply/page',
|
||||
{
|
||||
params,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询自动回复详情 */
|
||||
export function getAutoReply(id: number) {
|
||||
return requestClient.get<MpAutoReplyApi.AutoReply>(
|
||||
`/mp/auto-reply/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增自动回复 */
|
||||
export function createAutoReply(data: MpAutoReplyApi.AutoReply) {
|
||||
return requestClient.post('/mp/auto-reply/create', data);
|
||||
}
|
||||
|
||||
/** 修改自动回复 */
|
||||
export function updateAutoReply(data: MpAutoReplyApi.AutoReply) {
|
||||
return requestClient.put('/mp/auto-reply/update', data);
|
||||
}
|
||||
|
||||
/** 删除自动回复 */
|
||||
export function deleteAutoReply(id: number) {
|
||||
return requestClient.delete(`/mp/auto-reply/delete?id=${id}`);
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MpDraftApi {
|
||||
/** 草稿文章信息 */
|
||||
export interface Article {
|
||||
title: string;
|
||||
author: string;
|
||||
digest: string;
|
||||
content: string;
|
||||
contentSourceUrl: string;
|
||||
thumbMediaId: string;
|
||||
showCoverPic: number;
|
||||
needOpenComment: number;
|
||||
onlyFansCanComment: number;
|
||||
}
|
||||
|
||||
/** 草稿信息 */
|
||||
export interface Draft {
|
||||
id?: number;
|
||||
accountId: number;
|
||||
mediaId: string;
|
||||
articles: Article[];
|
||||
createTime?: Date;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询草稿列表 */
|
||||
export function getDraftPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MpDraftApi.Draft>>('/mp/draft/page', {
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/** 创建草稿 */
|
||||
export function createDraft(accountId: number, articles: MpDraftApi.Article[]) {
|
||||
return requestClient.post('/mp/draft/create', articles, {
|
||||
params: { accountId },
|
||||
});
|
||||
}
|
||||
|
||||
/** 更新草稿 */
|
||||
export function updateDraft(
|
||||
accountId: number,
|
||||
mediaId: string,
|
||||
articles: MpDraftApi.Article[],
|
||||
) {
|
||||
return requestClient.put('/mp/draft/update', articles, {
|
||||
params: { accountId, mediaId },
|
||||
});
|
||||
}
|
||||
|
||||
/** 删除草稿 */
|
||||
export function deleteDraft(accountId: number, mediaId: string) {
|
||||
return requestClient.delete('/mp/draft/delete', {
|
||||
params: { accountId, mediaId },
|
||||
});
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MpFreePublishApi {
|
||||
/** 自由发布文章信息 */
|
||||
export interface FreePublish {
|
||||
id?: number;
|
||||
accountId: number;
|
||||
mediaId: string;
|
||||
articleId: string;
|
||||
title: string;
|
||||
author: string;
|
||||
digest: string;
|
||||
content: string;
|
||||
thumbUrl: string;
|
||||
status: number;
|
||||
publishTime?: Date;
|
||||
createTime?: Date;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询自由发布文章列表 */
|
||||
export function getFreePublishPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MpFreePublishApi.FreePublish>>(
|
||||
'/mp/free-publish/page',
|
||||
{
|
||||
params,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/** 删除自由发布文章 */
|
||||
export function deleteFreePublish(accountId: number, articleId: string) {
|
||||
return requestClient.delete('/mp/free-publish/delete', {
|
||||
params: { accountId, articleId },
|
||||
});
|
||||
}
|
||||
|
||||
/** 发布自由发布文章 */
|
||||
export function submitFreePublish(accountId: number, mediaId: string) {
|
||||
return requestClient.post('/mp/free-publish/submit', null, {
|
||||
params: { accountId, mediaId },
|
||||
});
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/** 素材类型枚举 */
|
||||
export enum MaterialType {
|
||||
IMAGE = 1, // 图片
|
||||
THUMB = 4, // 缩略图
|
||||
VIDEO = 3, // 视频
|
||||
VOICE = 2, // 语音
|
||||
}
|
||||
|
||||
export namespace MpMaterialApi {
|
||||
/** 素材信息 */
|
||||
export interface Material {
|
||||
id?: number;
|
||||
accountId: number;
|
||||
type: MaterialType;
|
||||
mediaId: string;
|
||||
url: string;
|
||||
name: string;
|
||||
size: number;
|
||||
remark?: string;
|
||||
createTime?: Date;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询素材列表 */
|
||||
export function getMaterialPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MpMaterialApi.Material>>(
|
||||
'/mp/material/page',
|
||||
{
|
||||
params,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/** 删除永久素材 */
|
||||
export function deletePermanentMaterial(id: number) {
|
||||
return requestClient.delete('/mp/material/delete-permanent', {
|
||||
params: { id },
|
||||
});
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
import { requestClient } from '#/api/request';
|
||||
|
||||
/** 菜单类型枚举 */
|
||||
export enum MenuType {
|
||||
CLICK = 'click', // 点击推事件
|
||||
LOCATION_SELECT = 'location_select', // 发送位置
|
||||
MEDIA_ID = 'media_id', // 下发消息
|
||||
MINIPROGRAM = 'miniprogram', // 小程序
|
||||
PIC_PHOTO_OR_ALBUM = 'pic_photo_or_album', // 拍照或者相册发图
|
||||
PIC_SYSPHOTO = 'pic_sysphoto', // 系统拍照发图
|
||||
PIC_WEIXIN = 'pic_weixin', // 微信相册发图
|
||||
SCANCODE_PUSH = 'scancode_push', // 扫码推事件
|
||||
SCANCODE_WAITMSG = 'scancode_waitmsg', // 扫码带提示
|
||||
VIEW = 'view', // 跳转URL
|
||||
VIEW_LIMITED = 'view_limited', // 跳转图文消息URL
|
||||
}
|
||||
|
||||
export namespace MpMenuApi {
|
||||
/** 菜单按钮信息 */
|
||||
export interface MenuButton {
|
||||
type: MenuType;
|
||||
name: string;
|
||||
key?: string;
|
||||
url?: string;
|
||||
mediaId?: string;
|
||||
appId?: string;
|
||||
pagePath?: string;
|
||||
subButtons?: MenuButton[];
|
||||
}
|
||||
|
||||
/** 菜单信息 */
|
||||
export interface Menu {
|
||||
accountId: number;
|
||||
menus: MenuButton[];
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询菜单列表 */
|
||||
export function getMenuList(accountId: number) {
|
||||
return requestClient.get<MpMenuApi.MenuButton[]>('/mp/menu/list', {
|
||||
params: { accountId },
|
||||
});
|
||||
}
|
||||
|
||||
/** 保存菜单 */
|
||||
export function saveMenu(accountId: number, menus: MpMenuApi.MenuButton[]) {
|
||||
return requestClient.post('/mp/menu/save', {
|
||||
accountId,
|
||||
menus,
|
||||
});
|
||||
}
|
||||
|
||||
/** 删除菜单 */
|
||||
export function deleteMenu(accountId: number) {
|
||||
return requestClient.delete('/mp/menu/delete', {
|
||||
params: { accountId },
|
||||
});
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/** 消息类型枚举 */
|
||||
export enum MessageType {
|
||||
IMAGE = 'image', // 图片消息
|
||||
MPNEWS = 'mpnews', // 公众号图文消息
|
||||
MUSIC = 'music', // 音乐消息
|
||||
NEWS = 'news', // 图文消息
|
||||
TEXT = 'text', // 文本消息
|
||||
VIDEO = 'video', // 视频消息
|
||||
VOICE = 'voice', // 语音消息
|
||||
WXCARD = 'wxcard', // 卡券消息
|
||||
}
|
||||
|
||||
export namespace MpMessageApi {
|
||||
/** 消息信息 */
|
||||
export interface Message {
|
||||
id?: number;
|
||||
accountId: number;
|
||||
type: MessageType;
|
||||
openid: string;
|
||||
content: string;
|
||||
mediaId?: string;
|
||||
status: number;
|
||||
remark?: string;
|
||||
createTime?: Date;
|
||||
}
|
||||
|
||||
/** 发送消息请求 */
|
||||
export interface SendMessageRequest {
|
||||
accountId: number;
|
||||
openid: string;
|
||||
type: MessageType;
|
||||
content: string;
|
||||
mediaId?: string;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询消息列表 */
|
||||
export function getMessagePage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MpMessageApi.Message>>(
|
||||
'/mp/message/page',
|
||||
{
|
||||
params,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/** 发送消息 */
|
||||
export function sendMessage(data: MpMessageApi.SendMessageRequest) {
|
||||
return requestClient.post('/mp/message/send', data);
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
import type { PageParam } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MpStatisticsApi {
|
||||
/** 统计查询参数 */
|
||||
export interface StatisticsQuery extends PageParam {
|
||||
accountId: number;
|
||||
beginDate: string;
|
||||
endDate: string;
|
||||
}
|
||||
|
||||
/** 消息发送概况数据 */
|
||||
export interface UpstreamMessage {
|
||||
refDate: string;
|
||||
msgType: string;
|
||||
msgUser: number;
|
||||
msgCount: number;
|
||||
}
|
||||
|
||||
/** 用户增减数据 */
|
||||
export interface UserSummary {
|
||||
refDate: string;
|
||||
userSource: number;
|
||||
newUser: number;
|
||||
cancelUser: number;
|
||||
cumulateUser: number;
|
||||
}
|
||||
|
||||
/** 用户累计数据 */
|
||||
export interface UserCumulate {
|
||||
refDate: string;
|
||||
cumulateUser: number;
|
||||
}
|
||||
|
||||
/** 接口分析数据 */
|
||||
export interface InterfaceSummary {
|
||||
refDate: string;
|
||||
callbackCount: number;
|
||||
failCount: number;
|
||||
totalTimeCost: number;
|
||||
maxTimeCost: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取消息发送概况数据 */
|
||||
export function getUpstreamMessage(params: MpStatisticsApi.StatisticsQuery) {
|
||||
return requestClient.get<MpStatisticsApi.UpstreamMessage[]>(
|
||||
'/mp/statistics/upstream-message',
|
||||
{
|
||||
params,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/** 获取用户增减数据 */
|
||||
export function getUserSummary(params: MpStatisticsApi.StatisticsQuery) {
|
||||
return requestClient.get<MpStatisticsApi.UserSummary[]>(
|
||||
'/mp/statistics/user-summary',
|
||||
{
|
||||
params,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/** 获取用户累计数据 */
|
||||
export function getUserCumulate(params: MpStatisticsApi.StatisticsQuery) {
|
||||
return requestClient.get<MpStatisticsApi.UserCumulate[]>(
|
||||
'/mp/statistics/user-cumulate',
|
||||
{
|
||||
params,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/** 获取接口分析数据 */
|
||||
export function getInterfaceSummary(params: MpStatisticsApi.StatisticsQuery) {
|
||||
return requestClient.get<MpStatisticsApi.InterfaceSummary[]>(
|
||||
'/mp/statistics/interface-summary',
|
||||
{
|
||||
params,
|
||||
},
|
||||
);
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MpTagApi {
|
||||
/** 标签信息 */
|
||||
export interface Tag {
|
||||
id?: number;
|
||||
name: string;
|
||||
accountId: number;
|
||||
createTime?: Date;
|
||||
}
|
||||
|
||||
/** 标签分页查询参数 */
|
||||
export interface TagPageQuery extends PageParam {
|
||||
accountId?: number;
|
||||
name?: string;
|
||||
}
|
||||
}
|
||||
|
||||
/** 创建公众号标签 */
|
||||
export function createTag(data: MpTagApi.Tag) {
|
||||
return requestClient.post('/mp/tag/create', data);
|
||||
}
|
||||
|
||||
/** 更新公众号标签 */
|
||||
export function updateTag(data: MpTagApi.Tag) {
|
||||
return requestClient.put('/mp/tag/update', data);
|
||||
}
|
||||
|
||||
/** 删除公众号标签 */
|
||||
export function deleteTag(id: number) {
|
||||
return requestClient.delete('/mp/tag/delete', {
|
||||
params: { id },
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取公众号标签 */
|
||||
export function getTag(id: number) {
|
||||
return requestClient.get<MpTagApi.Tag>('/mp/tag/get', {
|
||||
params: { id },
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取公众号标签分页 */
|
||||
export function getTagPage(params: MpTagApi.TagPageQuery) {
|
||||
return requestClient.get<PageResult<MpTagApi.Tag>>('/mp/tag/page', {
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取公众号标签精简信息列表 */
|
||||
export function getSimpleTagList() {
|
||||
return requestClient.get<MpTagApi.Tag[]>('/mp/tag/list-all-simple');
|
||||
}
|
||||
|
||||
/** 同步公众号标签 */
|
||||
export function syncTag(accountId: number) {
|
||||
return requestClient.post('/mp/tag/sync', null, {
|
||||
params: { accountId },
|
||||
});
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MpUserApi {
|
||||
/** 用户信息 */
|
||||
export interface User {
|
||||
id?: number;
|
||||
accountId: number;
|
||||
openid: string;
|
||||
nickname: string;
|
||||
avatar: string;
|
||||
sex: number;
|
||||
country: string;
|
||||
province: string;
|
||||
city: string;
|
||||
language: string;
|
||||
subscribe: boolean;
|
||||
subscribeTime?: Date;
|
||||
remark?: string;
|
||||
tagIds?: number[];
|
||||
createTime?: Date;
|
||||
}
|
||||
|
||||
/** 用户分页查询参数 */
|
||||
export interface UserPageQuery extends PageParam {
|
||||
accountId?: number;
|
||||
nickname?: string;
|
||||
tagId?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 更新公众号粉丝 */
|
||||
export function updateUser(data: MpUserApi.User) {
|
||||
return requestClient.put('/mp/user/update', data);
|
||||
}
|
||||
|
||||
/** 获取公众号粉丝 */
|
||||
export function getUser(id: number) {
|
||||
return requestClient.get<MpUserApi.User>('/mp/user/get', {
|
||||
params: { id },
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取公众号粉丝分页 */
|
||||
export function getUserPage(params: MpUserApi.UserPageQuery) {
|
||||
return requestClient.get<PageResult<MpUserApi.User>>('/mp/user/page', {
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/** 同步公众号粉丝 */
|
||||
export function syncUser(accountId: number) {
|
||||
return requestClient.post('/mp/user/sync', null, {
|
||||
params: { accountId },
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue