成就等界面接口调整
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import { api } from '@/apis/index';
|
||||
import type { Resource, ResultDomain } from '@/types';
|
||||
import type { Resource, ResourceRecommendVO, ResultDomain } from '@/types';
|
||||
|
||||
/**
|
||||
* 推荐API服务
|
||||
@@ -38,5 +38,27 @@ export const recommendApi = {
|
||||
async getHotNews(limit?: number): Promise<ResultDomain<Resource>> {
|
||||
const response = await api.get<Resource>('/homepage/recommend/hot-news', { limit });
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取热门资源列表(推荐类型:1)
|
||||
* @param limit 限制数量
|
||||
* @returns Promise<ResultDomain<ResourceRecommendVO>>
|
||||
*/
|
||||
async getHotResources(limit?: number): Promise<ResultDomain<ResourceRecommendVO>> {
|
||||
|
||||
const response = await api.get<ResourceRecommendVO>('/homepage/recommend/hot', { limit });
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取思政资源列表(推荐类型:2)
|
||||
* @param limit 限制数量
|
||||
* @returns Promise<ResultDomain<ResourceRecommendVO>>
|
||||
*/
|
||||
async getIdeologicalResources(limit?: number): Promise<ResultDomain<ResourceRecommendVO>> {
|
||||
|
||||
const response = await api.get<ResourceRecommendVO>('/homepage/recommend/ideological', { limit });
|
||||
return response.data;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -6,4 +6,5 @@
|
||||
|
||||
export * from './resourceTag';
|
||||
export * from './resource';
|
||||
export { bannerApi} from './banner';
|
||||
export * from './resourceRecommend';
|
||||
export { bannerApi } from './banner';
|
||||
@@ -136,16 +136,6 @@ export const resourceApi = {
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 收藏次数增减
|
||||
* @param resourceID 资源ID
|
||||
* @returns Promise<ResultDomain<Resource>>
|
||||
*/
|
||||
async resourceCollect(collect: UserCollection): Promise<ResultDomain<Resource>> {
|
||||
const response = await api.post<Resource>(`/news/resources/resource/collect`, collect);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
// ==================== 资源推荐和轮播操作 ====================
|
||||
|
||||
/**
|
||||
|
||||
155
schoolNewsWeb/src/apis/resource/resourceRecommend.ts
Normal file
155
schoolNewsWeb/src/apis/resource/resourceRecommend.ts
Normal file
@@ -0,0 +1,155 @@
|
||||
/**
|
||||
* @description 资源推荐管理API接口
|
||||
* @filename resourceRecommend.ts
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-31
|
||||
*/
|
||||
|
||||
import { api } from '@/apis';
|
||||
import type { ResultDomain, ResourceRecommendVO, PageParam } from '@/types';
|
||||
|
||||
/**
|
||||
* 推荐类型枚举
|
||||
*/
|
||||
export enum RecommendType {
|
||||
/** 热门资源推荐 */
|
||||
HOT = 1,
|
||||
/** 思政资源推荐 */
|
||||
IDEOLOGICAL = 2
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源推荐API服务
|
||||
*/
|
||||
export const resourceRecommendApi = {
|
||||
/**
|
||||
* 获取推荐列表
|
||||
* @returns Promise<ResultDomain<ResourceRecommendVO>>
|
||||
*/
|
||||
async getRecommendList(): Promise<ResultDomain<ResourceRecommendVO>> {
|
||||
const response = await api.get<ResourceRecommendVO>('/news/recommends/list');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 根据推荐类型获取推荐资源列表
|
||||
* @param recommendType 推荐类型(1-热门资源,2-思政资源)
|
||||
* @param limit 限制数量
|
||||
* @returns Promise<ResultDomain<ResourceRecommendVO>>
|
||||
*/
|
||||
async getRecommendsByType(recommendType: number, limit?: number): Promise<ResultDomain<ResourceRecommendVO>> {
|
||||
const params = limit ? { limit } : null;
|
||||
const response = await api.get<ResourceRecommendVO>(`/news/recommends/type/${recommendType}`, params);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 分页查询推荐资源列表
|
||||
* @param filter 筛选条件
|
||||
* @param pageParam 分页参数
|
||||
* @returns Promise<ResultDomain<ResourceRecommendVO>>
|
||||
*/
|
||||
async getRecommendPage(pageParam: PageParam, filter?: any): Promise<ResultDomain<ResourceRecommendVO>> {
|
||||
const response = await api.post<ResourceRecommendVO>('/news/recommends/page', {
|
||||
pageParam,
|
||||
filter,
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 根据ID获取推荐详情
|
||||
* @param recommendID 推荐ID
|
||||
* @returns Promise<ResultDomain<ResourceRecommendVO>>
|
||||
*/
|
||||
async getRecommendById(recommendID: string): Promise<ResultDomain<ResourceRecommendVO>> {
|
||||
const response = await api.get<ResourceRecommendVO>(`/news/recommends/recommend/${recommendID}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 创建推荐
|
||||
* @param recommend 推荐信息
|
||||
* @returns Promise<ResultDomain<any>>
|
||||
*/
|
||||
async createRecommend(recommend: any): Promise<ResultDomain<any>> {
|
||||
const response = await api.post<any>('/news/recommends/recommend', recommend);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 批量添加推荐资源
|
||||
* @param resourceIDs 资源ID列表
|
||||
* @param recommendType 推荐类型
|
||||
* @param reason 推荐理由(可选)
|
||||
* @returns Promise<ResultDomain<any>>
|
||||
*/
|
||||
async batchAddRecommends(resourceIDs: string[], recommendType: number, reason?: string): Promise<ResultDomain<any>> {
|
||||
const response = await api.post<any>('/news/recommends/recommend/batch', {
|
||||
resourceIDs,
|
||||
recommendType,
|
||||
reason
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新推荐
|
||||
* @param recommend 推荐信息
|
||||
* @returns Promise<ResultDomain<any>>
|
||||
*/
|
||||
async updateRecommend(recommend: any): Promise<ResultDomain<any>> {
|
||||
const response = await api.put<any>('/news/recommends/recommend', recommend);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除推荐
|
||||
* @param recommendID 推荐ID
|
||||
* @returns Promise<ResultDomain<boolean>>
|
||||
*/
|
||||
async deleteRecommend(recommendID: string): Promise<ResultDomain<boolean>> {
|
||||
const response = await api.delete<boolean>(`/news/recommends/recommend/${recommendID}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新推荐排序
|
||||
* @param recommendID 推荐ID
|
||||
* @param orderNum 排序号
|
||||
* @returns Promise<ResultDomain<any>>
|
||||
*/
|
||||
async updateRecommendOrder(recommendID: string, orderNum: number): Promise<ResultDomain<any>> {
|
||||
const response = await api.put<any>(`/news/recommends/recommend/${recommendID}/order`, null, {
|
||||
params: { orderNum }
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 检查资源是否已推荐(按类型)
|
||||
* @param resourceID 资源ID
|
||||
* @param recommendType 推荐类型
|
||||
* @returns Promise<ResultDomain<boolean>>
|
||||
*/
|
||||
async isResourceRecommendedByType(resourceID: string, recommendType: number): Promise<ResultDomain<boolean>> {
|
||||
const response = await api.get<boolean>(`/news/recommends/check/${resourceID}`, {
|
||||
recommendType
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 统计推荐资源总数
|
||||
* @param filter 筛选条件
|
||||
* @returns Promise<ResultDomain<number>>
|
||||
*/
|
||||
async countRecommends(filter?: any): Promise<ResultDomain<number>> {
|
||||
const response = await api.post<number>('/news/recommends/count', filter);
|
||||
return response.data;
|
||||
}
|
||||
};
|
||||
|
||||
export default resourceRecommendApi;
|
||||
|
||||
@@ -19,8 +19,8 @@ export const resourceTagApi = {
|
||||
* 获取标签列表(获取所有标签)
|
||||
* @returns Promise<ResultDomain<Tag>>
|
||||
*/
|
||||
async getTagList(): Promise<ResultDomain<Tag>> {
|
||||
const response = await api.get<Tag>('/news/tags/list');
|
||||
async getTagList(filter: Tag): Promise<ResultDomain<Tag>> {
|
||||
const response = await api.get<Tag>('/news/tags/list', filter);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import { api } from '@/apis/index';
|
||||
import type { UserCollection, ResultDomain } from '@/types';
|
||||
import type { UserCollection, UserCollectionVO, ResultDomain } from '@/types';
|
||||
|
||||
/**
|
||||
* 用户收藏API服务
|
||||
@@ -13,14 +13,13 @@ import type { UserCollection, ResultDomain } from '@/types';
|
||||
export const userCollectionApi = {
|
||||
baseUrl: '/usercenter/collections',
|
||||
/**
|
||||
* 获取用户收藏列表
|
||||
* 获取用户收藏列表(扁平化VO,包含资源/课程详情)
|
||||
* @param userID 用户ID
|
||||
* @param collectionType 收藏类型
|
||||
* @returns Promise<ResultDomain<UserCollection>>
|
||||
* @returns Promise<ResultDomain<UserCollectionVO>>
|
||||
*/
|
||||
async getUserCollections(userID: string, collectionType?: number): Promise<ResultDomain<UserCollection>> {
|
||||
const response = await api.get<UserCollection>(`${this.baseUrl}/list`, {
|
||||
userID,
|
||||
async getUserCollections(userID: string, collectionType?: number): Promise<ResultDomain<UserCollectionVO>> {
|
||||
const response = await api.get<UserCollectionVO>(`${this.baseUrl}/user/${userID}`, {
|
||||
collectionType
|
||||
});
|
||||
return response.data;
|
||||
@@ -43,12 +42,8 @@ export const userCollectionApi = {
|
||||
* @param collectionID 收藏对象ID
|
||||
* @returns Promise<ResultDomain<boolean>>
|
||||
*/
|
||||
async removeCollection(userID: string, collectionType: number, collectionID: string): Promise<ResultDomain<boolean>> {
|
||||
const response = await api.delete<boolean>(`${this.baseUrl}/collect`, {
|
||||
userID,
|
||||
collectionType,
|
||||
collectionID
|
||||
});
|
||||
async removeCollection(collection: UserCollection): Promise<ResultDomain<UserCollection>> {
|
||||
const response = await api.delete<UserCollection>(`${this.baseUrl}/collect`, collection);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user