package com.ruoyi.wx.web.controller;


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.framework.recovery.domain.RecBrand;
import com.ruoyi.wx.web.domain.vo.GoodsInfoVo;
import com.ruoyi.wx.web.service.IWxQuotationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 行情服务
 */
@Tag(name = "行情服务")
@RestController
@RequestMapping("/wx/quotation")
@Slf4j
public class WxQuotationController {

    @Autowired
    private IWxQuotationService quotationService;

    @Operation(summary = "行情页品牌内容")
    @GetMapping("/index")
    public AjaxResult getIndex() {
        try {
            List<RecBrand> brands = quotationService.getBrands();
            return AjaxResult.success(brands);
        } catch (Exception e) {
            return AjaxResult.error();
        }
    }

    @Operation(summary = "行情页左侧品牌型号")
    @GetMapping("/model/{id}")
    public AjaxResult getModel(@PathVariable("id") Long id) {
        try {
            List<RecBrand> brandSeries = quotationService.getBrandSeries(id);
            return AjaxResult.success(brandSeries);
        } catch (Exception e) {
            return AjaxResult.error();
        }
    }

    @Operation(summary = "右侧所有信息")
    @GetMapping("/info/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        try {
            List<GoodsInfoVo> goodsInfoVos = quotationService.getGoodsInfo(id);
            return AjaxResult.success(goodsInfoVos);
        } catch (Exception e) {
            return AjaxResult.error();
        }
    }
}
