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

/**
 * 售后子Controller
 * 
 * @author fs
 * @date 2022-03-15
 */
@RestController
@RequestMapping("/store/storeAfterSalesItem")
public class FsStoreAfterSalesItemController extends BaseController
{
    @Autowired
    private IFsStoreAfterSalesItemService fsStoreAfterSalesItemService;

    /**
     * 查询售后子列表
     */
    @PreAuthorize("@ss.hasPermi('store:storeAfterSalesItem:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsStoreAfterSalesItem fsStoreAfterSalesItem)
    {
        startPage();
        List<FsStoreAfterSalesItem> list = fsStoreAfterSalesItemService.selectFsStoreAfterSalesItemList(fsStoreAfterSalesItem);
        return getDataTable(list);
    }

    /**
     * 导出售后子列表
     */
    @PreAuthorize("@ss.hasPermi('store:storeAfterSalesItem:export')")
    @Log(title = "售后子", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsStoreAfterSalesItem fsStoreAfterSalesItem)
    {
        List<FsStoreAfterSalesItem> list = fsStoreAfterSalesItemService.selectFsStoreAfterSalesItemList(fsStoreAfterSalesItem);
        ExcelUtil<FsStoreAfterSalesItem> util = new ExcelUtil<FsStoreAfterSalesItem>(FsStoreAfterSalesItem.class);
        return util.exportExcel(list, "storeAfterSalesItem");
    }

    /**
     * 获取售后子详细信息
     */
    @PreAuthorize("@ss.hasPermi('store:storeAfterSalesItem:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsStoreAfterSalesItemService.selectFsStoreAfterSalesItemById(id));
    }

    /**
     * 新增售后子
     */
    @PreAuthorize("@ss.hasPermi('store:storeAfterSalesItem:add')")
    @Log(title = "售后子", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsStoreAfterSalesItem fsStoreAfterSalesItem)
    {
        return toAjax(fsStoreAfterSalesItemService.insertFsStoreAfterSalesItem(fsStoreAfterSalesItem));
    }

    /**
     * 修改售后子
     */
    @PreAuthorize("@ss.hasPermi('store:storeAfterSalesItem:edit')")
    @Log(title = "售后子", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsStoreAfterSalesItem fsStoreAfterSalesItem)
    {
        return toAjax(fsStoreAfterSalesItemService.updateFsStoreAfterSalesItem(fsStoreAfterSalesItem));
    }

    /**
     * 删除售后子
     */
    @PreAuthorize("@ss.hasPermi('store:storeAfterSalesItem:remove')")
    @Log(title = "售后子", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsStoreAfterSalesItemService.deleteFsStoreAfterSalesItemByIds(ids));
    }
}
