package com.fs.store.controller;

import java.util.List;
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.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.store.domain.FsStoreShop;
import com.fs.store.service.IFsStoreShopService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 门店自提Controller
 * 
 * @author fs
 * @date 2022-03-15
 */
@RestController
@RequestMapping("/store/storeShop")
public class FsStoreShopController extends BaseController
{
    @Autowired
    private IFsStoreShopService fsStoreShopService;

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

    /**
     * 导出门店自提列表
     */
    @PreAuthorize("@ss.hasPermi('store:storeShop:export')")
    @Log(title = "门店自提", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsStoreShop fsStoreShop)
    {
        List<FsStoreShop> list = fsStoreShopService.selectFsStoreShopList(fsStoreShop);
        ExcelUtil<FsStoreShop> util = new ExcelUtil<FsStoreShop>(FsStoreShop.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 FsStoreShop fsStoreShop)
    {
        return toAjax(fsStoreShopService.insertFsStoreShop(fsStoreShop));
    }

    /**
     * 修改门店自提
     */
    @PreAuthorize("@ss.hasPermi('store:storeShop:edit')")
    @Log(title = "门店自提", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsStoreShop 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));
    }
}
