tag.ts 995 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { del, get, patch, post } from './base'
  2. import type { Tag } from '@/app/components/base/tag-management/constant'
  3. export const fetchTagList = (type: string) => {
  4. return get<Tag[]>('/tags', { params: { type } })
  5. }
  6. export const createTag = (name: string, type: string) => {
  7. return post<Tag>('/tags', {
  8. body: {
  9. name,
  10. type,
  11. },
  12. })
  13. }
  14. export const updateTag = (tagID: string, name: string) => {
  15. return patch(`/tags/${tagID}`, {
  16. body: {
  17. name,
  18. },
  19. })
  20. }
  21. export const deleteTag = (tagID: string) => {
  22. return del(`/tags/${tagID}`)
  23. }
  24. export const bindTag = (tagIDList: string[], targetID: string, type: string) => {
  25. return post('/tag-bindings/create', {
  26. body: {
  27. tag_ids: tagIDList,
  28. target_id: targetID,
  29. type,
  30. },
  31. })
  32. }
  33. export const unBindTag = (tagID: string, targetID: string, type: string) => {
  34. return post('/tag-bindings/remove', {
  35. body: {
  36. tag_id: tagID,
  37. target_id: targetID,
  38. type,
  39. },
  40. })
  41. }