package com.sundot.airport.web.controller.personnel;

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.sundot.airport.common.annotation.Log;
import com.sundot.airport.common.core.controller.BaseController;
import com.sundot.airport.common.core.domain.AjaxResult;
import com.sundot.airport.common.enums.BusinessType;
import com.sundot.airport.personnel.domain.PersonnelMonthlyAssessmentIndicatorDetail;
import com.sundot.airport.personnel.service.IPersonnelMonthlyAssessmentIndicatorDetailService;
import com.sundot.airport.common.utils.poi.ExcelUtil;
import com.sundot.airport.common.core.page.TableDataInfo;

/**
 * 月度考核指标明细Controller
 *
 * @author ruoyi
 * @date 2026-05-07
 */
@RestController
@RequestMapping("/personnel/indicatorDetail")
public class PersonnelMonthlyAssessmentIndicatorDetailController extends BaseController {
    @Autowired
    private IPersonnelMonthlyAssessmentIndicatorDetailService personnelMonthlyAssessmentIndicatorDetailService;

    /**
     * 查询月度考核指标明细列表
     */
    @PreAuthorize("@ss.hasPermi('personnel:indicatorDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(PersonnelMonthlyAssessmentIndicatorDetail personnelMonthlyAssessmentIndicatorDetail) {
        startPage();
        List<PersonnelMonthlyAssessmentIndicatorDetail> list = personnelMonthlyAssessmentIndicatorDetailService.selectPersonnelMonthlyAssessmentIndicatorDetailList(personnelMonthlyAssessmentIndicatorDetail);
        return getDataTable(list);
    }

    /**
     * 导出月度考核指标明细列表
     */
    @PreAuthorize("@ss.hasPermi('personnel:indicatorDetail:export')")
    @Log(title = "月度考核指标明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PersonnelMonthlyAssessmentIndicatorDetail personnelMonthlyAssessmentIndicatorDetail) {
        List<PersonnelMonthlyAssessmentIndicatorDetail> list = personnelMonthlyAssessmentIndicatorDetailService.selectPersonnelMonthlyAssessmentIndicatorDetailList(personnelMonthlyAssessmentIndicatorDetail);
        ExcelUtil<PersonnelMonthlyAssessmentIndicatorDetail> util = new ExcelUtil<PersonnelMonthlyAssessmentIndicatorDetail>(PersonnelMonthlyAssessmentIndicatorDetail.class);
        util.exportExcel(response, list, "月度考核指标明细数据");
    }

    /**
     * 获取月度考核指标明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('personnel:indicatorDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(personnelMonthlyAssessmentIndicatorDetailService.selectPersonnelMonthlyAssessmentIndicatorDetailById(id));
    }

    /**
     * 新增月度考核指标明细
     */
    @PreAuthorize("@ss.hasPermi('personnel:indicatorDetail:add')")
    @Log(title = "月度考核指标明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PersonnelMonthlyAssessmentIndicatorDetail personnelMonthlyAssessmentIndicatorDetail) {
        personnelMonthlyAssessmentIndicatorDetail.setCreateBy(getUsername());
        return toAjax(personnelMonthlyAssessmentIndicatorDetailService.insertPersonnelMonthlyAssessmentIndicatorDetail(personnelMonthlyAssessmentIndicatorDetail));
    }

    /**
     * 修改月度考核指标明细
     */
    @PreAuthorize("@ss.hasPermi('personnel:indicatorDetail:edit')")
    @Log(title = "月度考核指标明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PersonnelMonthlyAssessmentIndicatorDetail personnelMonthlyAssessmentIndicatorDetail) {
        personnelMonthlyAssessmentIndicatorDetail.setUpdateBy(getUsername());
        return toAjax(personnelMonthlyAssessmentIndicatorDetailService.updatePersonnelMonthlyAssessmentIndicatorDetail(personnelMonthlyAssessmentIndicatorDetail));
    }

    /**
     * 删除月度考核指标明细
     */
    @PreAuthorize("@ss.hasPermi('personnel:indicatorDetail:remove')")
    @Log(title = "月度考核指标明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(personnelMonthlyAssessmentIndicatorDetailService.deletePersonnelMonthlyAssessmentIndicatorDetailByIds(ids));
    }
}
