web-apis\types
This commit is contained in:
208
schoolNewsWeb/src/apis/homepage/index.ts
Normal file
208
schoolNewsWeb/src/apis/homepage/index.ts
Normal file
@@ -0,0 +1,208 @@
|
||||
/**
|
||||
* @description 首页相关API
|
||||
* @author system
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
|
||||
import { api } from '@/apis/index';
|
||||
import type { Resource, Banner, ResultDomain } from '@/types';
|
||||
|
||||
/**
|
||||
* 首页API服务
|
||||
*/
|
||||
export const homepageApi = {
|
||||
/**
|
||||
* 获取轮播组件数据
|
||||
* @returns Promise<ResultDomain<Banner>>
|
||||
*/
|
||||
async getBannerList(): Promise<ResultDomain<Banner>> {
|
||||
const response = await api.get<Banner>('/homepage/banner/list');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 点击轮播跳转新闻详情
|
||||
* @param bannerID Banner ID
|
||||
* @returns Promise<ResultDomain<Resource>>
|
||||
*/
|
||||
async getBannerNewsDetail(bannerID: string): Promise<ResultDomain<Resource>> {
|
||||
const response = await api.get<Resource>(`/homepage/banner/click/${bannerID}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取活跃轮播列表
|
||||
* @returns Promise<ResultDomain<Banner>>
|
||||
*/
|
||||
async getActiveBanners(): Promise<ResultDomain<Banner>> {
|
||||
const response = await api.get<Banner>('/homepage/banner/active');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取TOP资源推荐列表
|
||||
* @returns Promise<ResultDomain<Resource>>
|
||||
*/
|
||||
async getTopRecommendList(): Promise<ResultDomain<Resource>> {
|
||||
const response = await api.get<Resource>('/homepage/recommend/top-list');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 后台调控展示顺序
|
||||
* @param orderData 排序数据
|
||||
* @returns Promise<ResultDomain<boolean>>
|
||||
*/
|
||||
async updateRecommendOrder(orderData: any): Promise<ResultDomain<boolean>> {
|
||||
const response = await api.put<boolean>('/homepage/recommend/order', orderData);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取高热度新闻
|
||||
* @param limit 限制数量
|
||||
* @returns Promise<ResultDomain<Resource>>
|
||||
*/
|
||||
async getHotNews(limit?: number): Promise<ResultDomain<Resource>> {
|
||||
const response = await api.get<Resource>('/homepage/recommend/hot-news', { limit });
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取思政新闻概览
|
||||
* @param pageNum 页码
|
||||
* @param pageSize 每页条数
|
||||
* @returns Promise<ResultDomain<Resource>>
|
||||
*/
|
||||
async getNewsOverview(pageNum?: number, pageSize?: number): Promise<ResultDomain<Resource>> {
|
||||
const response = await api.get<Resource>('/homepage/news/overview', {
|
||||
pageNum,
|
||||
pageSize
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 点击跳转二级详情页
|
||||
* @param newsID 新闻ID
|
||||
* @returns Promise<ResultDomain<Resource>>
|
||||
*/
|
||||
async getNewsDetail(newsID: string): Promise<ResultDomain<Resource>> {
|
||||
const response = await api.get<Resource>(`/homepage/news/detail/${newsID}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取最新思政新闻
|
||||
* @param limit 限制数量
|
||||
* @returns Promise<ResultDomain<Resource>>
|
||||
*/
|
||||
async getLatestNews(limit?: number): Promise<ResultDomain<Resource>> {
|
||||
const response = await api.get<Resource>('/homepage/news/latest', { limit });
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取顶部菜单栏配置
|
||||
* @returns Promise<ResultDomain<any>>
|
||||
*/
|
||||
async getTopMenuConfig(): Promise<ResultDomain<any>> {
|
||||
const response = await api.get<any>('/homepage/menu/top-menu');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 后台修改菜单名称
|
||||
* @param menuData 菜单数据
|
||||
* @returns Promise<ResultDomain<boolean>>
|
||||
*/
|
||||
async updateMenuName(menuData: any): Promise<ResultDomain<boolean>> {
|
||||
const response = await api.put<boolean>('/homepage/menu/update-name', menuData);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取菜单项列表
|
||||
* @returns Promise<ResultDomain<any>>
|
||||
*/
|
||||
async getMenuList(): Promise<ResultDomain<any>> {
|
||||
const response = await api.get<any>('/homepage/menu/list');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 模糊检索资源
|
||||
* @param keyword 关键词
|
||||
* @returns Promise<ResultDomain<Resource>>
|
||||
*/
|
||||
async searchResources(keyword: string): Promise<ResultDomain<Resource>> {
|
||||
const response = await api.get<Resource>('/homepage/search', { keyword });
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 实时搜索建议
|
||||
* @param keyword 关键词
|
||||
* @returns Promise<ResultDomain<any>>
|
||||
*/
|
||||
async getSearchSuggestions(keyword: string): Promise<ResultDomain<any>> {
|
||||
const response = await api.get<any>('/homepage/search/suggestions', { keyword });
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取热门搜索词
|
||||
* @returns Promise<ResultDomain<any>>
|
||||
*/
|
||||
async getHotKeywords(): Promise<ResultDomain<any>> {
|
||||
const response = await api.get<any>('/homepage/search/hot-keywords');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 搜索新闻
|
||||
* @param keyword 关键词
|
||||
* @returns Promise<ResultDomain<Resource>>
|
||||
*/
|
||||
async searchNews(keyword: string): Promise<ResultDomain<Resource>> {
|
||||
const response = await api.get<Resource>('/homepage/search/news', { keyword });
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 搜索课程
|
||||
* @param keyword 关键词
|
||||
* @returns Promise<ResultDomain<any>>
|
||||
*/
|
||||
async searchCourses(keyword: string): Promise<ResultDomain<any>> {
|
||||
const response = await api.get<any>('/homepage/search/courses', { keyword });
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取首页统计数据
|
||||
* @returns Promise<ResultDomain<any>>
|
||||
*/
|
||||
async getHomePageStatistics(): Promise<ResultDomain<any>> {
|
||||
const response = await api.get<any>('/homepage/statistics');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取今日访问量
|
||||
* @returns Promise<ResultDomain<any>>
|
||||
*/
|
||||
async getTodayVisits(): Promise<ResultDomain<any>> {
|
||||
const response = await api.get<any>('/homepage/statistics/today-visits');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取资源总数
|
||||
* @returns Promise<ResultDomain<any>>
|
||||
*/
|
||||
async getTotalResources(): Promise<ResultDomain<any>> {
|
||||
const response = await api.get<any>('/homepage/statistics/total-resources');
|
||||
return response.data;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user