package com.zhongzheng.controller.pay;

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

import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
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 com.zhongzheng.common.annotation.Log;
import com.zhongzheng.common.core.controller.BaseController;
import com.zhongzheng.common.core.domain.AjaxResult;
import com.zhongzheng.common.enums.BusinessType;
import com.zhongzheng.modules.pay.vo.PayPayeeAisleVo;
import com.zhongzheng.modules.pay.bo.PayPayeeAisleQueryBo;
import com.zhongzheng.modules.pay.bo.PayPayeeAisleAddBo;
import com.zhongzheng.modules.pay.bo.PayPayeeAisleEditBo;
import com.zhongzheng.modules.pay.service.IPayPayeeAisleService;
import com.zhongzheng.common.utils.poi.ExcelUtil;
import com.zhongzheng.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 收款方账户Controller
 * 
 * @author ruoyi
 * @date 2021-10-12
 */
@Api(value = "收款方账户控制器", tags = {"收款方账户管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/pay/PayeeAisle")
public class PayPayeeAisleController extends BaseController {

    private final IPayPayeeAisleService iPayPayeeAisleService;

    /**
     * 查询收款方账户列表
     */
    @ApiOperation("查询收款方账户列表")
    @PreAuthorize("@ss.hasPermi('pay:aisle:list')")
    @GetMapping("/list")
    public TableDataInfo<PayPayeeAisleVo> list(PayPayeeAisleQueryBo bo) {
        startPage();
        List<PayPayeeAisleVo> list = iPayPayeeAisleService.queryList(bo);
        return getDataTable(list);
    }

    /**
     * 导出收款方账户列表
     */
/*    @ApiOperation("导出收款方账户列表")
    @PreAuthorize("@ss.hasPermi('pay:aisle:export')")
    @Log(title = "收款方账户", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<PayPayeeAisleVo> export(PayPayeeAisleQueryBo bo) {
        List<PayPayeeAisleVo> list = iPayPayeeAisleService.queryList(bo);
        ExcelUtil<PayPayeeAisleVo> util = new ExcelUtil<PayPayeeAisleVo>(PayPayeeAisleVo.class);
        return util.exportExcel(list, "收款方账户");
    }*/

    /**
     * 获取收款方账户详细信息
     */
    @ApiOperation("获取收款方账户详细信息")
    @PreAuthorize("@ss.hasPermi('pay:aisle:query')")
    @GetMapping("/{accountId}")
    public AjaxResult<PayPayeeAisleVo> getInfo(@PathVariable("accountId" ) Long accountId) {
        return AjaxResult.success(iPayPayeeAisleService.queryById(accountId));
    }

    /**
     * 新增收款方账户
     */
    @ApiOperation("新增收款方账户")
    @PreAuthorize("@ss.hasPermi('pay:aisle:add')")
    @Log(title = "收款方账户", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody PayPayeeAisleAddBo bo) {
        return toAjax(iPayPayeeAisleService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改收款方账户
     */
    @ApiOperation("修改收款方账户")
    @PreAuthorize("@ss.hasPermi('pay:aisle:edit')")
    @Log(title = "收款方账户", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult<Void> edit(@RequestBody PayPayeeAisleEditBo bo) {
        return toAjax(iPayPayeeAisleService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除收款方账户
     */
/*    @ApiOperation("删除收款方账户")
    @PreAuthorize("@ss.hasPermi('pay:aisle:remove')")
    @Log(title = "收款方账户" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{accountIds}")
    public AjaxResult<Void> remove(@PathVariable Long[] accountIds) {
        return toAjax(iPayPayeeAisleService.deleteWithValidByIds(Arrays.asList(accountIds), true) ? 1 : 0);
    }*/
}
