package com.ruoyi.web.controller.oa;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.common.core.domain.entity.CmcPostSalary;
import com.ruoyi.oa.service.ICmcPostSalaryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * cmc岗位工资Controller
 * 
 * @author cmc
 * @date 2024-03-25
 */
@RestController
@RequestMapping("/oa/salary")
public class CmcPostSalaryController extends BaseController
{
    @Autowired
    private ICmcPostSalaryService cmcPostSalaryService;

    /**
     * 查询cmc岗位工资列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcPostSalary cmcPostSalary)
    {
        startPage();
        List<CmcPostSalary> list = cmcPostSalaryService.selectCmcPostSalaryList(cmcPostSalary);
        return getDataTable(list);
    }

    /**
     * 导出cmc岗位工资列表
     */
    @Log(title = "cmc岗位工资", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcPostSalary cmcPostSalary)
    {
        List<CmcPostSalary> list = cmcPostSalaryService.selectCmcPostSalaryList(cmcPostSalary);
        ExcelUtil<CmcPostSalary> util = new ExcelUtil<CmcPostSalary>(CmcPostSalary.class);
        util.exportExcel(response, list, "cmc岗位工资数据");
    }

    /**
     * 获取cmc岗位工资详细信息
     */
    @GetMapping(value = "/{salaryId}")
    public AjaxResult getInfo(@PathVariable("salaryId") Integer salaryId)
    {
        return success(cmcPostSalaryService.selectCmcPostSalaryBySalaryId(salaryId));
    }

    /**
     * 新增cmc岗位工资
     */
    @Log(title = "cmc岗位工资", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcPostSalary cmcPostSalary)
    {
        return toAjax(cmcPostSalaryService.insertCmcPostSalary(cmcPostSalary));
    }

    /**
     * 修改cmc岗位工资
     */
    @Log(title = "cmc岗位工资", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcPostSalary cmcPostSalary)
    {
        return toAjax(cmcPostSalaryService.updateCmcPostSalary(cmcPostSalary));
    }

    /**
     * 删除cmc岗位工资
     */
    @Log(title = "cmc岗位工资", businessType = BusinessType.DELETE)
	@DeleteMapping("/{salaryIds}")
    public AjaxResult remove(@PathVariable Integer[] salaryIds)
    {
        return success(cmcPostSalaryService.deleteCmcPostSalaryBySalaryIds(salaryIds));
    }
}
