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.PayNatureVo;
import com.zhongzheng.modules.pay.bo.PayNatureQueryBo;
import com.zhongzheng.modules.pay.bo.PayNatureAddBo;
import com.zhongzheng.modules.pay.bo.PayNatureEditBo;
import com.zhongzheng.modules.pay.service.IPayNatureService;
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/nature")
public class PayNatureController extends BaseController {

    private final IPayNatureService iPayNatureService;

    /**
     * 查询收费性质列表
     */
    @ApiOperation("查询收费性质列表")
    @PreAuthorize("@ss.hasPermi('pay:nature:list')")
    @GetMapping("/list")
    public TableDataInfo<PayNatureVo> list(PayNatureQueryBo bo) {
        startPage();
        List<PayNatureVo> list = iPayNatureService.queryList(bo);
        return getDataTable(list);
    }

    /**
     * 导出收费性质列表
     */
/*    @ApiOperation("导出收费性质列表")
    @PreAuthorize("@ss.hasPermi('pay:nature:export')")
    @Log(title = "收费性质", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<PayNatureVo> export(PayNatureQueryBo bo) {
        List<PayNatureVo> list = iPayNatureService.queryList(bo);
        ExcelUtil<PayNatureVo> util = new ExcelUtil<PayNatureVo>(PayNatureVo.class);
        return util.exportExcel(list, "收费性质");
    }*/

    /**
     * 获取收费性质详细信息
     */
    @ApiOperation("获取收费性质详细信息")
    @PreAuthorize("@ss.hasPermi('pay:nature:query')")
    @GetMapping("/{natureId}")
    public AjaxResult<PayNatureVo> getInfo(@PathVariable("natureId" ) Long natureId) {
        return AjaxResult.success(iPayNatureService.queryById(natureId));
    }

    /**
     * 新增收费性质
     */
    @ApiOperation("新增收费性质")
    @PreAuthorize("@ss.hasPermi('pay:nature:add')")
    @Log(title = "收费性质", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody PayNatureAddBo bo) {
        return toAjax(iPayNatureService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改收费性质
     */
    @ApiOperation("修改收费性质")
    @PreAuthorize("@ss.hasPermi('pay:nature:edit')")
    @Log(title = "收费性质", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult<Void> edit(@RequestBody PayNatureEditBo bo) {
        return toAjax(iPayNatureService.updateByEditBo(bo) ? 1 : 0);
    }

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