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.CsResourceCharging;
import com.ruoyi.cs.service.ICsResourceChargingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 资源计费说明Controller
 *
 * @author ruoyi
 * @date 2024-05-07
 */
@RestController
@RequestMapping("/cs/csResourceCharging")
public class CsResourceChargingController extends BaseController
{
    @Resource
    private ICsResourceChargingService csResourceChargingService;

    /**
     * 查询资源计费说明列表
     */
    @PreAuthorize("@ss.hasPermi('cs:csResourceCharging:list')")
    @GetMapping("/list")
    public TableDataInfo list(CsResourceCharging csResourceCharging)
    {
        startPage();
        csResourceCharging.setDelFlag("0");
        List<CsResourceCharging> list = csResourceChargingService.selectCsResourceChargingList(csResourceCharging);
        return getDataTable(list);
    }

    /**
     * 导出资源计费说明列表
     */
    @PreAuthorize("@ss.hasPermi('cs:csResourceCharging:export')")
    @Log(title = "资源计费说明", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CsResourceCharging csResourceCharging)
    {
        List<CsResourceCharging> list = csResourceChargingService.selectCsResourceChargingList(csResourceCharging);
        ExcelUtil<CsResourceCharging> util = new ExcelUtil<CsResourceCharging>(CsResourceCharging.class);
        util.exportExcel(response, list, "资源计费说明数据");
    }

    /**
     * 获取资源计费说明详细信息
     */
    @PreAuthorize("@ss.hasPermi('cs:csResourceCharging:query')")
    @GetMapping(value = "/{resourceChargingId}")
    public AjaxResult getInfo(@PathVariable("resourceChargingId") String resourceChargingId)
    {
        return AjaxResult.success(csResourceChargingService.selectCsResourceChargingByResourceChargingId(resourceChargingId));
    }

    /**
     * 新增资源计费说明
     */
    @PreAuthorize("@ss.hasPermi('cs:csResourceCharging:add')")
    @Log(title = "资源计费说明", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CsResourceCharging csResourceCharging)
    {
        return toAjax(csResourceChargingService.insertCsResourceCharging(csResourceCharging));
    }

    /**
     * 修改资源计费说明
     */
    @PreAuthorize("@ss.hasPermi('cs:csResourceCharging:edit')")
    @Log(title = "资源计费说明", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CsResourceCharging csResourceCharging)
    {
        return toAjax(csResourceChargingService.updateCsResourceCharging(csResourceCharging));
    }

    /**
     * 删除资源计费说明
     */
    @PreAuthorize("@ss.hasPermi('cs:csResourceCharging:remove')")
    @Log(title = "资源计费说明", businessType = BusinessType.DELETE)
	@DeleteMapping("/{resourceChargingIds}")
    public AjaxResult remove(@PathVariable String[] resourceChargingIds)
    {
        return toAjax(csResourceChargingService.deleteCsResourceChargingByResourceChargingIds(resourceChargingIds));
    }
}
