package com.ruoyi.project.shiftmgr.controller;

import java.util.Date;
import java.util.List;
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.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.shiftmgr.domain.TShiftAnnualAssessment;
import com.ruoyi.project.shiftmgr.service.ITShiftAnnualAssessmentService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 年度考核信息Controller
 *
 * @author ruoyi
 * @date 2022-08-05
 */
@RestController
@RequestMapping("/shiftmgr/assessment")
public class TShiftAnnualAssessmentController extends BaseController
{
    @Autowired
    private ITShiftAnnualAssessmentService tShiftAnnualAssessmentService;

    /**
     * 查询年度考核信息列表
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:assessment:list')")
    @GetMapping("/list")
    public TableDataInfo list(TShiftAnnualAssessment tShiftAnnualAssessment)
    {
        startPage();
        List<TShiftAnnualAssessment> list = tShiftAnnualAssessmentService.selectTShiftAnnualAssessmentList(tShiftAnnualAssessment);
        return getDataTable(list);
    }

    /**
     * 导出年度考核信息列表
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:assessment:export')")
    @Log(title = "年度考核信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TShiftAnnualAssessment tShiftAnnualAssessment)
    {
        List<TShiftAnnualAssessment> list = tShiftAnnualAssessmentService.selectTShiftAnnualAssessmentList(tShiftAnnualAssessment);
        ExcelUtil<TShiftAnnualAssessment> util = new ExcelUtil<TShiftAnnualAssessment>(TShiftAnnualAssessment.class);
        return util.exportExcel(list, "assessment");
    }

    /**
     * 获取年度考核信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:assessment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tShiftAnnualAssessmentService.selectTShiftAnnualAssessmentById(id));
    }

    /**
     * 新增年度考核信息
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:assessment:add')")
    @Log(title = "年度考核信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TShiftAnnualAssessment tShiftAnnualAssessment)
    {
        tShiftAnnualAssessment.setCreaterCode(getUserId());
        tShiftAnnualAssessment.setCreatedate(new Date());
        return toAjax(tShiftAnnualAssessmentService.insertTShiftAnnualAssessment(tShiftAnnualAssessment));
    }

    /**
     * 修改年度考核信息
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:assessment:edit')")
    @Log(title = "年度考核信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TShiftAnnualAssessment tShiftAnnualAssessment)
    {
        tShiftAnnualAssessment.setUpdaterCode(getUserId());
        tShiftAnnualAssessment.setUpdatedate(new Date());
        return toAjax(tShiftAnnualAssessmentService.updateTShiftAnnualAssessment(tShiftAnnualAssessment));
    }

    /**
     * 删除年度考核信息
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:assessment:remove')")
    @Log(title = "年度考核信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tShiftAnnualAssessmentService.deleteTShiftAnnualAssessmentByIds(ids));
    }
}
