package com.fjhx.item.controller.product;

import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.item.entity.product.vo.ProductSpuVo;
import com.fjhx.item.entity.product.dto.ProductSpuSelectDto;
import com.fjhx.item.entity.product.dto.ProductSpuDto;
import com.ruoyi.common.core.domain.BaseSelectDto;
import com.fjhx.item.service.product.ProductSpuService;
import org.springframework.beans.factory.annotation.Autowired;


/**
 * <p>
 * 产品spu 前端控制器
 * </p>
 *
 * @author 
 * @since 2023-04-11
 */
@RestController
@RequestMapping("/productSpu")
public class ProductSpuController {

    @Autowired
    private ProductSpuService productSpuService;

    /**
     * 产品spu分页
     */
    @PostMapping("/page")
    public Page<ProductSpuVo> page(@RequestBody ProductSpuSelectDto dto) {
        return productSpuService.getPage(dto);
    }

    /**
     * 产品spu明细
     */
    @PostMapping("/detail")
    public ProductSpuVo detail(@RequestBody BaseSelectDto dto) {
        return productSpuService.detail(dto.getId());
    }

    /**
     * 产品spu新增
     */
    @PostMapping("/add")
    public void add(@RequestBody ProductSpuDto productSpuDto) {
        productSpuService.add(productSpuDto);
    }

    /**
     * 产品spu编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody ProductSpuDto productSpuDto) {
        productSpuService.edit(productSpuDto);
    }

    /**
     * 产品spu删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        productSpuService.delete(dto.getId());
    }

}
