package com.fs.store.controller;

import java.util.List;

import com.fs.common.utils.ParseUtils;
import com.fs.store.param.FsStoreProductRelationParam;
import com.fs.store.vo.FsStoreProductRelationQueryVO;
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.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.service.IFsStoreProductRelationService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;


@RestController
@RequestMapping("/store/storeProductRelation")
public class FsStoreProductRelationController extends BaseController
{
    @Autowired
    private IFsStoreProductRelationService fsStoreProductRelationService;

    @PreAuthorize("@ss.hasPermi('store:storeProductRelation:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsStoreProductRelationParam param)
    {
        startPage();
        List<FsStoreProductRelationQueryVO> list = fsStoreProductRelationService.selectFsStoreProductRelationListVO(param);
        for (FsStoreProductRelationQueryVO vo : list){
            vo.setPhone(ParseUtils.parsePhone(vo.getPhone()));
        }
        return getDataTable(list);
    }

    /**
     * 导出商品点赞和收藏列表
     */
    @PreAuthorize("@ss.hasPermi('store:storeProductRelation:export')")
    @Log(title = "商品浏览记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsStoreProductRelationParam param)
    {
        List<FsStoreProductRelationQueryVO> list = fsStoreProductRelationService.selectFsStoreProductRelationListVO(param);
        for (FsStoreProductRelationQueryVO vo : list){
            vo.setPhone(ParseUtils.parsePhone(vo.getPhone()));
        }
        ExcelUtil<FsStoreProductRelationQueryVO> util = new ExcelUtil<FsStoreProductRelationQueryVO>(FsStoreProductRelationQueryVO.class);
        return util.exportExcel(list, "商品浏览记录");
    }


}
