dict.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. import { http } from "@/utils/http";
  2. import { baseUrlApi } from "../utils";
  3. export interface DictList<T = any> {
  4. code: number;
  5. msg: string;
  6. rows: T;
  7. total?: number;
  8. }
  9. export interface BasicResponseModel<T = any> {
  10. code: number;
  11. msg: string;
  12. data: T;
  13. }
  14. /**
  15. * 获取字典类型列表
  16. * @param query
  17. */
  18. export const getSystemDictList = (query?: object) => {
  19. return http.request<DictList>("get", baseUrlApi("system/dict/type/list"), {
  20. params: query
  21. });
  22. };
  23. /**
  24. * 添加字典类型
  25. * @param data
  26. */
  27. export const addSystemDictType = (data: object) => {
  28. return http.request<BasicResponseModel>(
  29. "post",
  30. baseUrlApi("system/dict/type"),
  31. { data }
  32. );
  33. };
  34. /**
  35. * 修改字典类型
  36. * @param data
  37. */
  38. export const updateSystemDictType = (data: object) => {
  39. return http.request<BasicResponseModel>(
  40. "put",
  41. baseUrlApi("system/dict/type"),
  42. { data }
  43. );
  44. };
  45. /**
  46. * 删除字典类型
  47. * @param id
  48. */
  49. export const deleteSystemDictType = (id: string) => {
  50. return http.request<BasicResponseModel>(
  51. "delete",
  52. baseUrlApi(`system/dict/type/${id}`)
  53. );
  54. };
  55. /**
  56. * 根据ID获取字典类型详细信息
  57. * @param id
  58. */
  59. export const getSystemDictById = (id: string) => {
  60. return http.request<BasicResponseModel>(
  61. "get",
  62. baseUrlApi(`system/dict/type/${id}`)
  63. );
  64. };
  65. /**
  66. * 获取字典名称下拉框
  67. */
  68. export const getDictTypeOptionSelect = () => {
  69. return http.request<BasicResponseModel>(
  70. "get",
  71. baseUrlApi("system/dict/type/optionselect")
  72. );
  73. };
  74. /**
  75. * 获取字典数据列表
  76. * @param query
  77. */
  78. export const getSystemDictDataList = (query?: object) => {
  79. return http.request<DictList>("get", baseUrlApi("system/dict/data/list"), {
  80. params: query
  81. });
  82. };
  83. /**
  84. * 添加字典数据
  85. * @param data
  86. */
  87. export const addSystemDictData = (data: object) => {
  88. return http.request<BasicResponseModel>(
  89. "post",
  90. baseUrlApi("system/dict/data"),
  91. { data }
  92. );
  93. };
  94. /**
  95. * 修改字典数据
  96. * @param data
  97. */
  98. export const updateSystemDictData = (data: object) => {
  99. return http.request<BasicResponseModel>(
  100. "put",
  101. baseUrlApi("system/dict/data"),
  102. { data }
  103. );
  104. };
  105. /**
  106. * 删除字典数据
  107. * @param id
  108. */
  109. export const deleteSystemDictData = (id: string) => {
  110. return http.request<BasicResponseModel>(
  111. "delete",
  112. baseUrlApi(`system/dict/data/${id}`)
  113. );
  114. };
  115. /**
  116. * 根据ID获取字典数据详细信息
  117. * @param id
  118. */
  119. export const getSystemDictDataById = (id: string) => {
  120. return http.request<BasicResponseModel>(
  121. "get",
  122. baseUrlApi(`system/dict/data/${id}`)
  123. );
  124. };
  125. /**
  126. * 获取字典数据根据字典类型
  127. * @param dictType
  128. */
  129. export const getDictDataByType = (dictType: string) => {
  130. return http.request<BasicResponseModel>(
  131. "get",
  132. baseUrlApi(`system/dict/data/type/${dictType}`)
  133. );
  134. };
  135. /**
  136. * 刷新字典缓存
  137. */
  138. export const refreshDictCache = () => {
  139. return http.request<BasicResponseModel>(
  140. "delete",
  141. baseUrlApi("system/dict/type/refreshCache")
  142. );
  143. };