const express = require('express');
const router = express.Router();
const {
  getLivestockTypes,
  getActiveLivestockTypes,
  createLivestockType,
  getLivestockTypeById,
  updateLivestockType,
  deleteLivestockType,
  batchUpdateLivestockTypeStatus
} = require('../controllers/livestockTypeController');
const { jwtAuth, checkPermission } = require('../middleware/auth');

// 获取牲畜类型列表
router.get('/', jwtAuth, checkPermission('insurance_type', 'read'), getLivestockTypes);

// 获取所有启用的牲畜类型（用于下拉选择）
router.get('/active', getActiveLivestockTypes);

// 获取单个牲畜类型详情
router.get('/:id', jwtAuth, checkPermission('insurance_type', 'read'), getLivestockTypeById);

// 创建牲畜类型
router.post('/', jwtAuth, checkPermission('insurance_type', 'create'), createLivestockType);

// 更新牲畜类型
router.put('/:id', jwtAuth, checkPermission('insurance_type', 'edit'), updateLivestockType);

// 删除牲畜类型
router.delete('/:id', jwtAuth, checkPermission('insurance_type', 'delete'), deleteLivestockType);

// 批量更新牲畜类型状态
router.patch('/batch/status', jwtAuth, checkPermission('insurance_type', 'edit'), batchUpdateLivestockTypeStatus);

module.exports = router;