import { Router } from 'express';
import { AISelfImprovementController } from '../controllers/AISelfImprovementController';
import { Container } from 'typedi';

const router = Router();
const aiSelfImprovementController = Container.get(AISelfImprovementController);

// 生成改进建议
router.get('/suggestions/generate', (req, res, next) => {
  aiSelfImprovementController.generateSuggestions()
    .then(result => res.json(result))
    .catch(next);
});

// 获取所有改进建议
router.get('/suggestions', (req, res, next) => {
  aiSelfImprovementController.getSuggestions()
    .then(result => res.json(result))
    .catch(next);
});

// 更新建议状态
router.put('/suggestions/:id/status', (req, res, next) => {
  aiSelfImprovementController.updateSuggestionStatus(req.params.id, req.params.status)
    .then(result => res.json(result))
    .catch(next);
});

// 自动应用改进建议
router.get('/suggestions/apply', (req, res, next) => {
  aiSelfImprovementController.applySuggestions()
    .then(result => res.json(result))
    .catch(next);
});

// 执行定期优化
router.get('/optimize', (req, res, next) => {
  aiSelfImprovementController.performOptimization()
    .then(result => res.json(result))
    .catch(next);
});

export default router;
