Commit 411ec283 by wangshouyong

25171

parent 7a811d04
......@@ -24,6 +24,7 @@ import type {
UpdateArticleShowLatestDto,
LocateCommentParams,
CommentLocationDto,
PushRecallResultDto,
} from './types'
import type { BackendServicePageResult, PageSearchParams } from '@/utils/request/types'
import { SpecificVideoRewardEnum, BooleanFlag } from '@/constants'
......@@ -228,7 +229,7 @@ export const updateArticleRecommendAndSort = (data: UpdateArticleRecommendAndSor
* 已经撤回的批次会自动跳过,重复调用失败可以重试。能不能点由列表 pushInfo.recallable 决定。
*/
export const recallPush = (articleId: number) => {
return service.request({
return service.request<PushRecallResultDto>({
url: `/cultureEventPushPersons/recallPush?articleId=${articleId}`,
method: 'POST',
})
......
......@@ -308,6 +308,21 @@ export interface ArticlePushInfoDto {
}
/**
* 撤回/取消推送的结果。后端撤回失败时不会抛异常(部分批次成功时状态要保留),
* HTTP 仍然是 200,所以前端必须看 failCount 才知道到底撤没撤掉。
*/
export interface PushRecallResultDto {
/** 本次需要撤回的批次数 */
total: number
successCount: number
failCount: number
/** 是否属于「取消尚未执行的定时推送」 */
cancelled: boolean
/** 结果说明,可直接展示给用户 */
message: string
}
/**
* 专栏选项
*/
export interface ColumnOptionDto {
......
......@@ -133,8 +133,14 @@ const handleRecallPush = async (row: ArticleItemDto) => {
: '确定要撤回这条推送吗?已经收到通知的用户不会撤回消息。',
type: 'warning',
})
await recallPush(row.id)
push.success(isScheduled ? '取消定时推送成功' : '撤回成功')
// 后端撤回失败时不抛异常(部分批次成功的状态要保留),HTTP 还是 200,
// 所以这里必须看 failCount,否则会出现"提示撤回成功、状态却没变"
const { data } = await recallPush(row.id)
if (data?.failCount) {
push.warning(data.message || '部分批次撤回失败,可稍后重试')
} else {
push.success(data?.message || (isScheduled ? '取消定时推送成功' : '撤回成功'))
}
refresh()
}
</script>
......
......@@ -134,8 +134,14 @@ const handleRecallPush = async (row: ArticleItemDto) => {
: '确定要撤回这条推送吗?已经收到通知的用户不会撤回消息。',
type: 'warning',
})
await recallPush(row.id)
push.success(isScheduled ? '取消定时推送成功' : '撤回成功')
// 后端撤回失败时不抛异常(部分批次成功的状态要保留),HTTP 还是 200,
// 所以这里必须看 failCount,否则会出现"提示撤回成功、状态却没变"
const { data } = await recallPush(row.id)
if (data?.failCount) {
push.warning(data.message || '部分批次撤回失败,可稍后重试')
} else {
push.success(data?.message || (isScheduled ? '取消定时推送成功' : '撤回成功'))
}
refresh()
}
</script>
......
......@@ -137,8 +137,14 @@ const handleRecallPush = async (row: ArticleItemDto) => {
: '确定要撤回这条推送吗?已经收到通知的用户不会撤回消息。',
type: 'warning',
})
await recallPush(row.id)
push.success(isScheduled ? '取消定时推送成功' : '撤回成功')
// 后端撤回失败时不抛异常(部分批次成功的状态要保留),HTTP 还是 200,
// 所以这里必须看 failCount,否则会出现"提示撤回成功、状态却没变"
const { data } = await recallPush(row.id)
if (data?.failCount) {
push.warning(data.message || '部分批次撤回失败,可稍后重试')
} else {
push.success(data?.message || (isScheduled ? '取消定时推送成功' : '撤回成功'))
}
refresh()
}
</script>
......
......@@ -133,8 +133,14 @@ const handleRecallPush = async (row: ArticleItemDto) => {
: '确定要撤回这条推送吗?已经收到通知的用户不会撤回消息。',
type: 'warning',
})
await recallPush(row.id)
push.success(isScheduled ? '取消定时推送成功' : '撤回成功')
// 后端撤回失败时不抛异常(部分批次成功的状态要保留),HTTP 还是 200,
// 所以这里必须看 failCount,否则会出现"提示撤回成功、状态却没变"
const { data } = await recallPush(row.id)
if (data?.failCount) {
push.warning(data.message || '部分批次撤回失败,可稍后重试')
} else {
push.success(data?.message || (isScheduled ? '取消定时推送成功' : '撤回成功'))
}
refresh()
}
</script>
......
......@@ -147,8 +147,14 @@ const handleRecallPush = async (row: ArticleItemDto) => {
: '确定要撤回这条推送吗?已经收到通知的用户不会撤回消息。',
type: 'warning',
})
await recallPush(row.id)
push.success(isScheduled ? '取消定时推送成功' : '撤回成功')
// 后端撤回失败时不抛异常(部分批次成功的状态要保留),HTTP 还是 200,
// 所以这里必须看 failCount,否则会出现"提示撤回成功、状态却没变"
const { data } = await recallPush(row.id)
if (data?.failCount) {
push.warning(data.message || '部分批次撤回失败,可稍后重试')
} else {
push.success(data?.message || (isScheduled ? '取消定时推送成功' : '撤回成功'))
}
refresh()
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment