package com.ruoyi.controller;

import java.util.List;
import javax.annotation.Resource;
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.ruoyi.cs.domain.CsWorkloadRecord;
import com.ruoyi.cs.service.ICsWorkloadRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 人员工作量记录Controller
 *
 * @author ruoyi
 * @date 2024-05-31
 */
@RestController
@RequestMapping("/cs/csWorkloadRecord")
public class CsWorkloadRecordController extends BaseController
{
    @Resource
    private ICsWorkloadRecordService csWorkloadRecordService;

    /**
     * 查询人员工作量记录列表
     */
    @PreAuthorize("@ss.hasPermi('cs:csWorkloadRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(CsWorkloadRecord csWorkloadRecord)
    {
        startPage();
        csWorkloadRecord.setDelFlag("0");
        List<CsWorkloadRecord> list = csWorkloadRecordService.selectCsWorkloadRecordList(csWorkloadRecord);
        return getDataTable(list);
    }

    /**
     * 导出人员工作量记录列表
     */
    @PreAuthorize("@ss.hasPermi('cs:csWorkloadRecord:export')")
    @Log(title = "人员工作量记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CsWorkloadRecord csWorkloadRecord)
    {
        List<CsWorkloadRecord> list = csWorkloadRecordService.selectCsWorkloadRecordList(csWorkloadRecord);
        ExcelUtil<CsWorkloadRecord> util = new ExcelUtil<CsWorkloadRecord>(CsWorkloadRecord.class);
        util.exportExcel(response, list, "人员工作量记录数据");
    }

    /**
     * 获取人员工作量记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('cs:csWorkloadRecord:query')")
    @GetMapping(value = "/{workloadRecordId}")
    public AjaxResult getInfo(@PathVariable("workloadRecordId") String workloadRecordId)
    {
        return AjaxResult.success(csWorkloadRecordService.selectCsWorkloadRecordByWorkloadRecordId(workloadRecordId));
    }

    /**
     * 新增人员工作量记录
     */
    @PreAuthorize("@ss.hasPermi('cs:csWorkloadRecord:add')")
    @Log(title = "人员工作量记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CsWorkloadRecord csWorkloadRecord)
    {
        return toAjax(csWorkloadRecordService.insertCsWorkloadRecord(csWorkloadRecord));
    }

    /**
     * 修改人员工作量记录
     */
    @PreAuthorize("@ss.hasPermi('cs:csWorkloadRecord:edit')")
    @Log(title = "人员工作量记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CsWorkloadRecord csWorkloadRecord)
    {
        return toAjax(csWorkloadRecordService.updateCsWorkloadRecord(csWorkloadRecord));
    }

    /**
     * 删除人员工作量记录
     */
    @PreAuthorize("@ss.hasPermi('cs:csWorkloadRecord:remove')")
    @Log(title = "人员工作量记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{workloadRecordIds}")
    public AjaxResult remove(@PathVariable String[] workloadRecordIds)
    {
        return toAjax(csWorkloadRecordService.deleteCsWorkloadRecordByWorkloadRecordIds(workloadRecordIds));
    }
}
