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.TShiftAnnualAssPoints;
import com.ruoyi.project.shiftmgr.service.ITShiftAnnualAssPointsService;
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/points")
public class TShiftAnnualAssPointsController extends BaseController
{
    @Autowired
    private ITShiftAnnualAssPointsService tShiftAnnualAssPointsService;

    /**
     * 查询年度考核计分列表
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:points:list')")
    @GetMapping("/list")
    public TableDataInfo list(TShiftAnnualAssPoints tShiftAnnualAssPoints)
    {
        startPage();
        List<TShiftAnnualAssPoints> list = tShiftAnnualAssPointsService.selectTShiftAnnualAssPointsList(tShiftAnnualAssPoints);
        return getDataTable(list);
    }

    /**
     * 导出年度考核计分列表
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:points:export')")
    @Log(title = "年度考核计分", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TShiftAnnualAssPoints tShiftAnnualAssPoints)
    {
        List<TShiftAnnualAssPoints> list = tShiftAnnualAssPointsService.selectTShiftAnnualAssPointsList(tShiftAnnualAssPoints);
        ExcelUtil<TShiftAnnualAssPoints> util = new ExcelUtil<TShiftAnnualAssPoints>(TShiftAnnualAssPoints.class);
        return util.exportExcel(list, "points");
    }

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

    /**
     * 新增年度考核计分
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:points:add')")
    @Log(title = "年度考核计分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TShiftAnnualAssPoints tShiftAnnualAssPoints)
    {
        tShiftAnnualAssPoints.setCreaterCode(getUserId());
        tShiftAnnualAssPoints.setCreatedate(new Date());
        return toAjax(tShiftAnnualAssPointsService.insertTShiftAnnualAssPoints(tShiftAnnualAssPoints));
    }

    /**
     * 修改年度考核计分
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:points:edit')")
    @Log(title = "年度考核计分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TShiftAnnualAssPoints tShiftAnnualAssPoints)
    {
        tShiftAnnualAssPoints.setUpdaterCode(getUserId());
        tShiftAnnualAssPoints.setUpdatedate(new Date());
        return toAjax(tShiftAnnualAssPointsService.updateTShiftAnnualAssPoints(tShiftAnnualAssPoints));
    }

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