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.FsUserExtract;
import com.fs.his.param.FsUserExtractParam;
import com.fs.his.service.IFsUserExtractService;
import com.fs.his.vo.FsUserExtractVO;
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-06-25
 */
@RestController
@RequestMapping("/his/userExtract")
public class FsUserExtractController extends BaseController
{
    @Autowired
    private IFsUserExtractService fsUserExtractService;

    /**
     * 查询用户提现管理列表
     */
    @PreAuthorize("@ss.hasPermi('his:userExtract:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsUserExtractParam fsUserExtract)
    {
        startPage();
        List<FsUserExtractVO> list = fsUserExtractService.selectFsUserExtractListVO(fsUserExtract);
        return getDataTable(list);
    }

    /**
     * 导出用户提现管理列表
     */
    @PreAuthorize("@ss.hasPermi('his:userExtract:export')")
    @Log(title = "用户提现管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsUserExtract fsUserExtract)
    {
        List<FsUserExtract> list = fsUserExtractService.selectFsUserExtractList(fsUserExtract);
        ExcelUtil<FsUserExtract> util = new ExcelUtil<FsUserExtract>(FsUserExtract.class);
        return util.exportExcel(list, "用户提现管理数据");
    }

    /**
     * 获取用户提现管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('his:userExtract:query')")
    @GetMapping(value = "/{extractId}")
    public AjaxResult getInfo(@PathVariable("extractId") String extractId)
    {
        return AjaxResult.success(fsUserExtractService.selectFsUserExtractByExtractId(extractId));
    }

    /**
     * 新增用户提现管理
     */
    @PreAuthorize("@ss.hasPermi('his:userExtract:add')")
    @Log(title = "用户提现管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsUserExtract fsUserExtract)
    {
        return toAjax(fsUserExtractService.insertFsUserExtract(fsUserExtract));
    }

    /**
     * 审核
     */
    @PreAuthorize("@ss.hasPermi('his:userExtract:edit')")
    @Log(title = "审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsUserExtract fsUserExtract)
    {
        return toAjax(fsUserExtractService.updateFsUserExtract(fsUserExtract));
    }

    /**
     * 删除用户提现管理
     */
    @PreAuthorize("@ss.hasPermi('his:userExtract:remove')")
    @Log(title = "用户提现管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{extractIds}")
    public AjaxResult remove(@PathVariable String[] extractIds)
    {
        return toAjax(fsUserExtractService.deleteFsUserExtractByExtractIds(extractIds));
    }
}
