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.FsStoreProductAttrValueScrm;
import com.fs.hisStore.service.IFsStoreProductAttrValueScrmService;
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/storeProductAttrValue")
public class FsStoreProductAttrValueScrmController extends BaseController
{
    @Autowired
    private IFsStoreProductAttrValueScrmService fsStoreProductAttrValueService;

    /**
     * 查询商品属性值列表
     */
    @PreAuthorize("@ss.hasPermi('store:storeProductAttrValue:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsStoreProductAttrValueScrm fsStoreProductAttrValue)
    {
        startPage();
        List<FsStoreProductAttrValueScrm> list = fsStoreProductAttrValueService.selectFsStoreProductAttrValueList(fsStoreProductAttrValue);
        return getDataTable(list);
    }

    /**
     * 导出商品属性值列表
     */
    @PreAuthorize("@ss.hasPermi('store:storeProductAttrValue:export')")
    @Log(title = "商品属性值", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsStoreProductAttrValueScrm fsStoreProductAttrValue)
    {
        List<FsStoreProductAttrValueScrm> list = fsStoreProductAttrValueService.selectFsStoreProductAttrValueList(fsStoreProductAttrValue);
        ExcelUtil<FsStoreProductAttrValueScrm> util = new ExcelUtil<FsStoreProductAttrValueScrm>(FsStoreProductAttrValueScrm.class);
        return util.exportExcel(list, "storeProductAttrValue");
    }

    /**
     * 获取商品属性值详细信息
     */
    @PreAuthorize("@ss.hasPermi('store:storeProductAttrValue:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsStoreProductAttrValueService.selectFsStoreProductAttrValueById(id));
    }

    /**
     * 新增商品属性值
     */
    @PreAuthorize("@ss.hasPermi('store:storeProductAttrValue:add')")
    @Log(title = "商品属性值", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsStoreProductAttrValueScrm fsStoreProductAttrValue)
    {
        return toAjax(fsStoreProductAttrValueService.insertFsStoreProductAttrValue(fsStoreProductAttrValue));
    }

    /**
     * 修改商品属性值
     */
    @PreAuthorize("@ss.hasPermi('store:storeProductAttrValue:edit')")
    @Log(title = "商品属性值", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsStoreProductAttrValueScrm fsStoreProductAttrValue)
    {
        return toAjax(fsStoreProductAttrValueService.updateFsStoreProductAttrValue(fsStoreProductAttrValue));
    }

    /**
     * 删除商品属性值
     */
    @PreAuthorize("@ss.hasPermi('store:storeProductAttrValue:remove')")
    @Log(title = "商品属性值", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsStoreProductAttrValueService.deleteFsStoreProductAttrValueByIds(ids));
    }


}
