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.PayPayeeVo;
import com.zhongzheng.modules.pay.bo.PayPayeeQueryBo;
import com.zhongzheng.modules.pay.bo.PayPayeeAddBo;
import com.zhongzheng.modules.pay.bo.PayPayeeEditBo;
import com.zhongzheng.modules.pay.service.IPayPayeeService;
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/payee")
public class PayPayeeController extends BaseController {

    private final IPayPayeeService iPayPayeeService;

    /**
     * 查询收款方列表
     */
    @ApiOperation("查询收款方列表")
    @PreAuthorize("@ss.hasPermi('pay:payee:list')")
    @GetMapping("/list")
    public TableDataInfo<PayPayeeVo> list(PayPayeeQueryBo bo) {
        startPage();
        List<PayPayeeVo> list = iPayPayeeService.queryList(bo);
        return getDataTable(list);
    }

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

    /**
     * 获取收款方详细信息
     */
    @ApiOperation("获取收款方详细信息")
    @PreAuthorize("@ss.hasPermi('pay:payee:query')")
    @GetMapping("/{payeeId}")
    public AjaxResult<PayPayeeVo> getInfo(@PathVariable("payeeId" ) Long payeeId) {
        return AjaxResult.success(iPayPayeeService.queryById(payeeId));
    }

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

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

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