import { createCrudRoutes } from '@/server/utils/generic-crud.routes';
import { Role } from '@/server/modules/users/role.entity';
import { RoleSchema, CreateRoleDto, UpdateRoleDto } from '@/server/modules/users/role.entity';
import { authMiddleware } from '@/server/middleware/auth.middleware';
import { checkPermission, permissionMiddleware } from '@/server/middleware/permission.middleware';
import { OpenAPIHono } from '@hono/zod-openapi';

// 创建角色CRUD路由
const roleRoutes = createCrudRoutes({
  entity: Role,
  createSchema: CreateRoleDto,
  updateSchema: UpdateRoleDto,
  getSchema: RoleSchema,
  listSchema: RoleSchema,
  searchFields: ['name', 'description'],
  middleware: [
    authMiddleware, 
    // permissionMiddleware(checkPermission(['role:manage']))
]
})
const app = new OpenAPIHono()
  .route('/', roleRoutes)
// .route('/', customRoute)

export default app;