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.PersonnelMonthlyAssessmentIndicatorRewardPunishmentDetail;
import com.sundot.airport.personnel.service.IPersonnelMonthlyAssessmentIndicatorRewardPunishmentDetailService;
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/rewardPunishmentDetail")
public class PersonnelMonthlyAssessmentIndicatorRewardPunishmentDetailController extends BaseController {
    @Autowired
    private IPersonnelMonthlyAssessmentIndicatorRewardPunishmentDetailService personnelMonthlyAssessmentIndicatorRewardPunishmentDetailService;

    /**
     * 查询月度考核指标奖罚明细列表
     */
    @PreAuthorize("@ss.hasPermi('personnel:rewardPunishmentDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(PersonnelMonthlyAssessmentIndicatorRewardPunishmentDetail personnelMonthlyAssessmentIndicatorRewardPunishmentDetail) {
        startPage();
        List<PersonnelMonthlyAssessmentIndicatorRewardPunishmentDetail> list = personnelMonthlyAssessmentIndicatorRewardPunishmentDetailService.selectPersonnelMonthlyAssessmentIndicatorRewardPunishmentDetailList(personnelMonthlyAssessmentIndicatorRewardPunishmentDetail);
        return getDataTable(list);
    }

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

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

    /**
     * 新增月度考核指标奖罚明细
     */
    @PreAuthorize("@ss.hasPermi('personnel:rewardPunishmentDetail:add')")
    @Log(title = "月度考核指标奖罚明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PersonnelMonthlyAssessmentIndicatorRewardPunishmentDetail personnelMonthlyAssessmentIndicatorRewardPunishmentDetail) {
        personnelMonthlyAssessmentIndicatorRewardPunishmentDetail.setCreateBy(getUsername());
        return toAjax(personnelMonthlyAssessmentIndicatorRewardPunishmentDetailService.insertPersonnelMonthlyAssessmentIndicatorRewardPunishmentDetail(personnelMonthlyAssessmentIndicatorRewardPunishmentDetail));
    }

    /**
     * 修改月度考核指标奖罚明细
     */
    @PreAuthorize("@ss.hasPermi('personnel:rewardPunishmentDetail:edit')")
    @Log(title = "月度考核指标奖罚明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PersonnelMonthlyAssessmentIndicatorRewardPunishmentDetail personnelMonthlyAssessmentIndicatorRewardPunishmentDetail) {
        personnelMonthlyAssessmentIndicatorRewardPunishmentDetail.setUpdateBy(getUsername());
        return toAjax(personnelMonthlyAssessmentIndicatorRewardPunishmentDetailService.updatePersonnelMonthlyAssessmentIndicatorRewardPunishmentDetail(personnelMonthlyAssessmentIndicatorRewardPunishmentDetail));
    }

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