Files
nxxmdata/government-backend/routes/harmlessPlace.js

38 lines
1.6 KiB
JavaScript
Raw Normal View History

const express = require('express');
const router = express.Router();
const { body } = require('express-validator');
const harmlessPlaceController = require('../controllers/HarmlessPlaceController');
const authMiddleware = require('../middleware/auth');
// 应用身份验证中间件
router.use(authMiddleware);
// 获取无害化场所列表
router.get('/list', harmlessPlaceController.getList);
// 获取无害化场所详情
router.get('/detail/:id', harmlessPlaceController.getDetail);
// 创建无害化场所
router.post('/create', [
body('name').notEmpty().withMessage('场所名称不能为空'),
body('address').notEmpty().withMessage('地址不能为空'),
body('contactPerson').notEmpty().withMessage('联系人不能为空'),
body('contactPhone').notEmpty().withMessage('联系电话不能为空'),
body('licenseNumber').notEmpty().withMessage('许可证号不能为空')
], harmlessPlaceController.create);
// 更新无害化场所
router.put('/update/:id', [
body('name').optional().notEmpty().withMessage('场所名称不能为空'),
body('address').optional().notEmpty().withMessage('地址不能为空'),
body('contactPerson').optional().notEmpty().withMessage('联系人不能为空'),
body('contactPhone').optional().notEmpty().withMessage('联系电话不能为空'),
body('licenseNumber').optional().notEmpty().withMessage('许可证号不能为空'),
body('status').optional().isIn(['正常', '维护中', '停用']).withMessage('状态必须是正常、维护中或停用')
], harmlessPlaceController.update);
// 删除无害化场所
router.delete('/delete/:id', harmlessPlaceController.delete);
module.exports = router;