package com.srs.web.controller.stureg;

import java.util.List;
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.srs.common.annotation.Log;
import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.enums.BusinessType;
import com.srs.comprehensive.domain.SrsPayment;
import com.srs.comprehensive.service.ISrsPaymentService;
import com.srs.common.utils.poi.ExcelUtil;
import com.srs.common.core.page.TableDataInfo;

/**
 * 费用表Controller
 * 
 * @author srs
 * @date 2023-07-24
 */
@RestController
@RequestMapping("/system/payment")
public class SrsPaymentController extends BaseController
{
    @Autowired
    private ISrsPaymentService srsPaymentService;

    /**
     * 查询费用表列表
     */
//    @PreAuthorize("@ss.hasPermi('system:payment:list')")
    @GetMapping("/list")
    public TableDataInfo list(SrsPayment srsPayment)
    {
        startPage();
        List<SrsPayment> list = srsPaymentService.selectSrsPaymentList(srsPayment);
        return getDataTable(list);
    }

    /**
     * 导出费用表列表
     */
//    @PreAuthorize("@ss.hasPermi('system:payment:export')")
    @Log(title = "费用表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SrsPayment srsPayment)
    {
        List<SrsPayment> list = srsPaymentService.selectSrsPaymentList(srsPayment);
        ExcelUtil<SrsPayment> util = new ExcelUtil<SrsPayment>(SrsPayment.class);
        util.exportExcel(response, list, "费用表数据");
    }

    /**
     * 获取费用表详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:payment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(srsPaymentService.selectSrsPaymentById(id));
    }

    /**
     * 新增费用表
     */
//    @PreAuthorize("@ss.hasPermi('system:payment:add')")
    @Log(title = "费用表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SrsPayment srsPayment)
    {
        return toAjax(srsPaymentService.insertSrsPayment(srsPayment));
    }

    /**
     * 修改费用表
     */
//    @PreAuthorize("@ss.hasPermi('system:payment:edit')")
    @Log(title = "费用表", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody SrsPayment srsPayment)
    {
        return toAjax(srsPaymentService.updateSrsPayment(srsPayment));
    }

    /**
     * 删除费用表
     */
//    @PreAuthorize("@ss.hasPermi('system:payment:remove')")
    @Log(title = "费用表", businessType = BusinessType.DELETE)
	@PostMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(srsPaymentService.deleteSrsPaymentByIds(ids));
    }
}
