package com.ylx.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ylx.common.core.domain.R;
import com.ylx.massage.domain.dto.OptionDTO;
import com.ylx.massage.domain.dto.ServiceOptionDTO;
import com.ylx.massage.domain.vo.ProductOptionVO;
import com.ylx.massage.domain.vo.ProductServiceOptionVO;
import com.ylx.massage.service.ProductSelectionService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/api/products") // 假设的基础路径
public class ApiProductSelectionController {

    @Resource
    private ProductSelectionService productSelectionService;

    @ApiOperation("查询商品列表（支持服务与实物）")
    @PostMapping(value = "/options")
    public R<Page<ProductOptionVO>> optionsPage( @RequestBody OptionDTO dto) {
        Page<ProductOptionVO> pageData = this.productSelectionService.optionsPage(dto);
        return R.ok(pageData);
    }

    @ApiOperation("获取服务商品列表")
    @PostMapping(value = "/options/service")
    public R<Page<ProductServiceOptionVO>> queryServicePage(@RequestBody ServiceOptionDTO dto) {
        Page<ProductServiceOptionVO> pageData = this.productSelectionService.serviceOptionsPage(dto);
        return R.ok(pageData);
    }

}
