package cn.ezhizao.project.business.salary.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
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 cn.ezhizao.framework.aspectj.lang.annotation.Log;
import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
import cn.ezhizao.project.business.salary.domain.BizFinancialSalaryDetail;
import cn.ezhizao.project.business.salary.service.IBizFinancialSalaryDetailService;
import cn.ezhizao.framework.web.controller.BaseController;
import cn.ezhizao.framework.web.domain.AjaxResult;
import cn.ezhizao.common.utils.poi.ExcelUtil;
import cn.ezhizao.framework.web.page.TableDataInfo;

/**
 * 工资报工信息Controller
 *
 * @author ruoyi
 * @date 2023-11-16
 */
@RestController
@RequestMapping("/business/salaryDetail")
public class BizFinancialSalaryDetailController extends BaseController
{
    @Resource
    private IBizFinancialSalaryDetailService bizFinancialSalaryDetailService;

    /**
     * 查询工资报工信息列表
     */
    @PreAuthorize("@ss.hasPermi('business:salaryDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizFinancialSalaryDetail bizFinancialSalaryDetail) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizFinancialSalaryDetail);
        startPage();
        List<BizFinancialSalaryDetail> list = bizFinancialSalaryDetailService.getList(bizFinancialSalaryDetail);
        return getDataTable(list);
    }

    /**
     * 导出工资报工信息列表
     */
    @PreAuthorize("@ss.hasPermi('business:salaryDetail:export')")
    @Log(title = "工资报工信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizFinancialSalaryDetail bizFinancialSalaryDetail) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizFinancialSalaryDetail);
        List<BizFinancialSalaryDetail> list = bizFinancialSalaryDetailService.getList(bizFinancialSalaryDetail);
        ExcelUtil<BizFinancialSalaryDetail> util = new ExcelUtil<BizFinancialSalaryDetail>(BizFinancialSalaryDetail.class);
        util.exportExcel(response, list, "工资报工信息数据");
    }

    /**
     * 获取工资报工信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:salaryDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizFinancialSalaryDetailService.getById(id));
    }

    /**
     * 新增工资报工信息
     */
    @PreAuthorize("@ss.hasPermi('business:salaryDetail:add')")
    @Log(title = "工资报工信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizFinancialSalaryDetail bizFinancialSalaryDetail) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizFinancialSalaryDetail);
        return toAjax(bizFinancialSalaryDetailService.save(bizFinancialSalaryDetail));
    }

    /**
     * 修改工资报工信息
     */
    @PreAuthorize("@ss.hasPermi('business:salaryDetail:edit')")
    @Log(title = "工资报工信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizFinancialSalaryDetail bizFinancialSalaryDetail) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizFinancialSalaryDetail);
        return toAjax(bizFinancialSalaryDetailService.updateById(bizFinancialSalaryDetail));
    }

    /**
     * 删除工资报工信息
     */
    @PreAuthorize("@ss.hasPermi('business:salaryDetail:remove')")
    @Log(title = "工资报工信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(bizFinancialSalaryDetailService.removeBatchByIds(ids));
    }
}
