package com.fs.his.controller;

import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.his.domain.FsUserRecharge;
import com.fs.his.param.FsUserRechargeParam;
import com.fs.his.service.IFsUserRechargeService;
import com.fs.his.vo.FsUserRechargeListVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 会员充值Controller
 *
 * @author fs
 * @date 2023-11-02
 */
@RestController
@RequestMapping("/his/userRecharge")
public class FsUserRechargeController extends BaseController
{
    @Autowired
    private IFsUserRechargeService fsUserRechargeService;

    /**
     * 查询会员充值列表
     */
    @PreAuthorize("@ss.hasPermi('his:userRecharge:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsUserRechargeParam fsUserRecharge)
    {
        startPage();
        List<FsUserRechargeListVO> list = fsUserRechargeService.selectFsUserRechargeListVO(fsUserRecharge);
        return getDataTable(list);
    }

    /**
     * 导出会员充值列表
     */
    @PreAuthorize("@ss.hasPermi('his:userRecharge:export')")
    @Log(title = "会员充值", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsUserRecharge fsUserRecharge)
    {
        List<FsUserRecharge> list = fsUserRechargeService.selectFsUserRechargeList(fsUserRecharge);
        ExcelUtil<FsUserRecharge> util = new ExcelUtil<FsUserRecharge>(FsUserRecharge.class);
        return util.exportExcel(list, "会员充值数据");
    }

    /**
     * 获取会员充值详细信息
     */
    @PreAuthorize("@ss.hasPermi('his:userRecharge:query')")
    @GetMapping(value = "/{rechargeId}")
    public AjaxResult getInfo(@PathVariable("rechargeId") Long rechargeId)
    {
        return AjaxResult.success(fsUserRechargeService.selectFsUserRechargeByRechargeId(rechargeId));
    }

    /**
     * 新增会员充值
     */
    @PreAuthorize("@ss.hasPermi('his:userRecharge:add')")
    @Log(title = "会员充值", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsUserRecharge fsUserRecharge)
    {
        return toAjax(fsUserRechargeService.insertFsUserRecharge(fsUserRecharge));
    }

    /**
     * 修改会员充值
     */
    @PreAuthorize("@ss.hasPermi('his:userRecharge:edit')")
    @Log(title = "会员充值", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsUserRecharge fsUserRecharge)
    {
        return toAjax(fsUserRechargeService.updateFsUserRecharge(fsUserRecharge));
    }

    /**
     * 删除会员充值
     */
    @PreAuthorize("@ss.hasPermi('his:userRecharge:remove')")
    @Log(title = "会员充值", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rechargeIds}")
    public AjaxResult remove(@PathVariable Long[] rechargeIds)
    {
        return toAjax(fsUserRechargeService.deleteFsUserRechargeByRechargeIds(rechargeIds));
    }
}
