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

/**
 * 商品详情Controller
 * 
 * @author fs
 * @date 2022-03-15
 */
@RestController
@RequestMapping("/store/storeProductDetails")
public class FsStoreProductDetailsController extends BaseController
{
    @Autowired
    private IFsStoreProductDetailsService fsStoreProductDetailsService;

    /**
     * 查询商品详情列表
     */
    @PreAuthorize("@ss.hasPermi('store:storeProductDetails:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsStoreProductDetails fsStoreProductDetails)
    {
        startPage();
        List<FsStoreProductDetails> list = fsStoreProductDetailsService.selectFsStoreProductDetailsList(fsStoreProductDetails);
        return getDataTable(list);
    }

    /**
     * 导出商品详情列表
     */
    @PreAuthorize("@ss.hasPermi('store:storeProductDetails:export')")
    @Log(title = "商品详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsStoreProductDetails fsStoreProductDetails)
    {
        List<FsStoreProductDetails> list = fsStoreProductDetailsService.selectFsStoreProductDetailsList(fsStoreProductDetails);
        ExcelUtil<FsStoreProductDetails> util = new ExcelUtil<FsStoreProductDetails>(FsStoreProductDetails.class);
        return util.exportExcel(list, "storeProductDetails");
    }

    /**
     * 获取商品详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('store:storeProductDetails:query')")
    @GetMapping(value = "/{detailsId}")
    public AjaxResult getInfo(@PathVariable("detailsId") Long detailsId)
    {
        return AjaxResult.success(fsStoreProductDetailsService.selectFsStoreProductDetailsById(detailsId));
    }

    /**
     * 新增商品详情
     */
    @PreAuthorize("@ss.hasPermi('store:storeProductDetails:add')")
    @Log(title = "商品详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsStoreProductDetails fsStoreProductDetails)
    {
        return toAjax(fsStoreProductDetailsService.insertFsStoreProductDetails(fsStoreProductDetails));
    }

    /**
     * 修改商品详情
     */
    @PreAuthorize("@ss.hasPermi('store:storeProductDetails:edit')")
    @Log(title = "商品详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsStoreProductDetails fsStoreProductDetails)
    {
        return toAjax(fsStoreProductDetailsService.updateFsStoreProductDetails(fsStoreProductDetails));
    }

    /**
     * 删除商品详情
     */
    @PreAuthorize("@ss.hasPermi('store:storeProductDetails:remove')")
    @Log(title = "商品详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{detailsIds}")
    public AjaxResult remove(@PathVariable Long[] detailsIds)
    {
        return toAjax(fsStoreProductDetailsService.deleteFsStoreProductDetailsByIds(detailsIds));
    }
}
