package com.ruoyi.oa.controller;

import java.util.List;
import java.util.Arrays;

import com.ruoyi.oa.domain.bo.SysOaReceiveAccountBo;
import com.ruoyi.oa.domain.vo.SysOaReceiveAccountVo;
import com.ruoyi.oa.service.ISysOaReceiveAccountService;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;

import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 付款账户管理
 *
 * @author hdka
 * @date 2024-11-02
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/oaReceiveAccount")
public class SysOaReceiveAccountController extends BaseController {

    private final ISysOaReceiveAccountService iSysOaReceiveAccountService;

    /**
     * 查询付款账户管理列表
     */
    @GetMapping("/list")
    public R<List<SysOaReceiveAccountVo>> list(SysOaReceiveAccountBo bo) {

        return R.ok(iSysOaReceiveAccountService.queryPageList(bo));
    }

    /**
     * 获取全部账户数据
     */
    @GetMapping("/allList")
    public R<List<SysOaReceiveAccountVo>> allList(SysOaReceiveAccountBo bo) {

        return R.ok(iSysOaReceiveAccountService.queryList(bo));
    }


    /**
     * 导出付款账户管理列表
     */
    @Log(title = "付款账户管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(SysOaReceiveAccountBo bo, HttpServletResponse response) {
        List<SysOaReceiveAccountVo> list = iSysOaReceiveAccountService.queryList(bo);
        ExcelUtil.exportExcel(list, "付款账户管理", SysOaReceiveAccountVo.class, response);
    }

    /**
     * 获取付款账户管理详细信息
     *
     * @param receiveAccountId 主键
     */
    @GetMapping("/{receiveAccountId}")
    public R<SysOaReceiveAccountVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long receiveAccountId) {
        return R.ok(iSysOaReceiveAccountService.queryById(receiveAccountId));
    }

    /**
     * 新增付款账户管理
     */
    @Log(title = "付款账户管理", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<SysOaReceiveAccountVo> add(@Validated(AddGroup.class) @RequestBody SysOaReceiveAccountBo bo) {
        return R.ok(iSysOaReceiveAccountService.insertByBo(bo));
    }

    /**
     * 修改付款账户管理
     */
    @Log(title = "付款账户管理", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysOaReceiveAccountBo bo) {
        return toAjax(iSysOaReceiveAccountService.updateByBo(bo));
    }

    /**
     * 删除付款账户管理
     *
     * @param receiveAccountIds 主键串
     */
    @Log(title = "付款账户管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{receiveAccountIds}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] receiveAccountIds) {
        return toAjax(iSysOaReceiveAccountService.deleteWithValidByIds(Arrays.asList(receiveAccountIds), true));
    }
}
