package com.cn.fdapfe.biz.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cn.fdapfe.common.annotation.Log;
import com.cn.fdapfe.common.core.controller.BaseController;
import com.cn.fdapfe.common.core.domain.AjaxResult;
import com.cn.fdapfe.common.enums.BusinessType;
import com.cn.fdapfe.biz.domain.EvaluationIndicator;
import com.cn.fdapfe.biz.service.IEvaluationIndicatorService;
import com.cn.fdapfe.common.utils.poi.ExcelUtil;
import com.cn.fdapfe.common.core.page.TableDataInfo;

/**
 * 评估指标体系管理Controller
 * 
 * @author Allen
 * @date 2025-03-07
 */
@RestController
@RequestMapping("/eval/indicator")
public class EvaluationIndicatorController extends BaseController
{
    @Autowired
    private IEvaluationIndicatorService evaluationIndicatorService;

    /**
     * 查询评估指标体系管理列表
     */
    @PreAuthorize("@ss.hasPermi('eval:indicator:list')")
    @GetMapping("/list")
    public TableDataInfo list(EvaluationIndicator evaluationIndicator)
    {
        startPage();
        List<EvaluationIndicator> list = evaluationIndicatorService.selectEvaluationIndicatorList(evaluationIndicator);
        return getDataTable(list);
    }

    /**
     * 导出评估指标体系管理列表
     */
    @PreAuthorize("@ss.hasPermi('eval:indicator:export')")
    @Log(title = "评估指标体系管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EvaluationIndicator evaluationIndicator)
    {
        List<EvaluationIndicator> list = evaluationIndicatorService.selectEvaluationIndicatorList(evaluationIndicator);
        ExcelUtil<EvaluationIndicator> util = new ExcelUtil<EvaluationIndicator>(EvaluationIndicator.class);
        util.exportExcel(response, list, "评估指标体系管理数据");
    }

    /**
     * 获取评估指标体系管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('eval:indicator:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(evaluationIndicatorService.selectEvaluationIndicatorById(id));
    }

    /**
     * 新增评估指标体系管理
     */
    @PreAuthorize("@ss.hasPermi('eval:indicator:add')")
    @Log(title = "评估指标体系管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EvaluationIndicator evaluationIndicator)
    {
        return toAjax(evaluationIndicatorService.insertEvaluationIndicator(evaluationIndicator));
    }

    /**
     * 修改评估指标体系管理
     */
    @PreAuthorize("@ss.hasPermi('eval:indicator:edit')")
    @Log(title = "评估指标体系管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EvaluationIndicator evaluationIndicator)
    {
        return toAjax(evaluationIndicatorService.updateEvaluationIndicator(evaluationIndicator));
    }

    /**
     * 删除评估指标体系管理
     */
    @PreAuthorize("@ss.hasPermi('eval:indicator:remove')")
    @Log(title = "评估指标体系管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(evaluationIndicatorService.deleteEvaluationIndicatorByIds(ids));
    }
}
