package com.xingxi.api.controller;

import com.xingxi.api.common.BaseApiController;
import com.xingxi.api.model.*;
import com.xingxi.api.service.ProdServiceI;
import com.xingxi.common.enums.EDelFlag;
import com.xingxi.common.enums.ERoleKey;
import com.xingxi.master.product.domain.*;
import com.xingxi.master.product.service.IProdAttrService;
import com.xingxi.master.product.service.IProdPicService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/homepage")
public class ProdApiController extends BaseApiController {

    @Autowired
    private ProdServiceI prodService;

    @PostMapping("/prods")
    public MercProdListResponse getProdList(@Valid @RequestBody MercProdRequest request) {

        List<MercProdResponse> prodList = prodService.selectMercProdList(request);

        return new MercProdListResponse(prodList);
    }

    @PostMapping("/prodDetail")
    public MercProdResponse getProdDetail(@Valid @RequestBody MercProdRequest request) {

        return prodService.selectMercProdById(request.getMercProdId());

    }
}
