
package com.tmerclub.cloud.flow.controller.admin;

import com.tmerclub.cloud.api.auth.bo.UidInfoBO;
import com.tmerclub.cloud.api.auth.constant.SysTypeEnum;
import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.common.security.AuthUserContext;
import com.tmerclub.cloud.flow.dto.SingleProdTrendDTO;
import com.tmerclub.cloud.flow.service.ProductAnalyseService;
import com.tmerclub.cloud.flow.vo.SingleProdTrendVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
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 java.util.List;
import java.util.Objects;

/**
 * 流量分析—商品分析
 *
 * @author YXF
 * @date 2021-05-21 15:25:19
 */
@RestController
@RequestMapping("/mp/productAnalyse")
@Tag(name = "admin流量分析—商品分析")
public class ProductAnalyseController {

    @Autowired
    private ProductAnalyseService productAnalyseService;

    @GetMapping("/getSingleProdTrend")
    @Operation(summary = "获得单个商品趋势图")
    public ServerResponseEntity<List<SingleProdTrendVO>> getSingleProdTrend(SingleProdTrendDTO singleProdTrendDTO) {
        UidInfoBO uidInfoBO = AuthUserContext.get();
        if (Objects.equals(SysTypeEnum.MULTISHOP.value(), uidInfoBO.getSysType())) {
            singleProdTrendDTO.setShopId(uidInfoBO.getTenantId());
        }
        List<SingleProdTrendVO> singleProdTend = productAnalyseService.getSingleProdTend(singleProdTrendDTO);
        return ServerResponseEntity.success(singleProdTend);
    }
}
