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.BizStatementAccountLoop;
import cn.ezhizao.project.business.statementAccount.service.IBizStatementAccountLoopService;
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/statementAccountLoop")
public class BizStatementAccountLoopController extends BaseController
{
    @Resource
    private IBizStatementAccountLoopService bizStatementAccountLoopService;

    /**
     * 查询对账单明细 循环列表
     */
    @PreAuthorize("@ss.hasPermi('business:statementAccountLoop:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizStatementAccountLoop bizStatementAccountLoop) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizStatementAccountLoop);
        startPage();
        List<BizStatementAccountLoop> list = bizStatementAccountLoopService.getList(bizStatementAccountLoop);
        return getDataTable(list);
    }

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

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

    /**
     * 新增对账单明细 循环
     */
    @PreAuthorize("@ss.hasPermi('business:statementAccountLoop:add')")
    @Log(title = "对账单明细 循环", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizStatementAccountLoop bizStatementAccountLoop) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizStatementAccountLoop);
        return toAjax(bizStatementAccountLoopService.save(bizStatementAccountLoop));
    }

    /**
     * 修改对账单明细 循环
     */
    @PreAuthorize("@ss.hasPermi('business:statementAccountLoop:edit')")
    @Log(title = "对账单明细 循环", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizStatementAccountLoop bizStatementAccountLoop) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizStatementAccountLoop);
        return toAjax(bizStatementAccountLoopService.updateById(bizStatementAccountLoop));
    }

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