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

import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import cn.ezhizao.project.business.receiveTicket.domain.BizFinancialReceiveTicket;
import cn.ezhizao.project.business.salary.domain.BizFinancialSalary;
import cn.ezhizao.project.business.salary.domain.BizFinancialSalaryDetail;
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.receiveTicket.domain.BizFinancialReceiveTicketDetail;
import cn.ezhizao.project.business.receiveTicket.service.IBizFinancialReceiveTicketDetailService;
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-17
 */
@RestController
@RequestMapping("/business/receiveTicketDetail")
public class BizFinancialReceiveTicketDetailController extends BaseController
{
    @Resource
    private IBizFinancialReceiveTicketDetailService bizFinancialReceiveTicketDetailService;

    /**
     * 查询收票详情列表
     */
    @PreAuthorize("@ss.hasPermi('business:receiveTicket:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizFinancialReceiveTicketDetail bizFinancialReceiveTicketDetail) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizFinancialReceiveTicketDetail);
        startPage();
        List<BizFinancialReceiveTicketDetail> list = bizFinancialReceiveTicketDetailService.getList(bizFinancialReceiveTicketDetail);
        return getDataTable(list);
    }

    /**
     * 导出收票详情列表
     */
    @PreAuthorize("@ss.hasPermi('business:receiveTicket:export')")
    @Log(title = "收票详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizFinancialReceiveTicketDetail bizFinancialReceiveTicketDetail) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizFinancialReceiveTicketDetail);
        List<BizFinancialReceiveTicketDetail> list = bizFinancialReceiveTicketDetailService.getList(bizFinancialReceiveTicketDetail);
        ExcelUtil<BizFinancialReceiveTicketDetail> util = new ExcelUtil<BizFinancialReceiveTicketDetail>(BizFinancialReceiveTicketDetail.class);
        util.exportExcel(response, list, "收票详情数据");
    }

    /**
     * 获取收票详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:receiveTicket:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizFinancialReceiveTicketDetailService.getById(id));
    }

    /**
     * 新增收票详情
     */
    @PreAuthorize("@ss.hasPermi('business:receiveTicket:add')")
    @Log(title = "收票详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizFinancialReceiveTicketDetail bizFinancialReceiveTicketDetail) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizFinancialReceiveTicketDetail);
        return toAjax(bizFinancialReceiveTicketDetailService.save(bizFinancialReceiveTicketDetail));
    }

    /**
     * 修改收票详情
     */
    @PreAuthorize("@ss.hasPermi('business:receiveTicket:edit')")
    @Log(title = "收票详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizFinancialReceiveTicketDetail bizFinancialReceiveTicketDetail) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizFinancialReceiveTicketDetail);
        return toAjax(bizFinancialReceiveTicketDetailService.updateById(bizFinancialReceiveTicketDetail));
    }

    /**
     * 删除收票详情
     */
    @PreAuthorize("@ss.hasPermi('business:receiveTicket:remove')")
    @Log(title = "收票详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(bizFinancialReceiveTicketDetailService.removeBatchByIds(ids));
    }
}
