package com.fs.store.controller.store;

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.FsStoreExtract;
import com.fs.his.service.IFsStoreExtractService;
import com.fs.his.vo.FsStoreExtractVO;
import com.fs.store.utils.UserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 店铺提现管理Controller
 *
 * @author fs
 * @date 2023-06-25
 */
@RestController
@RequestMapping("/store/storeExtract")
public class FsStoreExtractController extends BaseController
{
    @Autowired
    private IFsStoreExtractService fsStoreExtractService;

    /**
     * 查询店铺提现管理列表
     */

    @GetMapping("/list")
    public TableDataInfo list(FsStoreExtract fsStoreExtract)
    {
        fsStoreExtract.setStoreId(UserUtil.getLoginUserStoreID());
        startPage();
        List<FsStoreExtractVO> list = fsStoreExtractService.selectFsStoreExtractListVO(fsStoreExtract);
        return getDataTable(list);
    }

    /**
     * 导出店铺提现管理列表
     */

    @Log(title = "店铺提现管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsStoreExtract fsStoreExtract)
    {
        fsStoreExtract.setStoreId(UserUtil.getLoginUserStoreID());
        List<FsStoreExtract> list = fsStoreExtractService.selectFsStoreExtractList(fsStoreExtract);
        ExcelUtil<FsStoreExtract> util = new ExcelUtil<FsStoreExtract>(FsStoreExtract.class);
        return util.exportExcel(list, "店铺提现管理数据");
    }

    /**
     * 获取店铺提现管理详细信息
     */

    @GetMapping(value = "/{extractId}")
    public AjaxResult getInfo(@PathVariable("extractId") String extractId)
    {
        return AjaxResult.success(fsStoreExtractService.selectFsStoreExtractByExtractId(extractId));
    }

    /**
     * 新增店铺提现
     */

    @Log(title = "店铺提现管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsStoreExtract fsStoreExtract)
    {
        fsStoreExtract.setStoreId(UserUtil.getLoginUserStoreID());
        return toAjax(fsStoreExtractService.insertFsStoreExtract(fsStoreExtract));
    }

    /**
     * 审核
     */

    @Log(title = "审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsStoreExtract fsStoreExtract)
    {
        fsStoreExtract.setStoreId(UserUtil.getLoginUserStoreID());
        return toAjax(fsStoreExtractService.updateFsStoreExtract(fsStoreExtract));
    }

    /**
     * 删除店铺提现管理
     */

    @Log(title = "店铺提现管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{extractIds}")
    public AjaxResult remove(@PathVariable String[] extractIds)
    {
        return toAjax(fsStoreExtractService.deleteFsStoreExtractByExtractIds(extractIds));
    }
}
