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

/**
 * 产品浏览分析Controller
 * 
 * @author fs
 * @date 2022-03-15
 */
@RestController
@RequestMapping("/store/storeVisit")
public class FsStoreVisitController extends BaseController
{
    @Autowired
    private IFsStoreVisitService fsStoreVisitService;

    /**
     * 查询产品浏览分析列表
     */
    @PreAuthorize("@ss.hasPermi('store:storeVisit:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsStoreVisit fsStoreVisit)
    {
        startPage();
        List<FsStoreVisit> list = fsStoreVisitService.selectFsStoreVisitList(fsStoreVisit);
        return getDataTable(list);
    }

    /**
     * 导出产品浏览分析列表
     */
    @PreAuthorize("@ss.hasPermi('store:storeVisit:export')")
    @Log(title = "产品浏览分析", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsStoreVisit fsStoreVisit)
    {
        List<FsStoreVisit> list = fsStoreVisitService.selectFsStoreVisitList(fsStoreVisit);
        ExcelUtil<FsStoreVisit> util = new ExcelUtil<FsStoreVisit>(FsStoreVisit.class);
        return util.exportExcel(list, "storeVisit");
    }

    /**
     * 获取产品浏览分析详细信息
     */
    @PreAuthorize("@ss.hasPermi('store:storeVisit:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsStoreVisitService.selectFsStoreVisitById(id));
    }

    /**
     * 新增产品浏览分析
     */
    @PreAuthorize("@ss.hasPermi('store:storeVisit:add')")
    @Log(title = "产品浏览分析", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsStoreVisit fsStoreVisit)
    {
        return toAjax(fsStoreVisitService.insertFsStoreVisit(fsStoreVisit));
    }

    /**
     * 修改产品浏览分析
     */
    @PreAuthorize("@ss.hasPermi('store:storeVisit:edit')")
    @Log(title = "产品浏览分析", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsStoreVisit fsStoreVisit)
    {
        return toAjax(fsStoreVisitService.updateFsStoreVisit(fsStoreVisit));
    }

    /**
     * 删除产品浏览分析
     */
    @PreAuthorize("@ss.hasPermi('store:storeVisit:remove')")
    @Log(title = "产品浏览分析", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsStoreVisitService.deleteFsStoreVisitByIds(ids));
    }
}
