package cn.ezhizao.project.business.statementAccount.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.statementAccount.domain.BizStatementAccountOnce;
import cn.ezhizao.project.business.statementAccount.service.IBizStatementAccountOnceService;
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-12-05
 */
@RestController
@RequestMapping("/business/statementAccountOnce")
public class BizStatementAccountOnceController extends BaseController
{
    @Resource
    private IBizStatementAccountOnceService bizStatementAccountOnceService;

    /**
     * 查询对账单明细 单次列表
     */
    @PreAuthorize("@ss.hasPermi('business:statementAccountOnce:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizStatementAccountOnce bizStatementAccountOnce) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizStatementAccountOnce);
        startPage();
        List<BizStatementAccountOnce> list = bizStatementAccountOnceService.getList(bizStatementAccountOnce);
        return getDataTable(list);
    }

    /**
     * 导出对账单明细 单次列表
     */
    @PreAuthorize("@ss.hasPermi('business:statementAccountOnce:export')")
    @Log(title = "对账单明细 单次", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizStatementAccountOnce bizStatementAccountOnce) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizStatementAccountOnce);
        List<BizStatementAccountOnce> list = bizStatementAccountOnceService.getList(bizStatementAccountOnce);
        ExcelUtil<BizStatementAccountOnce> util = new ExcelUtil<BizStatementAccountOnce>(BizStatementAccountOnce.class);
        util.exportExcel(response, list, "对账单明细 单次数据");
    }

    /**
     * 获取对账单明细 单次详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:statementAccountOnce:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizStatementAccountOnceService.getById(id));
    }

    /**
     * 新增对账单明细 单次
     */
    @PreAuthorize("@ss.hasPermi('business:statementAccountOnce:add')")
    @Log(title = "对账单明细 单次", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizStatementAccountOnce bizStatementAccountOnce) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizStatementAccountOnce);
        return toAjax(bizStatementAccountOnceService.save(bizStatementAccountOnce));
    }

    /**
     * 修改对账单明细 单次
     */
    @PreAuthorize("@ss.hasPermi('business:statementAccountOnce:edit')")
    @Log(title = "对账单明细 单次", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizStatementAccountOnce bizStatementAccountOnce) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizStatementAccountOnce);
        return toAjax(bizStatementAccountOnceService.updateById(bizStatementAccountOnce));
    }

    /**
     * 删除对账单明细 单次
     */
    @PreAuthorize("@ss.hasPermi('business:statementAccountOnce:remove')")
    @Log(title = "对账单明细 单次", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(bizStatementAccountOnceService.removeBatchByIds(ids));
    }
}
