news.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { defHttp } from '/@/utils/http/axios';
  2. import {
  3. GetNewsListModel,
  4. DeleteBatchesParams,
  5. NewsIdParams,
  6. AddNewsParams,
  7. EditNewsParams,
  8. GetNewsModel,
  9. } from './model/newsModel';
  10. enum Api {
  11. NewsUrl = '/news/',
  12. }
  13. /**
  14. * @description: GetNewsList
  15. */
  16. export function getNewsList(params) {
  17. return defHttp.request<GetNewsListModel>({
  18. url: Api.NewsUrl,
  19. method: 'GET',
  20. params,
  21. });
  22. }
  23. /**
  24. * @description: addNews
  25. */
  26. export function addNews(params: AddNewsParams) {
  27. return defHttp.request<GetNewsListModel>({
  28. url: Api.NewsUrl,
  29. method: 'POST',
  30. params,
  31. });
  32. }
  33. /**
  34. * @description: 批量删除新闻
  35. */
  36. export function deleteBatchesNews(params: DeleteBatchesParams) {
  37. return defHttp.request<GetNewsListModel>({
  38. url: Api.NewsUrl,
  39. method: 'DELETE',
  40. params,
  41. });
  42. }
  43. /**
  44. * @description: 获取单个新闻
  45. */
  46. export function getNews(params: NewsIdParams) {
  47. return defHttp.request<GetNewsModel>({
  48. url: Api.NewsUrl + params.id,
  49. method: 'GET',
  50. });
  51. }
  52. /**
  53. * @description: 修改单个新闻
  54. */
  55. export function editNews(params: EditNewsParams) {
  56. return defHttp.request<GetNewsListModel>({
  57. url: Api.NewsUrl + params.id,
  58. method: 'PUT',
  59. params,
  60. });
  61. }
  62. /**
  63. * @description: 删除单个新闻
  64. */
  65. export function deleteNews(params: NewsIdParams) {
  66. return defHttp.request<GetNewsListModel>({
  67. url: Api.NewsUrl + params.id,
  68. method: 'DELETE',
  69. });
  70. }