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.FsStoreShopStaffScrm;
import com.fs.hisStore.service.IFsStoreShopStaffScrmService;
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/storeShopStaff")
public class FsStoreShopStaffScrmController extends BaseController
{
    @Autowired
    private IFsStoreShopStaffScrmService fsStoreShopStaffService;

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

    /**
     * 导出门店店员列表
     */
    @PreAuthorize("@ss.hasPermi('store:storeShopStaff:export')")
    @Log(title = "门店店员", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsStoreShopStaffScrm fsStoreShopStaff)
    {
        List<FsStoreShopStaffScrm> list = fsStoreShopStaffService.selectFsStoreShopStaffList(fsStoreShopStaff);
        ExcelUtil<FsStoreShopStaffScrm> util = new ExcelUtil<FsStoreShopStaffScrm>(FsStoreShopStaffScrm.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 FsStoreShopStaffScrm fsStoreShopStaff)
    {
        return toAjax(fsStoreShopStaffService.insertFsStoreShopStaff(fsStoreShopStaff));
    }

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