完善用户提问功能模块
This commit is contained in:
@ -77,3 +77,4 @@ export async function updateAboutUs(params: AboutUsRequest) {
|
||||
data: params,
|
||||
});
|
||||
}
|
||||
|
@ -2,21 +2,30 @@ import request from '@/utils/request';
|
||||
|
||||
// 获取帮助中心列表
|
||||
export async function getHelpList(params: API.HelpSearchParams) {
|
||||
return request('/api/help/list', {
|
||||
return request('/portals/helpqanda/getPage', {
|
||||
method: 'POST',
|
||||
data: {
|
||||
basePageRequest: {
|
||||
pageNo: params.pageNo || 1,
|
||||
pageSize: params.pageSize || 10,
|
||||
},
|
||||
...params,
|
||||
title: params.title,
|
||||
type: params.type,
|
||||
status: params.status,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 获取帮助详情
|
||||
export async function getHelpDetail(id: string) {
|
||||
return request(`/portals/helpqanda/${id}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
// 添加帮助
|
||||
export async function addHelp(params: API.HelpRequest) {
|
||||
return request('/api/help/add', {
|
||||
return request('/portals/helpqanda', {
|
||||
method: 'POST',
|
||||
data: params,
|
||||
});
|
||||
@ -24,39 +33,68 @@ export async function addHelp(params: API.HelpRequest) {
|
||||
|
||||
// 更新帮助
|
||||
export async function updateHelp(id: string, params: API.HelpRequest) {
|
||||
return request(`/api/help/update/${id}`, {
|
||||
return request('/portals/helpqanda', {
|
||||
method: 'PUT',
|
||||
data: params,
|
||||
data: {
|
||||
...params,
|
||||
id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 删除帮助
|
||||
export async function deleteHelp(id: string) {
|
||||
return request(`/api/help/delete/${id}`, {
|
||||
return request(`/portals/helpqanda/${id}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
}
|
||||
|
||||
// 批量删除帮助
|
||||
export async function batchDeleteHelp(ids: string[]) {
|
||||
return request('/api/help/batchDelete', {
|
||||
method: 'DELETE',
|
||||
data: { ids },
|
||||
// 由于没有提供批量删除接口,使用Promise.all进行多次单独删除
|
||||
return Promise.all(ids.map(id => deleteHelp(id))).then(results => {
|
||||
// 检查是否所有删除操作都成功
|
||||
const allSuccess = results.every(res => res.success);
|
||||
return {
|
||||
success: allSuccess,
|
||||
message: allSuccess ? '批量删除成功' : '部分删除失败',
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
// 更新帮助状态(发布/下架)
|
||||
export async function updateHelpStatus(id: string, status: string) {
|
||||
return request(`/api/help/updateStatus/${id}`, {
|
||||
method: 'PUT',
|
||||
data: { status },
|
||||
});
|
||||
// 根据状态决定调用上架还是下架接口
|
||||
if (status === '1') {
|
||||
// 上架
|
||||
return request('/portals/helpqanda/up', {
|
||||
method: 'POST',
|
||||
data: { id },
|
||||
});
|
||||
} else {
|
||||
// 下架
|
||||
return request('/portals/helpqanda/down', {
|
||||
method: 'POST',
|
||||
data: { id },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 更新帮助置顶状态
|
||||
export async function updateHelpTopStatus(id: string, isTop: string) {
|
||||
return request(`/api/help/updateTop/${id}`, {
|
||||
method: 'PUT',
|
||||
data: { isTop },
|
||||
// 根据接口规范,置顶状态的更新应包含在常规更新中
|
||||
// 由于没有专门的置顶接口,这里需要先获取详情,然后更新
|
||||
return getHelpDetail(id).then(res => {
|
||||
if (res.success) {
|
||||
const detail = res.data;
|
||||
return updateHelp(id, {
|
||||
...detail,
|
||||
isTop,
|
||||
});
|
||||
}
|
||||
return {
|
||||
success: false,
|
||||
message: '获取详情失败,无法更新置顶状态',
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
import request from '@/utils/request';
|
||||
|
||||
// 获取通知列表
|
||||
export async function getNoticeList(params: API.NoticeSearchParams) {
|
||||
return request('/api/notices', {
|
||||
export async function getNoticeList(params: API.NoticeSearchParams & { pageNo?: number; pageSize?: number }) {
|
||||
return request('/notices', {
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
@ -10,14 +10,14 @@ export async function getNoticeList(params: API.NoticeSearchParams) {
|
||||
|
||||
// 获取通知详情
|
||||
export async function getNoticeDetail(id: string) {
|
||||
return request(`/api/notices/${id}`, {
|
||||
return request(`/notices/${id}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
// 新增通知
|
||||
export async function addNotice(params: API.NoticeRequest) {
|
||||
return request('/api/notices', {
|
||||
return request('/notices', {
|
||||
method: 'POST',
|
||||
data: params,
|
||||
});
|
||||
@ -25,7 +25,7 @@ export async function addNotice(params: API.NoticeRequest) {
|
||||
|
||||
// 更新通知
|
||||
export async function updateNotice(id: string, params: API.NoticeRequest) {
|
||||
return request(`/api/notices/${id}`, {
|
||||
return request(`/notices/${id}`, {
|
||||
method: 'PUT',
|
||||
data: params,
|
||||
});
|
||||
@ -33,14 +33,14 @@ export async function updateNotice(id: string, params: API.NoticeRequest) {
|
||||
|
||||
// 删除通知
|
||||
export async function deleteNotice(id: string) {
|
||||
return request(`/api/notices/${id}`, {
|
||||
return request(`/notices/${id}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
}
|
||||
|
||||
// 批量删除通知
|
||||
export async function batchDeleteNotice(ids: string[]) {
|
||||
return request('/api/notices/batch', {
|
||||
return request('/notices/batch', {
|
||||
method: 'DELETE',
|
||||
data: { ids },
|
||||
});
|
||||
@ -48,7 +48,7 @@ export async function batchDeleteNotice(ids: string[]) {
|
||||
|
||||
// 发布/下架通知
|
||||
export async function updateNoticeStatus(id: string, status: string) {
|
||||
return request(`/api/notices/${id}/status`, {
|
||||
return request(`/notices/${id}/status`, {
|
||||
method: 'PUT',
|
||||
data: { status },
|
||||
});
|
||||
@ -56,7 +56,7 @@ export async function updateNoticeStatus(id: string, status: string) {
|
||||
|
||||
// 置顶/取消置顶通知
|
||||
export async function updateNoticeTopStatus(id: string, isTop: string) {
|
||||
return request(`/api/notices/${id}/top`, {
|
||||
return request(`/notices/${id}/top`, {
|
||||
method: 'PUT',
|
||||
data: { isTop },
|
||||
});
|
||||
|
113
src/servers/api/typings.d.ts
vendored
113
src/servers/api/typings.d.ts
vendored
@ -141,44 +141,34 @@ declare namespace API {
|
||||
}[];
|
||||
}[]
|
||||
|
||||
// 基础分页请求参数
|
||||
export interface BasePageRequest {
|
||||
// 通用响应类型
|
||||
type Response<T = any> = {
|
||||
success: boolean;
|
||||
data: T;
|
||||
message?: string;
|
||||
code?: number;
|
||||
};
|
||||
|
||||
// 分页响应类型
|
||||
type PageResponse<T = any> = {
|
||||
records: T[];
|
||||
total: number;
|
||||
size: number;
|
||||
current: number;
|
||||
pages: number;
|
||||
};
|
||||
|
||||
// 基础分页请求
|
||||
interface BasePageRequest {
|
||||
pageNo: number;
|
||||
pageSize: number;
|
||||
[property: string]: unknown;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
// 分页请求参数
|
||||
export interface PageRequest {
|
||||
interface PageRequest {
|
||||
basePageRequest: BasePageRequest;
|
||||
title?: string;
|
||||
status?: string;
|
||||
[property: string]: unknown;
|
||||
}
|
||||
|
||||
// 基础响应格式
|
||||
export interface Response<T = unknown> {
|
||||
code: number;
|
||||
data: T;
|
||||
message: string;
|
||||
success: boolean;
|
||||
[property: string]: unknown;
|
||||
}
|
||||
|
||||
// 分页数据响应
|
||||
export interface PageResponse<T> {
|
||||
countId: null;
|
||||
current: number;
|
||||
hitCount: boolean;
|
||||
maxLimit: null;
|
||||
optimizeCountSql: boolean;
|
||||
orders: string[];
|
||||
pages: number;
|
||||
records: T[];
|
||||
searchCount: boolean;
|
||||
size: number;
|
||||
total: number;
|
||||
[property: string]: unknown;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
// 政策法规数据项
|
||||
@ -286,6 +276,8 @@ declare namespace API {
|
||||
export interface NoticeSearchParams {
|
||||
title?: string;
|
||||
status?: string;
|
||||
pageNo?: number;
|
||||
pageSize?: number;
|
||||
}
|
||||
|
||||
// 帮助中心数据项
|
||||
@ -360,4 +352,61 @@ declare namespace API {
|
||||
pageNo?: number;
|
||||
pageSize?: number;
|
||||
}
|
||||
|
||||
// 用户问题记录类型
|
||||
interface QuestionRecord {
|
||||
id: string;
|
||||
title: string;
|
||||
type: string;
|
||||
content: string;
|
||||
answerContent?: string;
|
||||
userName: string;
|
||||
companyName: string;
|
||||
fullName: string;
|
||||
contactDetails: string;
|
||||
email: string;
|
||||
askTime: string;
|
||||
answerTime?: string;
|
||||
answerBy?: string;
|
||||
isAnswer: string; // 0-未回答,1-已回答
|
||||
isPublished?: number; // 0-未发布,1-已发布
|
||||
isTop?: number; // 0-未置顶,1-已置顶
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
// 问题列表请求参数
|
||||
interface QuestionListRequest {
|
||||
isAnswer?: number; // 0-未回答,1-已回答
|
||||
title?: string;
|
||||
type?: string;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
// 问题添加请求参数
|
||||
interface QuestionAddRequest {
|
||||
title: string;
|
||||
content: string;
|
||||
type: string;
|
||||
fullName: string;
|
||||
companyName: string;
|
||||
userName: string;
|
||||
contactDetails: string;
|
||||
email: string;
|
||||
}
|
||||
|
||||
// 问题回答请求参数
|
||||
interface QuestionAnswerRequest {
|
||||
id: string;
|
||||
answerContent: string;
|
||||
isPublished?: number; // 0-未发布,1-已发布
|
||||
isTop?: number; // 0-未置顶,1-已置顶
|
||||
}
|
||||
|
||||
// 问题状态更新请求参数
|
||||
interface QuestionStatusRequest {
|
||||
id: string;
|
||||
isPublished?: number; // 0-未发布,1-已发布
|
||||
isTop?: number; // 0-未置顶,1-已置顶
|
||||
}
|
||||
}
|
||||
|
@ -1,75 +1,81 @@
|
||||
import request from '@/utils/request';
|
||||
|
||||
// 获取用户提问列表
|
||||
export async function getUserQuestions(params: API.UserQuestionSearchParams) {
|
||||
return request('/api/userQuestion/list', {
|
||||
method: 'POST',
|
||||
data: {
|
||||
basePageRequest: {
|
||||
pageNo: params.pageNo || 1,
|
||||
pageSize: params.pageSize || 10,
|
||||
},
|
||||
...params,
|
||||
},
|
||||
// 获取问题列表
|
||||
export async function getQuestionList(params: API.QuestionListRequest): Promise<API.Response<API.QuestionRecord[]>> {
|
||||
return request('/portals/qanda', {
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
// 获取已回答的用户提问列表
|
||||
export async function getAnsweredQuestions(params: API.UserQuestionSearchParams) {
|
||||
return request('/api/userQuestion/answered', {
|
||||
// 获取问题分页列表
|
||||
export async function getQuestionPage(params: API.PageRequest): Promise<API.Response<API.PageResponse<API.QuestionRecord>>> {
|
||||
return request('/portals/qanda/getPage', {
|
||||
method: 'POST',
|
||||
data: {
|
||||
basePageRequest: {
|
||||
pageNo: params.pageNo || 1,
|
||||
pageSize: params.pageSize || 10,
|
||||
},
|
||||
...params,
|
||||
status: '1', // 已回答状态
|
||||
},
|
||||
data: params,
|
||||
});
|
||||
}
|
||||
|
||||
// 获取未回答的用户提问列表
|
||||
export async function getUnansweredQuestions(params: API.UserQuestionSearchParams) {
|
||||
return request('/api/userQuestion/unanswered', {
|
||||
method: 'POST',
|
||||
data: {
|
||||
basePageRequest: {
|
||||
pageNo: params.pageNo || 1,
|
||||
pageSize: params.pageSize || 10,
|
||||
},
|
||||
...params,
|
||||
status: '0', // 未回答状态
|
||||
},
|
||||
// 获取问题详情
|
||||
export async function getQuestionDetail(id: string): Promise<API.Response<API.QuestionRecord>> {
|
||||
return request(`/portals/qanda/${id}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
// 回复用户提问
|
||||
export async function replyQuestion(id: string, answer: string) {
|
||||
return request(`/api/userQuestion/reply/${id}`, {
|
||||
// 回答问题
|
||||
export async function answerQuestion(params: API.QuestionAnswerRequest): Promise<API.Response<string>> {
|
||||
return request('/portals/qanda', {
|
||||
method: 'PUT',
|
||||
data: { answer },
|
||||
data: params,
|
||||
});
|
||||
}
|
||||
|
||||
// 删除用户提问
|
||||
export async function deleteQuestion(id: string) {
|
||||
return request(`/api/userQuestion/delete/${id}`, {
|
||||
// 标记问题为已阅
|
||||
export async function markQuestionSeen(id: string): Promise<API.Response<string>> {
|
||||
return request('/portals/qanda/seeEdit', {
|
||||
method: 'POST',
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 标记问题为已阅(新增接口)
|
||||
export async function markQuestionSeeEdit(id: string): Promise<API.Response<string>> {
|
||||
return request(`/portals/qanda/seeEdit`, {
|
||||
method: 'POST',
|
||||
data: { id },
|
||||
});
|
||||
}
|
||||
|
||||
// 更新问题状态(发布/置顶)
|
||||
export async function updateQuestionStatus(params: API.QuestionStatusRequest): Promise<API.Response<string>> {
|
||||
return request('/portals/qanda/status', {
|
||||
method: 'PUT',
|
||||
data: params,
|
||||
});
|
||||
}
|
||||
|
||||
// 删除单个问题
|
||||
export async function deleteQuestion(id: string): Promise<API.Response<string>> {
|
||||
return request(`/portals/qanda/${id}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
}
|
||||
|
||||
// 批量删除用户提问
|
||||
export async function batchDeleteQuestions(ids: string[]) {
|
||||
return request('/api/userQuestion/batchDelete', {
|
||||
// 批量删除问题
|
||||
export async function batchDeleteQuestion(ids: string[]): Promise<API.Response<string>> {
|
||||
return request('/portals/qanda/batch', {
|
||||
method: 'DELETE',
|
||||
data: { ids },
|
||||
});
|
||||
}
|
||||
|
||||
// 获取用户提问详情
|
||||
export async function getQuestionDetail(id: string) {
|
||||
return request(`/api/userQuestion/detail/${id}`, {
|
||||
method: 'GET',
|
||||
// 添加问题
|
||||
export async function addQuestion(params: API.QuestionAddRequest): Promise<API.Response<string>> {
|
||||
return request('/portals/qanda', {
|
||||
method: 'POST',
|
||||
data: params,
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user