package com.yanzhu.jh.project.controller;

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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.yanzhu.jh.project.domain.SurProjectAttendanceData;
import com.yanzhu.jh.project.service.ISurProjectAttendanceDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 劳务实名制管理Controller
 * 
 * @author ruoyi
 * @date 2023-09-24
 */
@RestController
@RequestMapping("/project/attendance")
public class SurProjectAttendanceDataController extends BaseController
{
    @Autowired
    private ISurProjectAttendanceDataService surProjectAttendanceDataService;

    /**
     * 查询劳务实名制管理列表
     */
    @PreAuthorize("@ss.hasPermi('project:attendance:list')")
    @GetMapping("/list")
    public TableDataInfo list(SurProjectAttendanceData surProjectAttendanceData)
    {
        startPage();
        List<SurProjectAttendanceData> list = surProjectAttendanceDataService.selectSurProjectAttendanceDataList(surProjectAttendanceData);
        return getDataTable(list);
    }

    /**
     * 导出劳务实名制管理列表
     */
    @PreAuthorize("@ss.hasPermi('project:attendance:export')")
    @Log(title = "劳务实名制管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SurProjectAttendanceData surProjectAttendanceData)
    {
        List<SurProjectAttendanceData> list = surProjectAttendanceDataService.selectSurProjectAttendanceDataList(surProjectAttendanceData);
        ExcelUtil<SurProjectAttendanceData> util = new ExcelUtil<SurProjectAttendanceData>(SurProjectAttendanceData.class);
        util.exportExcel(response, list, "劳务实名制管理数据");
    }

    /**
     * 获取劳务实名制管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:attendance:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(surProjectAttendanceDataService.selectSurProjectAttendanceDataById(id));
    }

    /**
     * 新增劳务实名制管理
     */
    @PreAuthorize("@ss.hasPermi('project:attendance:add')")
    @Log(title = "劳务实名制管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SurProjectAttendanceData surProjectAttendanceData)
    {
        return toAjax(surProjectAttendanceDataService.insertSurProjectAttendanceData(surProjectAttendanceData));
    }

    /**
     * 修改劳务实名制管理
     */
    @PreAuthorize("@ss.hasPermi('project:attendance:edit')")
    @Log(title = "劳务实名制管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SurProjectAttendanceData surProjectAttendanceData)
    {
        return toAjax(surProjectAttendanceDataService.updateSurProjectAttendanceData(surProjectAttendanceData));
    }

    /**
     * 删除劳务实名制管理
     */
    @PreAuthorize("@ss.hasPermi('project:attendance:remove')")
    @Log(title = "劳务实名制管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(surProjectAttendanceDataService.deleteSurProjectAttendanceDataByIds(ids));
    }
}
