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.PayServeVo;
import com.zhongzheng.modules.pay.bo.PayServeQueryBo;
import com.zhongzheng.modules.pay.bo.PayServeAddBo;
import com.zhongzheng.modules.pay.bo.PayServeEditBo;
import com.zhongzheng.modules.pay.service.IPayServeService;
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/serve")
public class PayServeController extends BaseController {

    private final IPayServeService iPayServeService;

    /**
     * 查询服务模式列表
     */
    @ApiOperation("查询服务模式列表")
    @PreAuthorize("@ss.hasPermi('pay:serve:list')")
    @GetMapping("/list")
    public TableDataInfo<PayServeVo> list(PayServeQueryBo bo) {
        startPage();
        List<PayServeVo> list = iPayServeService.queryList(bo);
        return getDataTable(list);
    }

    /**
     * 导出服务模式列表
     */
  /*  @ApiOperation("导出服务模式列表")
    @PreAuthorize("@ss.hasPermi('pay:serve:export')")
    @Log(title = "服务模式", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<PayServeVo> export(PayServeQueryBo bo) {
        List<PayServeVo> list = iPayServeService.queryList(bo);
        ExcelUtil<PayServeVo> util = new ExcelUtil<PayServeVo>(PayServeVo.class);
        return util.exportExcel(list, "服务模式");
    }*/

    /**
     * 获取服务模式详细信息
     */
    @ApiOperation("获取服务模式详细信息")
    @PreAuthorize("@ss.hasPermi('pay:serve:query')")
    @GetMapping("/{serveId}")
    public AjaxResult<PayServeVo> getInfo(@PathVariable("serveId" ) Long serveId) {
        return AjaxResult.success(iPayServeService.queryById(serveId));
    }

    /**
     * 新增服务模式
     */
    @ApiOperation("新增服务模式")
    @PreAuthorize("@ss.hasPermi('pay:serve:add')")
    @Log(title = "服务模式", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody PayServeAddBo bo) {
        return toAjax(iPayServeService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改服务模式
     */
    @ApiOperation("修改服务模式")
    @PreAuthorize("@ss.hasPermi('pay:serve:edit')")
    @Log(title = "服务模式", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult<Void> edit(@RequestBody PayServeEditBo bo) {
        return toAjax(iPayServeService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除服务模式
     */
/*    @ApiOperation("删除服务模式")
    @PreAuthorize("@ss.hasPermi('pay:serve:remove')")
    @Log(title = "服务模式" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{serveIds}")
    public AjaxResult<Void> remove(@PathVariable Long[] serveIds) {
        return toAjax(iPayServeService.deleteWithValidByIds(Arrays.asList(serveIds), true) ? 1 : 0);
    }*/
}
