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.TShiftAnnualAssHis;
import com.ruoyi.project.shiftmgr.service.ITShiftAnnualAssHisService;
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/his")
public class TShiftAnnualAssHisController extends BaseController
{
    @Autowired
    private ITShiftAnnualAssHisService tShiftAnnualAssHisService;

    /**
     * 查询年度考核打分记录列表
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:his:list')")
    @GetMapping("/list")
    public TableDataInfo list(TShiftAnnualAssHis tShiftAnnualAssHis)
    {
        startPage();
        List<TShiftAnnualAssHis> list = tShiftAnnualAssHisService.selectTShiftAnnualAssHisList(tShiftAnnualAssHis);
        return getDataTable(list);
    }

    /**
     * 导出年度考核打分记录列表
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:his:export')")
    @Log(title = "年度考核打分记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TShiftAnnualAssHis tShiftAnnualAssHis)
    {
        List<TShiftAnnualAssHis> list = tShiftAnnualAssHisService.selectTShiftAnnualAssHisList(tShiftAnnualAssHis);
        ExcelUtil<TShiftAnnualAssHis> util = new ExcelUtil<TShiftAnnualAssHis>(TShiftAnnualAssHis.class);
        return util.exportExcel(list, "his");
    }

    /**
     * 获取年度考核打分记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:his:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tShiftAnnualAssHisService.selectTShiftAnnualAssHisById(id));
    }

    /**
     * 新增年度考核打分记录
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:his:add')")
    @Log(title = "年度考核打分记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TShiftAnnualAssHis tShiftAnnualAssHis)
    {
        tShiftAnnualAssHis.setCreaterCode(getUserId());
        tShiftAnnualAssHis.setCreatedate(new Date());
        return toAjax(tShiftAnnualAssHisService.insertTShiftAnnualAssHis(tShiftAnnualAssHis));
    }

    /**
     * 修改年度考核打分记录
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:his:edit')")
    @Log(title = "年度考核打分记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TShiftAnnualAssHis tShiftAnnualAssHis)
    {
        tShiftAnnualAssHis.setUpdaterCode(getUserId());
        tShiftAnnualAssHis.setUpdatedate(new Date());
        return toAjax(tShiftAnnualAssHisService.updateTShiftAnnualAssHis(tShiftAnnualAssHis));
    }

    /**
     * 删除年度考核打分记录
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:his:remove')")
    @Log(title = "年度考核打分记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tShiftAnnualAssHisService.deleteTShiftAnnualAssHisByIds(ids));
    }
}
