feat(dict): 新增字典管理API接口和类型定义
- 添加字典类型和字典数据的API接口 - 定义完整的字典相关类型定义 - 包含CRUD操作和分页查询功能 - 支持字典类型选项和数据选项查询
This commit is contained in:
parent
c733dc5ffe
commit
bf94dd07be
183
src/service/api/system/dict/index.ts
Normal file
183
src/service/api/system/dict/index.ts
Normal file
@ -0,0 +1,183 @@
|
||||
/**
|
||||
* 字典管理 API 接口
|
||||
*/
|
||||
|
||||
import { request } from '@/service/http'
|
||||
import type {
|
||||
DictDataForm,
|
||||
DictDataOption,
|
||||
DictDataQueryBo,
|
||||
DictDataVo,
|
||||
DictTypeForm,
|
||||
DictTypeOption,
|
||||
DictTypeQueryBo,
|
||||
DictTypeVo,
|
||||
PageDictDataVo,
|
||||
PageDictTypeVo,
|
||||
} from './types'
|
||||
|
||||
// 重新导出类型供外部使用
|
||||
export type {
|
||||
DictDataForm,
|
||||
DictDataOption,
|
||||
DictDataQueryBo,
|
||||
DictDataSearchForm,
|
||||
DictDataVo,
|
||||
DictTypeForm,
|
||||
DictTypeOption,
|
||||
DictTypeQueryBo,
|
||||
DictTypeSearchForm,
|
||||
DictTypeVo,
|
||||
PageDictDataVo,
|
||||
PageDictTypeVo,
|
||||
} from './types'
|
||||
|
||||
export { DictStatus, DictTag } from './types'
|
||||
|
||||
/** ======================= 字典类型管理 API ======================= */
|
||||
|
||||
/**
|
||||
* 分页查询字典类型列表
|
||||
*/
|
||||
export function getDictTypeList(params: DictTypeQueryBo) {
|
||||
return request.Get<Service.ResponseResult<PageDictTypeVo>>('/coder/sysDictType/listPage', {
|
||||
params,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有字典类型
|
||||
*/
|
||||
export function getAllDictTypes() {
|
||||
return request.Get<Service.ResponseResult<DictTypeVo[]>>('/coder/sysDictType/list')
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询字典类型详情
|
||||
*/
|
||||
export function getDictTypeById(id: string) {
|
||||
return request.Get<Service.ResponseResult<DictTypeVo>>(`/coder/sysDictType/getById/${id}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增字典类型
|
||||
*/
|
||||
export function addDictType(data: DictTypeForm) {
|
||||
return request.Post<Service.ResponseResult<string>>('/coder/sysDictType/add', data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典类型
|
||||
*/
|
||||
export function updateDictType(data: DictTypeForm) {
|
||||
return request.Post<Service.ResponseResult<string>>('/coder/sysDictType/update', data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典类型
|
||||
*/
|
||||
export function deleteDictType(id: string) {
|
||||
return request.Post<Service.ResponseResult<string>>(`/coder/sysDictType/deleteById/${id}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除字典类型
|
||||
*/
|
||||
export function batchDeleteDictType(ids: string[]) {
|
||||
return request.Post<Service.ResponseResult<string>>('/coder/sysDictType/batchDelete', ids)
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典类型状态
|
||||
*/
|
||||
export function updateDictTypeStatus(dictId: string, dictStatus: string) {
|
||||
return request.Post<Service.ResponseResult<string>>(`/coder/sysDictType/updateStatus/${dictId}/${dictStatus}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询字典类型下拉框选项
|
||||
*/
|
||||
export function getDictTypeOptions() {
|
||||
return request.Get<Service.ResponseResult<DictTypeOption[]>>('/coder/sysDictType/listDictType')
|
||||
}
|
||||
|
||||
/** ======================= 字典数据管理 API ======================= */
|
||||
|
||||
/**
|
||||
* 分页查询字典数据列表
|
||||
*/
|
||||
export function getDictDataList(params: DictDataQueryBo) {
|
||||
return request.Get<Service.ResponseResult<PageDictDataVo>>('/coder/sysDictData/listPage', {
|
||||
params,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有字典数据
|
||||
*/
|
||||
export function getAllDictData() {
|
||||
return request.Get<Service.ResponseResult<DictDataVo[]>>('/coder/sysDictData/list')
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询字典数据详情
|
||||
*/
|
||||
export function getDictDataById(id: string) {
|
||||
return request.Get<Service.ResponseResult<DictDataVo>>(`/coder/sysDictData/getById/${id}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增字典数据
|
||||
*/
|
||||
export function addDictData(data: DictDataForm) {
|
||||
return request.Post<Service.ResponseResult<string>>('/coder/sysDictData/add', data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最新排序号
|
||||
*/
|
||||
export function getDictDataSorted(dictType: string) {
|
||||
return request.Get<Service.ResponseResult<number>>(`/coder/sysDictData/getSorted/${dictType}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典数据
|
||||
*/
|
||||
export function updateDictData(data: DictDataForm) {
|
||||
return request.Post<Service.ResponseResult<string>>('/coder/sysDictData/update', data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典数据
|
||||
*/
|
||||
export function deleteDictData(id: string) {
|
||||
return request.Post<Service.ResponseResult<string>>(`/coder/sysDictData/deleteById/${id}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除字典数据
|
||||
*/
|
||||
export function batchDeleteDictData(ids: string[]) {
|
||||
return request.Post<Service.ResponseResult<string>>('/coder/sysDictData/batchDelete', ids)
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典数据状态
|
||||
*/
|
||||
export function updateDictDataStatus(dictId: string, dictStatus: string) {
|
||||
return request.Post<Service.ResponseResult<string>>(`/coder/sysDictData/updateStatus/${dictId}/${dictStatus}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型查询字典数据
|
||||
*/
|
||||
export function getDictDataByType(dictType: string) {
|
||||
return request.Get<Service.ResponseResult<DictDataOption[]>>(`/coder/sysDictData/listDataByType/${dictType}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步字典缓存到Redis
|
||||
*/
|
||||
export function syncDictCache() {
|
||||
return request.Get<Service.ResponseResult<string>>('/coder/sysDictData/listDictCacheRedis')
|
||||
}
|
||||
145
src/service/api/system/dict/types.ts
Normal file
145
src/service/api/system/dict/types.ts
Normal file
@ -0,0 +1,145 @@
|
||||
/**
|
||||
* 字典管理相关的类型定义
|
||||
*/
|
||||
|
||||
/** 字典类型相关类型定义 */
|
||||
|
||||
// 字典类型实体
|
||||
export interface DictTypeVo {
|
||||
dictId: string
|
||||
dictType: string
|
||||
dictName: string
|
||||
dictStatus: string
|
||||
createBy?: string
|
||||
createTime?: string
|
||||
updateBy?: string
|
||||
updateTime?: string
|
||||
remark?: string
|
||||
}
|
||||
|
||||
// 字典类型查询参数
|
||||
export interface DictTypeQueryBo {
|
||||
pageNo?: number
|
||||
pageSize?: number
|
||||
dictName?: string
|
||||
dictType?: string
|
||||
dictStatus?: string
|
||||
}
|
||||
|
||||
// 字典类型搜索表单
|
||||
export interface DictTypeSearchForm {
|
||||
dictName?: string
|
||||
dictType?: string
|
||||
dictStatus?: string
|
||||
}
|
||||
|
||||
// 字典类型表单
|
||||
export interface DictTypeForm {
|
||||
dictId?: string
|
||||
dictType: string
|
||||
dictName: string
|
||||
dictStatus: string
|
||||
remark?: string
|
||||
}
|
||||
|
||||
/** 字典数据相关类型定义 */
|
||||
|
||||
// 字典数据实体
|
||||
export interface DictDataVo {
|
||||
dictId: string
|
||||
dictLabel: string
|
||||
dictValue: string
|
||||
dictType: string
|
||||
dictStatus: string
|
||||
dictTag: string
|
||||
dictColor?: string
|
||||
sorted: number
|
||||
createBy?: string
|
||||
createTime?: string
|
||||
updateBy?: string
|
||||
updateTime?: string
|
||||
remark?: string
|
||||
}
|
||||
|
||||
// 字典数据查询参数
|
||||
export interface DictDataQueryBo {
|
||||
pageNo?: number
|
||||
pageSize?: number
|
||||
dictType?: string
|
||||
dictLabel?: string
|
||||
dictStatus?: string
|
||||
}
|
||||
|
||||
// 字典数据搜索表单
|
||||
export interface DictDataSearchForm {
|
||||
dictType?: string
|
||||
dictLabel?: string
|
||||
dictStatus?: string
|
||||
}
|
||||
|
||||
// 字典数据表单
|
||||
export interface DictDataForm {
|
||||
dictId?: string
|
||||
dictLabel: string
|
||||
dictValue: string
|
||||
dictType: string
|
||||
dictStatus: string
|
||||
dictTag: string
|
||||
dictColor?: string
|
||||
sorted: number
|
||||
remark?: string
|
||||
}
|
||||
|
||||
/** 分页结果类型 */
|
||||
|
||||
// 字典类型分页结果
|
||||
export interface PageDictTypeVo {
|
||||
records: DictTypeVo[]
|
||||
total: number
|
||||
size: number
|
||||
current: number
|
||||
pages: number
|
||||
}
|
||||
|
||||
// 字典数据分页结果
|
||||
export interface PageDictDataVo {
|
||||
records: DictDataVo[]
|
||||
total: number
|
||||
size: number
|
||||
current: number
|
||||
pages: number
|
||||
}
|
||||
|
||||
/** 选项类型 */
|
||||
|
||||
// 字典类型下拉选项
|
||||
export interface DictTypeOption {
|
||||
dictType: string
|
||||
dictName: string
|
||||
}
|
||||
|
||||
// 字典数据选项
|
||||
export interface DictDataOption {
|
||||
dictLabel: string
|
||||
dictValue: string
|
||||
dictType: string
|
||||
dictTag: string
|
||||
dictColor?: string
|
||||
}
|
||||
|
||||
/** 状态常量 */
|
||||
|
||||
// 字典状态枚举
|
||||
export const DictStatus = {
|
||||
NORMAL: '0', // 正常
|
||||
DISABLED: '1', // 停用
|
||||
} as const
|
||||
|
||||
// 字典标签类型枚举
|
||||
export const DictTag = {
|
||||
PRIMARY: 'primary',
|
||||
SUCCESS: 'success',
|
||||
INFO: 'info',
|
||||
WARNING: 'warning',
|
||||
ERROR: 'error',
|
||||
} as const
|
||||
Loading…
Reference in New Issue
Block a user