package com.fjhx.purchase.controller.sales;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.fjhx.common.constant.SourceConstant;
import com.fjhx.purchase.entity.sales.po.SalesReturn;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.purchase.entity.sales.vo.SalesReturnVo;
import com.fjhx.purchase.entity.sales.dto.SalesReturnSelectDto;
import com.fjhx.purchase.entity.sales.dto.SalesReturnDto;
import com.ruoyi.common.core.domain.BaseSelectDto;
import com.fjhx.purchase.service.sales.SalesReturnService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;


/**
 * <p>
 * 退货 前端控制器
 * </p>
 *
 * @author 
 * @since 2023-04-11
 */
@DS(SourceConstant.PURCHASE)
@RestController
@RequestMapping("/salesReturn")
public class SalesReturnController {

    @Autowired
    private SalesReturnService salesReturnService;

    /**
     * 退货分页
     */
    @PostMapping("/page")
    public Page<SalesReturnVo> page(@RequestBody SalesReturnSelectDto dto) {
        return salesReturnService.getPage(dto);
    }

    /**
     * 退货明细
     */
    @PostMapping("/detail")
    public SalesReturnVo detail(@RequestBody BaseSelectDto dto) {
        return salesReturnService.detail(dto.getId());
    }

    /**
     * 退货新增
     */
    @PostMapping("/add")
    public void add(@RequestBody SalesReturnDto salesReturnDto) {
        salesReturnService.add(salesReturnDto);
    }

    /**
     * 退货编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody SalesReturnDto salesReturnDto) {
        salesReturnService.edit(salesReturnDto);
    }

    /**
     * 退货删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        salesReturnService.delete(dto.getId());
    }

    /**
     * 根据供应商查询退货列表
     */
    @GetMapping("/getBySupplyId")
    public List<SalesReturn> getBySupplyId(@RequestParam("supplyId") String supplyId) {
        return salesReturnService.getListBySupplyId(supplyId);
    }

}
