package com.ruoyi.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cs.domain.CsPaymentDetails;
import com.ruoyi.cs.service.ICsPaymentDetailsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 充值付费明细Controller
 *
 * @author ruoyi
 * @date 2024-06-20
 */
@RestController
@RequestMapping("/cs/csPaymentDetails")
public class CsPaymentDetailsController extends BaseController
{
    @Resource
    private ICsPaymentDetailsService csPaymentDetailsService;

    /**
     * 查询充值付费明细列表
     */
    @PreAuthorize("@ss.hasPermi('cs:csPaymentDetails:list')")
    @GetMapping("/list")
    public TableDataInfo list(CsPaymentDetails csPaymentDetails)
    {
        startPage();
        csPaymentDetails.setDelFlag("0");
        List<CsPaymentDetails> list = csPaymentDetailsService.selectCsPaymentDetailsList(csPaymentDetails);
        return getDataTable(list);
    }

    /**
     * 导出充值付费明细列表
     */
    @PreAuthorize("@ss.hasPermi('cs:csPaymentDetails:export')")
    @Log(title = "充值付费明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CsPaymentDetails csPaymentDetails)
    {
        List<CsPaymentDetails> list = csPaymentDetailsService.selectCsPaymentDetailsList(csPaymentDetails);
        ExcelUtil<CsPaymentDetails> util = new ExcelUtil<CsPaymentDetails>(CsPaymentDetails.class);
        util.exportExcel(response, list, "充值付费明细数据");
    }

    /**
     * 获取充值付费明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('cs:csPaymentDetails:query')")
    @GetMapping(value = "/{paymentDetailsId}")
    public AjaxResult getInfo(@PathVariable("paymentDetailsId") String paymentDetailsId)
    {
        return AjaxResult.success(csPaymentDetailsService.selectCsPaymentDetailsByPaymentDetailsId(paymentDetailsId));
    }

    /**
     * 新增充值付费明细
     */
    @PreAuthorize("@ss.hasPermi('cs:csPaymentDetails:add')")
    @Log(title = "充值付费明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CsPaymentDetails csPaymentDetails)
    {
        return toAjax(csPaymentDetailsService.insertCsPaymentDetails(csPaymentDetails));
    }

    /**
     * 修改充值付费明细
     */
    @PreAuthorize("@ss.hasPermi('cs:csPaymentDetails:edit')")
    @Log(title = "充值付费明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CsPaymentDetails csPaymentDetails)
    {
        return toAjax(csPaymentDetailsService.updateCsPaymentDetails(csPaymentDetails));
    }

    /**
     * 删除充值付费明细
     */
    @PreAuthorize("@ss.hasPermi('cs:csPaymentDetails:remove')")
    @Log(title = "充值付费明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{paymentDetailsIds}")
    public AjaxResult remove(@PathVariable String[] paymentDetailsIds)
    {
        return toAjax(csPaymentDetailsService.deleteCsPaymentDetailsByPaymentDetailsIds(paymentDetailsIds));
    }
}
