package org.dromara.app;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wzj.soopin.goods.convert.ProductConvert;
import com.wzj.soopin.goods.domain.bo.ProductBo;
import com.wzj.soopin.goods.domain.entity.Product;
import com.wzj.soopin.goods.domain.vo.ProductVO;
import com.wzj.soopin.goods.service.ProductService;
import com.wzj.soopin.goods.service.impl.ProductServiceImpl;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.springframework.web.bind.annotation.*;

@Tag(name ="商品信息接口列表")
@RestController
@RequestMapping("/app/product")
@RequiredArgsConstructor
public class AppProductController {

    private final ProductServiceImpl service;
    private final ProductConvert convert;
    private final ProductService productService;

    @Tag(name = "查询商品信息列表")
    @PostMapping("page")
    public R<IPage<ProductVO>> page(@RequestBody ProductBo query, Page<Product> page) {
        IPage<ProductVO> resultPage = service.getProduct(page, query);
        return R.ok(resultPage);
    }

    @Tag(name ="获取商品信息详细信息")
    @GetMapping(value = "/{id}")
    public R getInfo(@PathVariable("id") Long id) {
        return R.ok(service.selectById(id));
    }

}
