44 lines
2.2 KiB
JavaScript
44 lines
2.2 KiB
JavaScript
const express = require('express');
|
|
const router = express.Router();
|
|
const { body } = require('express-validator');
|
|
const harmlessRegistrationController = require('../controllers/HarmlessRegistrationController');
|
|
const authMiddleware = require('../middleware/auth');
|
|
|
|
// 应用身份验证中间件
|
|
router.use(authMiddleware);
|
|
|
|
// 获取无害化登记列表
|
|
router.get('/list', harmlessRegistrationController.getList);
|
|
|
|
// 获取无害化登记详情
|
|
router.get('/detail/:id', harmlessRegistrationController.getDetail);
|
|
|
|
// 创建无害化登记
|
|
router.post('/create', [
|
|
body('registrationNumber').notEmpty().withMessage('登记编号不能为空'),
|
|
body('animalType').notEmpty().withMessage('动物类型不能为空'),
|
|
body('quantity').isInt({ min: 1 }).withMessage('数量必须大于0'),
|
|
body('reason').notEmpty().withMessage('原因不能为空'),
|
|
body('processingMethod').notEmpty().withMessage('处理方式不能为空'),
|
|
body('processingPlace').notEmpty().withMessage('处理场所不能为空'),
|
|
body('processingDate').notEmpty().withMessage('处理日期不能为空'),
|
|
body('registrant').notEmpty().withMessage('登记人不能为空')
|
|
], harmlessRegistrationController.create);
|
|
|
|
// 更新无害化登记
|
|
router.put('/update/:id', [
|
|
body('registrationNumber').optional().notEmpty().withMessage('登记编号不能为空'),
|
|
body('animalType').optional().notEmpty().withMessage('动物类型不能为空'),
|
|
body('quantity').optional().isInt({ min: 1 }).withMessage('数量必须大于0'),
|
|
body('reason').optional().notEmpty().withMessage('原因不能为空'),
|
|
body('processingMethod').optional().notEmpty().withMessage('处理方式不能为空'),
|
|
body('processingPlace').optional().notEmpty().withMessage('处理场所不能为空'),
|
|
body('processingDate').optional().notEmpty().withMessage('处理日期不能为空'),
|
|
body('registrant').optional().notEmpty().withMessage('登记人不能为空'),
|
|
body('status').optional().isIn(['待处理', '处理中', '已完成', '已取消']).withMessage('状态必须是待处理、处理中、已完成或已取消')
|
|
], harmlessRegistrationController.update);
|
|
|
|
// 删除无害化登记
|
|
router.delete('/delete/:id', harmlessRegistrationController.delete);
|
|
|
|
module.exports = router; |