package com.fjhx.controller.product;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.entity.product.ProductSpu;
import com.fjhx.params.product.ProductSpuVo;
import com.fjhx.service.product.ProductSpuService;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
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 java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-11-25
 */
@RestController
@RequestMapping("/productSpu")
public class ProductSpuController {

    @Autowired
    private ProductSpuService productSpuService;

    @PostMapping("/page")
    public R page(@RequestBody Map<String, Object> condition){
        Page<ProductSpu> result = productSpuService.getPage(condition);
        return R.success(result);
    }

    @PostMapping("/add")
    public R add(@RequestBody ProductSpuVo productSpuVo){
        productSpuService.add(productSpuVo);
        return R.success();
    }

    @PostMapping("/edit")
    public R edit(@RequestBody ProductSpuVo productSpuVo) {
        productSpuService.edit(productSpuVo);
        return R.success();
    }

    @PostMapping("/delete")
    public R delete(@RequestBody ProductSpuVo productSpuVo) {
        productSpuService.delete(productSpuVo);
        return R.success();
    }

}

