视图修改、接口修改
This commit is contained in:
124
schoolNewsWeb/src/apis/resource/banner.ts
Normal file
124
schoolNewsWeb/src/apis/resource/banner.ts
Normal file
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
* @description Banner 管理 API 接口
|
||||
* @filename banner-manage.ts
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-28
|
||||
*/
|
||||
|
||||
import { api } from '@/apis';
|
||||
import type { ResultDomain, Banner, PageParam } from '@/types';
|
||||
|
||||
/**
|
||||
* Banner 管理 API 服务
|
||||
*/
|
||||
export const bannerApi = {
|
||||
/**
|
||||
* 获取横幅列表
|
||||
* @param filter 筛选条件
|
||||
* @returns Promise<ResultDomain<Banner>>
|
||||
*/
|
||||
async getBannerList(filter?: Partial<Banner>): Promise<ResultDomain<Banner>> {
|
||||
const response = await api.get<Banner>('/news/banners/list', filter);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取横幅分页列表
|
||||
* @param pageParam 分页参数
|
||||
* @param filter 筛选条件
|
||||
* @returns Promise<ResultDomain<Banner>>
|
||||
*/
|
||||
async getBannerPage(pageParam: PageParam, filter?: Partial<Banner>): Promise<ResultDomain<Banner>> {
|
||||
const response = await api.post<Banner>('/news/banners/banner/page', {
|
||||
pageParam,
|
||||
filter,
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 创建横幅
|
||||
* @param banner 横幅信息
|
||||
* @returns Promise<ResultDomain<Banner>>
|
||||
*/
|
||||
async createBanner(banner: Banner): Promise<ResultDomain<Banner>> {
|
||||
const response = await api.post<Banner>('/news/banners/banner', banner);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新横幅
|
||||
* @param banner 横幅信息
|
||||
* @returns Promise<ResultDomain<Banner>>
|
||||
*/
|
||||
async updateBanner(banner: Banner): Promise<ResultDomain<Banner>> {
|
||||
const response = await api.put<Banner>('/news/banners/banner', banner);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除横幅
|
||||
* @param banner 横幅信息(包含 bannerID)
|
||||
* @returns Promise<ResultDomain<boolean>>
|
||||
*/
|
||||
async deleteBanner(banner: Banner): Promise<ResultDomain<boolean>> {
|
||||
const response = await api.delete<boolean>('/news/banners/banner', {
|
||||
data: banner
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 根据 ID 删除横幅
|
||||
* @param bannerID 横幅ID
|
||||
* @returns Promise<ResultDomain<boolean>>
|
||||
*/
|
||||
async deleteBannerById(bannerID: string): Promise<ResultDomain<boolean>> {
|
||||
return this.deleteBanner({ id: bannerID });
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新横幅状态
|
||||
* @param bannerID 横幅ID
|
||||
* @param status 状态值(0禁用 1启用)
|
||||
* @returns Promise<ResultDomain<Banner>>
|
||||
*/
|
||||
async updateBannerStatus(bannerID: string, status: number): Promise<ResultDomain<Banner>> {
|
||||
const response = await api.put<Banner>('/news/banners/banner/status', {
|
||||
id: bannerID,
|
||||
status,
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 启用横幅
|
||||
* @param bannerID 横幅ID
|
||||
* @returns Promise<ResultDomain<Banner>>
|
||||
*/
|
||||
async enableBanner(bannerID: string): Promise<ResultDomain<Banner>> {
|
||||
return this.updateBannerStatus(bannerID, 1);
|
||||
},
|
||||
|
||||
/**
|
||||
* 禁用横幅
|
||||
* @param bannerID 横幅ID
|
||||
* @returns Promise<ResultDomain<Banner>>
|
||||
*/
|
||||
async disableBanner(bannerID: string): Promise<ResultDomain<Banner>> {
|
||||
return this.updateBannerStatus(bannerID, 0);
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取首页横幅列表
|
||||
* @returns Promise<ResultDomain<Banner>>
|
||||
*/
|
||||
async getHomeBannerList(): Promise<ResultDomain<Banner>> {
|
||||
const response = await api.get<Banner>('/news/banners/home');
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
|
||||
export default bannerApi;
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
|
||||
export * from './resourceCategory';
|
||||
export * from './resourceTag';
|
||||
export * from './resource';
|
||||
export * from './resource';
|
||||
export { bannerApi} from './banner';
|
||||
@@ -1,117 +0,0 @@
|
||||
/**
|
||||
* @description 资源分类API接口
|
||||
* @filename resourceCategory.ts
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-15
|
||||
*
|
||||
* ⚠️ 注意:此API已废弃!
|
||||
*
|
||||
* 从2025-10-27起,资源分类功能已迁移到标签系统(Tag)中。
|
||||
*
|
||||
* 迁移说明:
|
||||
* - 原 tb_resource_category 表已废弃
|
||||
* - 改为使用 tb_tag 表的 tag_type=1 表示文章分类标签
|
||||
* - 请使用 resourceTagApi.getTagsByType(1) 替代本 API 的方法
|
||||
*
|
||||
* API 迁移对照:
|
||||
* - getCategoryList() → resourceTagApi.getTagsByType(1)
|
||||
* - getCategoryById(id) → resourceTagApi.getTagById(id)
|
||||
* - createCategory(category) → resourceTagApi.createTag({...category, tagType: 1})
|
||||
* - updateCategory(category) → resourceTagApi.updateTag(category)
|
||||
* - deleteCategory(id) → resourceTagApi.deleteTag(id)
|
||||
*
|
||||
* @deprecated 请使用 resourceTagApi 代替
|
||||
*/
|
||||
|
||||
import { api } from '@/apis';
|
||||
import type { ResultDomain, ResourceCategory } from '@/types';
|
||||
|
||||
/**
|
||||
* 资源分类API服务
|
||||
* @deprecated 已废弃,请使用 resourceTagApi.getTagsByType(1) 获取文章分类标签
|
||||
*/
|
||||
export const resourceCategoryApi = {
|
||||
/**
|
||||
* 获取分类列表
|
||||
* @returns Promise<ResultDomain<ResourceCategory>>
|
||||
*/
|
||||
async getCategoryList(): Promise<ResultDomain<ResourceCategory>> {
|
||||
const response = await api.get<ResourceCategory>('/news/categorys/list');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 根据ID获取分类详情
|
||||
* @param tagID 分类ID
|
||||
* @returns Promise<ResultDomain<ResourceCategory>>
|
||||
*/
|
||||
async getCategoryById(tagID: string): Promise<ResultDomain<ResourceCategory>> {
|
||||
const response = await api.get<ResourceCategory>(`/news/categorys/category/${tagID}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 创建分类
|
||||
* @param category 分类信息
|
||||
* @returns Promise<ResultDomain<ResourceCategory>>
|
||||
*/
|
||||
async createCategory(category: ResourceCategory): Promise<ResultDomain<ResourceCategory>> {
|
||||
const response = await api.post<ResourceCategory>('/news/categorys/category', category);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新分类
|
||||
* @param category 分类信息
|
||||
* @returns Promise<ResultDomain<ResourceCategory>>
|
||||
*/
|
||||
async updateCategory(category: ResourceCategory): Promise<ResultDomain<ResourceCategory>> {
|
||||
const response = await api.put<ResourceCategory>('/news/categorys/category', category);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除分类
|
||||
* @param tagID 分类ID
|
||||
* @returns Promise<ResultDomain<boolean>>
|
||||
*/
|
||||
async deleteCategory(tagID: string): Promise<ResultDomain<boolean>> {
|
||||
const response = await api.delete<boolean>(`/news/categorys/category/${tagID}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新分类状态
|
||||
* @param tagID 分类ID
|
||||
* @param status 状态值
|
||||
* @returns Promise<ResultDomain<ResourceCategory>>
|
||||
*/
|
||||
async updateCategoryStatus(tagID: string, status: number): Promise<ResultDomain<ResourceCategory>> {
|
||||
const response = await api.put<ResourceCategory>(`/news/categorys/category/${tagID}/status`, null, {
|
||||
params: { status }
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取分类树
|
||||
* @returns Promise<ResultDomain<ResourceCategory>>
|
||||
*/
|
||||
async getCategoryTree(): Promise<ResultDomain<ResourceCategory>> {
|
||||
const response = await api.get<ResourceCategory>('/news/categorys/tree');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取子分类
|
||||
* @param parentID 父分类ID
|
||||
* @returns Promise<ResultDomain<ResourceCategory>>
|
||||
*/
|
||||
async getChildCategories(parentID: string): Promise<ResultDomain<ResourceCategory>> {
|
||||
const response = await api.get<ResourceCategory>(`/news/categorys/category/${parentID}/children`);
|
||||
return response.data;
|
||||
}
|
||||
};
|
||||
|
||||
export default resourceCategoryApi;
|
||||
Reference in New Issue
Block a user