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.PersonnelNonCadreMonthlyAssessment;
import com.sundot.airport.personnel.service.IPersonnelNonCadreMonthlyAssessmentService;
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/assessment")
public class PersonnelNonCadreMonthlyAssessmentController extends BaseController {
    @Autowired
    private IPersonnelNonCadreMonthlyAssessmentService personnelNonCadreMonthlyAssessmentService;

    /**
     * 查询非干部月度考核列表
     */
    @PreAuthorize("@ss.hasPermi('personnel:assessment:list')")
    @GetMapping("/list")
    public TableDataInfo list(PersonnelNonCadreMonthlyAssessment personnelNonCadreMonthlyAssessment) {
        startPage();
        List<PersonnelNonCadreMonthlyAssessment> list = personnelNonCadreMonthlyAssessmentService.selectPersonnelNonCadreMonthlyAssessmentList(personnelNonCadreMonthlyAssessment);
        return getDataTable(list);
    }

    /**
     * 导出非干部月度考核列表
     */
    @PreAuthorize("@ss.hasPermi('personnel:assessment:export')")
    @Log(title = "非干部月度考核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PersonnelNonCadreMonthlyAssessment personnelNonCadreMonthlyAssessment) {
        List<PersonnelNonCadreMonthlyAssessment> list = personnelNonCadreMonthlyAssessmentService.selectPersonnelNonCadreMonthlyAssessmentList(personnelNonCadreMonthlyAssessment);
        ExcelUtil<PersonnelNonCadreMonthlyAssessment> util = new ExcelUtil<PersonnelNonCadreMonthlyAssessment>(PersonnelNonCadreMonthlyAssessment.class);
        util.exportExcel(response, list, "非干部月度考核数据");
    }

    /**
     * 获取非干部月度考核详细信息
     */
    @PreAuthorize("@ss.hasPermi('personnel:assessment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(personnelNonCadreMonthlyAssessmentService.selectPersonnelNonCadreMonthlyAssessmentById(id));
    }

    /**
     * 新增非干部月度考核
     */
    @PreAuthorize("@ss.hasPermi('personnel:assessment:add')")
    @Log(title = "非干部月度考核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PersonnelNonCadreMonthlyAssessment personnelNonCadreMonthlyAssessment) {
        personnelNonCadreMonthlyAssessment.setCreateBy(getUsername());
        return toAjax(personnelNonCadreMonthlyAssessmentService.insertPersonnelNonCadreMonthlyAssessment(personnelNonCadreMonthlyAssessment));
    }

    /**
     * 修改非干部月度考核
     */
    @PreAuthorize("@ss.hasPermi('personnel:assessment:edit')")
    @Log(title = "非干部月度考核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PersonnelNonCadreMonthlyAssessment personnelNonCadreMonthlyAssessment) {
        personnelNonCadreMonthlyAssessment.setUpdateBy(getUsername());
        return toAjax(personnelNonCadreMonthlyAssessmentService.updatePersonnelNonCadreMonthlyAssessment(personnelNonCadreMonthlyAssessment));
    }

    /**
     * 删除非干部月度考核
     */
    @PreAuthorize("@ss.hasPermi('personnel:assessment:remove')")
    @Log(title = "非干部月度考核", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(personnelNonCadreMonthlyAssessmentService.deletePersonnelNonCadreMonthlyAssessmentByIds(ids));
    }

    /**
     * 自动生成指定月份非干部月度考核
     */
    @PreAuthorize("@ss.hasPermi('personnel:assessment:add')")
    @GetMapping(value = "/autoGenerate/{month}")
    public AjaxResult autoGenerate(@PathVariable("month") String month) {
        return success(personnelNonCadreMonthlyAssessmentService.autoGenerate(month));
    }
}
