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.FsStoreShopStaff;
import com.fs.store.service.IFsStoreShopStaffService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 门店店员Controller
 * 
 * @author fs
 * @date 2022-03-15
 */
@RestController
@RequestMapping("/store/storeShopStaff")
public class FsStoreShopStaffController extends BaseController
{
    @Autowired
    private IFsStoreShopStaffService fsStoreShopStaffService;

    /**
     * 查询门店店员列表
     */
    @PreAuthorize("@ss.hasPermi('store:storeShopStaff:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsStoreShopStaff fsStoreShopStaff)
    {
        startPage();
        List<FsStoreShopStaff> list = fsStoreShopStaffService.selectFsStoreShopStaffList(fsStoreShopStaff);
        return getDataTable(list);
    }

    /**
     * 导出门店店员列表
     */
    @PreAuthorize("@ss.hasPermi('store:storeShopStaff:export')")
    @Log(title = "门店店员", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsStoreShopStaff fsStoreShopStaff)
    {
        List<FsStoreShopStaff> list = fsStoreShopStaffService.selectFsStoreShopStaffList(fsStoreShopStaff);
        ExcelUtil<FsStoreShopStaff> util = new ExcelUtil<FsStoreShopStaff>(FsStoreShopStaff.class);
        return util.exportExcel(list, "storeShopStaff");
    }

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

    /**
     * 新增门店店员
     */
    @PreAuthorize("@ss.hasPermi('store:storeShopStaff:add')")
    @Log(title = "门店店员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsStoreShopStaff fsStoreShopStaff)
    {
        return toAjax(fsStoreShopStaffService.insertFsStoreShopStaff(fsStoreShopStaff));
    }

    /**
     * 修改门店店员
     */
    @PreAuthorize("@ss.hasPermi('store:storeShopStaff:edit')")
    @Log(title = "门店店员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsStoreShopStaff fsStoreShopStaff)
    {
        return toAjax(fsStoreShopStaffService.updateFsStoreShopStaff(fsStoreShopStaff));
    }

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