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.ParseUtils;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.hisStore.param.FsStoreProductRelationParam;
import com.fs.hisStore.service.IFsStoreProductRelationScrmService;
import com.fs.hisStore.vo.FsStoreProductRelationQueryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/store/store/storeProductRelation")
public class FsStoreProductRelationScrmController extends BaseController
{
    @Autowired
    private IFsStoreProductRelationScrmService 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, "商品浏览记录");
    }


}
