feat: 统一函数命名
This commit is contained in:
@@ -2,7 +2,7 @@ import { z } from 'zod'
|
||||
|
||||
import { HttpMethodSchema } from '@/enum'
|
||||
|
||||
export const SysApiSchema = z.object({
|
||||
export const ApiSchema = z.object({
|
||||
id: z.number().int(),
|
||||
name: z.string(),
|
||||
group_name: z.string(),
|
||||
@@ -11,17 +11,18 @@ export const SysApiSchema = z.object({
|
||||
sort: z.number(),
|
||||
})
|
||||
|
||||
export type SysApi = z.infer<typeof SysApiSchema>
|
||||
export type Api = z.infer<typeof ApiSchema>
|
||||
|
||||
// 搜索参数
|
||||
export const searchSysApiSchema = z.object({
|
||||
export const searchApiSchema = z.object({
|
||||
name: z.string().optional(),
|
||||
group_name: z.string().optional(),
|
||||
method: HttpMethodSchema.optional(),
|
||||
})
|
||||
|
||||
export type SearchSysApiParams = z.infer<typeof searchSysApiSchema>
|
||||
export type SearchApiParams = z.infer<typeof searchApiSchema>
|
||||
|
||||
export const SysApiFormSchema = z.object({
|
||||
export const apiFormSchema = z.object({
|
||||
id: z.number().optional(),
|
||||
name: z.string().min(2, '接口名称至少2个字符').max(16, '接口名称不能超过16个字符'),
|
||||
group_name: z.string().min(2, '分组名称至少2个字符').max(16, '分组名称不能超过16个字符'),
|
||||
@@ -30,4 +31,4 @@ export const SysApiFormSchema = z.object({
|
||||
sort: z.coerce.number<number>().int().min(0, '排序值不能小于0'),
|
||||
})
|
||||
|
||||
export type SysApiForm = z.infer<typeof SysApiFormSchema>
|
||||
export type ApiForm = z.infer<typeof apiFormSchema>
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const sysFileSchema = z.object({
|
||||
export const fileSchema = z.object({
|
||||
id: z.number().int(),
|
||||
file_name: z.string(),
|
||||
file_path: z.string(),
|
||||
file_url: z.string(),
|
||||
original_name: z.string(),
|
||||
folder_name: z.string(),
|
||||
mime_type: z.string(),
|
||||
@@ -12,11 +13,11 @@ export const sysFileSchema = z.object({
|
||||
updated_at: z.string(),
|
||||
})
|
||||
|
||||
export type SysFile = z.infer<typeof sysFileSchema>
|
||||
export type File = z.infer<typeof fileSchema>
|
||||
|
||||
export const sysFileFormSchema = z.object({
|
||||
export const fileFormSchema = z.object({
|
||||
id: z.number().int(),
|
||||
file_path: z.string(),
|
||||
file_url: z.string(),
|
||||
})
|
||||
|
||||
export type SysFileForm = z.infer<typeof sysFileFormSchema>
|
||||
export type FileForm = z.infer<typeof fileFormSchema>
|
||||
|
||||
@@ -9,7 +9,7 @@ const MenuIconKeySchema = z.custom<MenuIconKeyValues>(
|
||||
},
|
||||
)
|
||||
|
||||
export const sysMenuSchema = z.object({
|
||||
export const menuSchema = z.object({
|
||||
id: z.number().int(),
|
||||
name: z.string(),
|
||||
path: z.string(),
|
||||
@@ -25,13 +25,13 @@ export const sysMenuSchema = z.object({
|
||||
updated_at: z.string(),
|
||||
})
|
||||
|
||||
export type SysMenu = z.infer<typeof sysMenuSchema>
|
||||
export type Menu = z.infer<typeof menuSchema>
|
||||
|
||||
export interface SysMenuTree extends SysMenu {
|
||||
children?: SysMenuTree[]
|
||||
export interface MenuTree extends Menu {
|
||||
children?: MenuTree[]
|
||||
}
|
||||
|
||||
export const sysMenuFormSchema = z
|
||||
export const menuFormSchema = z
|
||||
.object({
|
||||
id: z.number().optional(),
|
||||
name: z.string().min(1, '菜单名称不能为空').max(16, '菜单名称不能超过16个字符'),
|
||||
@@ -63,4 +63,4 @@ export const sysMenuFormSchema = z
|
||||
return data
|
||||
})
|
||||
|
||||
export type SysMenuForm = z.infer<typeof sysMenuFormSchema>
|
||||
export type MenuForm = z.infer<typeof menuFormSchema>
|
||||
|
||||
@@ -2,7 +2,7 @@ import { z } from 'zod'
|
||||
|
||||
import { StatusSchema } from '@/enum'
|
||||
|
||||
export const sysRoleSchema = z.object({
|
||||
export const roleSchema = z.object({
|
||||
id: z.number().int(),
|
||||
name: z.string(),
|
||||
code: z.string(),
|
||||
@@ -11,9 +11,9 @@ export const sysRoleSchema = z.object({
|
||||
updated_at: z.string(),
|
||||
})
|
||||
|
||||
export type SysRole = z.infer<typeof sysRoleSchema>
|
||||
export type Role = z.infer<typeof roleSchema>
|
||||
|
||||
export const sysRoleFormSchema = z
|
||||
export const roleFormSchema = z
|
||||
.object({
|
||||
id: z.number().optional(),
|
||||
name: z.string().min(2, '角色名称至少2个字符').max(16, '角色名称不能超过16个字符'),
|
||||
@@ -33,4 +33,4 @@ export const sysRoleFormSchema = z
|
||||
}
|
||||
})
|
||||
|
||||
export type SysRoleForm = z.infer<typeof sysRoleFormSchema>
|
||||
export type RoleForm = z.infer<typeof roleFormSchema>
|
||||
|
||||
@@ -2,10 +2,10 @@ import { z } from 'zod'
|
||||
|
||||
import { StatusSchema } from '@/enum'
|
||||
|
||||
import { sysFileFormSchema } from './file'
|
||||
import { sysMenuSchema } from './menu'
|
||||
import { fileFormSchema } from './file'
|
||||
import { menuSchema } from './menu'
|
||||
|
||||
export const sysUserSchema = z.object({
|
||||
export const userSchema = z.object({
|
||||
id: z.number().int(),
|
||||
account: z.string(),
|
||||
username: z.string(),
|
||||
@@ -16,15 +16,15 @@ export const sysUserSchema = z.object({
|
||||
avatar_id: z.number().int().optional(),
|
||||
})
|
||||
|
||||
export type SysUser = z.infer<typeof sysUserSchema>
|
||||
export type User = z.infer<typeof userSchema>
|
||||
|
||||
// 搜索参数
|
||||
export const searchSysUserSchema = z.object({
|
||||
export const searchUserSchema = z.object({
|
||||
username: z.string().optional(),
|
||||
})
|
||||
export type SearchSysUserParams = z.infer<typeof searchSysUserSchema>
|
||||
export type SearchUserParams = z.infer<typeof searchUserSchema>
|
||||
|
||||
export const sysUserInfoSchema = sysUserSchema
|
||||
export const userInfoSchema = userSchema
|
||||
.pick({
|
||||
id: true,
|
||||
account: true,
|
||||
@@ -34,11 +34,11 @@ export const sysUserInfoSchema = sysUserSchema
|
||||
})
|
||||
.extend({
|
||||
roles: z.array(z.string()),
|
||||
menus: z.array(sysMenuSchema),
|
||||
menus: z.array(menuSchema),
|
||||
permissions: z.array(z.string()),
|
||||
})
|
||||
|
||||
export type SysUserInfo = z.infer<typeof sysUserInfoSchema>
|
||||
export type UserInfo = z.infer<typeof userInfoSchema>
|
||||
|
||||
const passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{5,16}$/
|
||||
|
||||
@@ -58,7 +58,7 @@ export const changePasswordFormSchema = z
|
||||
|
||||
export type ChangePasswordForm = z.infer<typeof changePasswordFormSchema>
|
||||
|
||||
export const sysUserFormSchema = z
|
||||
export const userFormSchema = z
|
||||
.object({
|
||||
id: z.number().optional(),
|
||||
account: z
|
||||
@@ -75,7 +75,7 @@ export const sysUserFormSchema = z
|
||||
message: '请选择状态',
|
||||
}),
|
||||
confirmPassword: z.string().optional(),
|
||||
avatar: z.array(sysFileFormSchema).optional(),
|
||||
avatar: z.array(fileFormSchema).optional(),
|
||||
})
|
||||
.superRefine((data, ctx) => {
|
||||
if (!data.id) {
|
||||
@@ -100,6 +100,6 @@ export const sysUserFormSchema = z
|
||||
}
|
||||
})
|
||||
|
||||
export type SysUserFormInput = z.input<typeof sysUserFormSchema>
|
||||
export type UserFormInput = z.input<typeof userFormSchema>
|
||||
|
||||
export type SysUserFormOutput = z.output<typeof sysUserFormSchema>
|
||||
export type UserFormOutput = z.output<typeof userFormSchema>
|
||||
|
||||
Reference in New Issue
Block a user