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.PayAisleVo;
import com.zhongzheng.modules.pay.bo.PayAisleQueryBo;
import com.zhongzheng.modules.pay.bo.PayAisleAddBo;
import com.zhongzheng.modules.pay.bo.PayAisleEditBo;
import com.zhongzheng.modules.pay.service.IPayAisleService;
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/aisle")
public class PayAisleController extends BaseController {

    private final IPayAisleService iPayAisleService;

    /**
     * 查询支付通道列表
     */
    @ApiOperation("查询支付通道列表")
    @PreAuthorize("@ss.hasPermi('pay:aisle:list')")
    @GetMapping("/list")
    public TableDataInfo<PayAisleVo> list(PayAisleQueryBo bo) {
        startPage();
        List<PayAisleVo> list = iPayAisleService.queryList(bo);
        return getDataTable(list);
    }

    /**
     * 导出支付通道列表
     */
/*    @ApiOperation("导出支付通道列表")
    @PreAuthorize("@ss.hasPermi('pay:aisle:export')")
    @Log(title = "支付通道", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<PayAisleVo> export(PayAisleQueryBo bo) {
        List<PayAisleVo> list = iPayAisleService.queryList(bo);
        ExcelUtil<PayAisleVo> util = new ExcelUtil<PayAisleVo>(PayAisleVo.class);
        return util.exportExcel(list, "支付通道");
    }*/

    /**
     * 获取支付通道详细信息
     */
    @ApiOperation("获取支付通道详细信息")
    @PreAuthorize("@ss.hasPermi('pay:aisle:query')")
    @GetMapping("/{aisleId}")
    public AjaxResult<PayAisleVo> getInfo(@PathVariable("aisleId" ) Long aisleId) {
        return AjaxResult.success(iPayAisleService.queryById(aisleId));
    }

    /**
     * 新增支付通道
     */
    @ApiOperation("新增支付通道")
    @PreAuthorize("@ss.hasPermi('pay:aisle:add')")
    @Log(title = "支付通道", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody PayAisleAddBo bo) {
        return toAjax(iPayAisleService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改支付通道
     */
    @ApiOperation("修改支付通道")
    @PreAuthorize("@ss.hasPermi('pay:aisle:edit')")
    @Log(title = "支付通道", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult<Void> edit(@RequestBody PayAisleEditBo bo) {
        return toAjax(iPayAisleService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除支付通道
     */
 /*   @ApiOperation("删除支付通道")
    @PreAuthorize("@ss.hasPermi('pay:aisle:remove')")
    @Log(title = "支付通道" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{aisleIds}")
    public AjaxResult<Void> remove(@PathVariable Long[] aisleIds) {
        return toAjax(iPayAisleService.deleteWithValidByIds(Arrays.asList(aisleIds), true) ? 1 : 0);
    }*/
}
