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

/**
 * 商品属性值Controller
 * 
 * @author fs
 * @date 2022-03-15
 */
@RestController
@RequestMapping("/store/storeProductAttrValue")
public class FsStoreProductAttrValueController extends BaseController
{
    @Autowired
    private IFsStoreProductAttrValueService fsStoreProductAttrValueService;

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

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

    /**
     * 修改商品属性值
     */
    @PreAuthorize("@ss.hasPermi('store:storeProductAttrValue:edit')")
    @Log(title = "商品属性值", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsStoreProductAttrValue 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));
    }


}
