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.BizFinancialSalaryDetailEmployee;
import cn.ezhizao.project.business.salary.service.IBizFinancialSalaryDetailEmployeeService;
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/salaryDetailEmployee")
public class BizFinancialSalaryDetailEmployeeController extends BaseController
{
    @Resource
    private IBizFinancialSalaryDetailEmployeeService bizFinancialSalaryDetailEmployeeService;

    /**
     * 查询工资人员信息列表
     */
    @PreAuthorize("@ss.hasPermi('business:salaryDetailEmployee:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizFinancialSalaryDetailEmployee bizFinancialSalaryDetailEmployee) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizFinancialSalaryDetailEmployee);
        startPage();
        List<BizFinancialSalaryDetailEmployee> list = bizFinancialSalaryDetailEmployeeService.getList(bizFinancialSalaryDetailEmployee);
        return getDataTable(list);
    }

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

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

    /**
     * 新增工资人员信息
     */
    @PreAuthorize("@ss.hasPermi('business:salaryDetailEmployee:add')")
    @Log(title = "工资人员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizFinancialSalaryDetailEmployee bizFinancialSalaryDetailEmployee) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizFinancialSalaryDetailEmployee);
        return toAjax(bizFinancialSalaryDetailEmployeeService.save(bizFinancialSalaryDetailEmployee));
    }

    /**
     * 修改工资人员信息
     */
    @PreAuthorize("@ss.hasPermi('business:salaryDetailEmployee:edit')")
    @Log(title = "工资人员信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizFinancialSalaryDetailEmployee bizFinancialSalaryDetailEmployee) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizFinancialSalaryDetailEmployee);
        return toAjax(bizFinancialSalaryDetailEmployeeService.updateById(bizFinancialSalaryDetailEmployee));
    }

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