package com.fs.hisStore.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.hisStore.domain.FsStoreShopScrm;
import com.fs.hisStore.service.IFsStoreShopScrmService;
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 2022-03-15
 */
@RestController
@RequestMapping("/store/store/storeShop")
public class FsStoreShopScrmController extends BaseController
{
    @Autowired
    private IFsStoreShopScrmService fsStoreShopService;

    /**
     * 查询门店自提列表
     */
    @PreAuthorize("@ss.hasPermi('store:storeShop:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsStoreShopScrm fsStoreShop)
    {
        startPage();
        List<FsStoreShopScrm> list = fsStoreShopService.selectFsStoreShopList(fsStoreShop);
        return getDataTable(list);
    }

    /**
     * 导出门店自提列表
     */
    @PreAuthorize("@ss.hasPermi('store:storeShop:export')")
    @Log(title = "门店自提", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsStoreShopScrm fsStoreShop)
    {
        List<FsStoreShopScrm> list = fsStoreShopService.selectFsStoreShopList(fsStoreShop);
        ExcelUtil<FsStoreShopScrm> util = new ExcelUtil<FsStoreShopScrm>(FsStoreShopScrm.class);
        return util.exportExcel(list, "storeShop");
    }

    /**
     * 获取门店自提详细信息
     */
    @PreAuthorize("@ss.hasPermi('store:storeShop:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsStoreShopService.selectFsStoreShopById(id));
    }

    /**
     * 新增门店自提
     */
    @PreAuthorize("@ss.hasPermi('store:storeShop:add')")
    @Log(title = "门店自提", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsStoreShopScrm fsStoreShop)
    {
        return toAjax(fsStoreShopService.insertFsStoreShop(fsStoreShop));
    }

    /**
     * 修改门店自提
     */
    @PreAuthorize("@ss.hasPermi('store:storeShop:edit')")
    @Log(title = "门店自提", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsStoreShopScrm fsStoreShop)
    {
        return toAjax(fsStoreShopService.updateFsStoreShop(fsStoreShop));
    }

    /**
     * 删除门店自提
     */
    @PreAuthorize("@ss.hasPermi('store:storeShop:remove')")
    @Log(title = "门店自提", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsStoreShopService.deleteFsStoreShopByIds(ids));
    }
}
