|
@@ -2,7 +2,7 @@ import { FastifyInstance } from 'fastify'
|
|
|
import { FishController } from '../controllers/fish.controller'
|
|
import { FishController } from '../controllers/fish.controller'
|
|
|
import { authenticate, hasRole } from '../middlewares/auth.middleware'
|
|
import { authenticate, hasRole } from '../middlewares/auth.middleware'
|
|
|
import { UserRole } from '../entities/user.entity'
|
|
import { UserRole } from '../entities/user.entity'
|
|
|
-import { ListFishQuery, CreateFishBody, UpdateFishBody, DeleteFishBody, StatisticsQuery } from '../dto/fish.dto'
|
|
|
|
|
|
|
+import { ListFishQuery, CreateFishBody, UpdateFishBody, DeleteFishBody, StatisticsQuery, BatchUpdateFishBody } from '../dto/fish.dto'
|
|
|
|
|
|
|
|
export default async function fishRoutes(fastify: FastifyInstance) {
|
|
export default async function fishRoutes(fastify: FastifyInstance) {
|
|
|
const fishController = new FishController(fastify)
|
|
const fishController = new FishController(fastify)
|
|
@@ -34,17 +34,24 @@ export default async function fishRoutes(fastify: FastifyInstance) {
|
|
|
fishController.update.bind(fishController)
|
|
fishController.update.bind(fishController)
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+ // 批量更新所有者id
|
|
|
|
|
+ fastify.post<{ Body: BatchUpdateFishBody }>(
|
|
|
|
|
+ '/batchUpdateOwner',
|
|
|
|
|
+ { onRequest: [hasRole(UserRole.ADMIN)] },
|
|
|
|
|
+ fishController.batchUpdateOwner.bind(fishController)
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
// 删除记录
|
|
// 删除记录
|
|
|
fastify.post<{ Body: DeleteFishBody }>(
|
|
fastify.post<{ Body: DeleteFishBody }>(
|
|
|
'/delete',
|
|
'/delete',
|
|
|
- { onRequest: [authenticate] },
|
|
|
|
|
|
|
+ { onRequest: [hasRole(UserRole.ADMIN)] },
|
|
|
fishController.delete.bind(fishController)
|
|
fishController.delete.bind(fishController)
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
// 批量删除记录
|
|
// 批量删除记录
|
|
|
fastify.post<{ Body: { ids: string[] } }>(
|
|
fastify.post<{ Body: { ids: string[] } }>(
|
|
|
'/batch-delete',
|
|
'/batch-delete',
|
|
|
- { onRequest: [authenticate] },
|
|
|
|
|
|
|
+ { onRequest: [hasRole(UserRole.ADMIN)] },
|
|
|
fishController.batchDelete.bind(fishController)
|
|
fishController.batchDelete.bind(fishController)
|
|
|
)
|
|
)
|
|
|
|
|
|