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.PayVisitVo;
import com.zhongzheng.modules.pay.bo.PayVisitQueryBo;
import com.zhongzheng.modules.pay.bo.PayVisitAddBo;
import com.zhongzheng.modules.pay.bo.PayVisitEditBo;
import com.zhongzheng.modules.pay.service.IPayVisitService;
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/visit")
public class PayVisitController extends BaseController {

    private final IPayVisitService iPayVisitService;

    /**
     * 查询到访校区列表
     */
    @ApiOperation("查询到访校区列表")
    @PreAuthorize("@ss.hasPermi('pay:visit:list')")
    @GetMapping("/list")
    public TableDataInfo<PayVisitVo> list(PayVisitQueryBo bo) {
        startPage();
        List<PayVisitVo> list = iPayVisitService.queryList(bo);
        return getDataTable(list);
    }

    /**
     * 导出到访校区列表
     */
/*
    @ApiOperation("导出到访校区列表")
    @PreAuthorize("@ss.hasPermi('pay:visit:export')")
    @Log(title = "到访校区", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<PayVisitVo> export(PayVisitQueryBo bo) {
        List<PayVisitVo> list = iPayVisitService.queryList(bo);
        ExcelUtil<PayVisitVo> util = new ExcelUtil<PayVisitVo>(PayVisitVo.class);
        return util.exportExcel(list, "到访校区");
    }
*/

    /**
     * 获取到访校区详细信息
     */
    @ApiOperation("获取到访校区详细信息")
    @PreAuthorize("@ss.hasPermi('pay:visit:query')")
    @GetMapping("/{visitId}")
    public AjaxResult<PayVisitVo> getInfo(@PathVariable("visitId" ) Long visitId) {
        return AjaxResult.success(iPayVisitService.queryById(visitId));
    }

    /**
     * 新增到访校区
     */
    @ApiOperation("新增到访校区")
    @PreAuthorize("@ss.hasPermi('pay:visit:add')")
    @Log(title = "到访校区", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody PayVisitAddBo bo) {
        return toAjax(iPayVisitService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改到访校区
     */
    @ApiOperation("修改到访校区")
    @PreAuthorize("@ss.hasPermi('pay:visit:edit')")
    @Log(title = "到访校区", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult<Void> edit(@RequestBody PayVisitEditBo bo) {
        return toAjax(iPayVisitService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除到访校区
     */
 /*   @ApiOperation("删除到访校区")
    @PreAuthorize("@ss.hasPermi('pay:visit:remove')")
    @Log(title = "到访校区" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{visitIds}")
    public AjaxResult<Void> remove(@PathVariable Long[] visitIds) {
        return toAjax(iPayVisitService.deleteWithValidByIds(Arrays.asList(visitIds), true) ? 1 : 0);
    }*/
}
