package com.fjhx.sale.controller.sample;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.fjhx.common.constant.SourceConstant;
import com.fjhx.sale.entity.sample.dto.SampleProductDto;
import com.fjhx.sale.entity.sample.dto.SampleProductSelectDto;
import com.fjhx.sale.entity.sample.vo.SampleProductVo;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.BaseSelectDto;
import com.fjhx.sale.service.sample.SampleProductService;
import org.springframework.beans.factory.annotation.Autowired;


/**
 * <p>
 * 样品单-产品 前端控制器
 * </p>
 *
 * @author 
 * @since 2023-05-05
 */
@RestController
@RequestMapping("/sampleProduct")
public class SampleProductController {

    @Autowired
    private SampleProductService sampleProductService;

    /**
     * 样品单-产品分页
     */
    @PostMapping("/page")
    public Page<SampleProductVo> page(@RequestBody SampleProductSelectDto dto) {
        return sampleProductService.getPage(dto);
    }

    /**
     * 样品单-产品明细
     */
    @PostMapping("/detail")
    public SampleProductVo detail(@RequestBody BaseSelectDto dto) {
        return sampleProductService.detail(dto.getId());
    }

    /**
     * 样品单-产品新增
     */
    @PostMapping("/add")
    public void add(@RequestBody SampleProductDto sampleProductDto) {
        sampleProductService.add(sampleProductDto);
    }

    /**
     * 样品单-产品编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody SampleProductDto sampleProductDto) {
        sampleProductService.edit(sampleProductDto);
    }

    /**
     * 样品单-产品删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        sampleProductService.delete(dto.getId());
    }

}
