package com.fjhx.purchase.controller.arrival;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.common.constant.SourceConstant;
import com.fjhx.purchase.entity.arrival.dto.ArrivalDto;
import com.fjhx.purchase.entity.arrival.dto.ArrivalSelectDto;
import com.fjhx.purchase.entity.arrival.po.Arrival;
import com.fjhx.purchase.entity.arrival.vo.ArrivalVo;
import com.fjhx.purchase.service.arrival.ArrivalService;
import com.ruoyi.common.core.domain.BaseSelectDto;
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;


/**
 * <p>
 * 到货 前端控制器
 * </p>
 *
 * @author
 * @since 2023-04-07
 */
@DS(SourceConstant.PURCHASE)
@RestController
@RequestMapping("/arrival")
public class ArrivalController {

    @Autowired
    private ArrivalService arrivalService;

    /**
     * 到货分页
     */
    @PostMapping("/page")
    public Page<ArrivalVo> page(@RequestBody ArrivalSelectDto dto) {
        return arrivalService.getPage(dto);
    }

    /**
     * 到货明细
     */
    @PostMapping("/detail")
    public ArrivalVo detail(@RequestBody BaseSelectDto dto) {
        return arrivalService.detail(dto.getId());
    }

    /**
     * 到货新增
     */
    @PostMapping("/add")
    public void add(@RequestBody Arrival arrival) {
        arrivalService.add(arrival);
    }

    /**
     * 到货新增 维多利亚
     */
    @PostMapping("/addByWdly")
    public void addByWdly(@RequestBody ArrivalDto arrival) {
        arrivalService.addByWdly(arrival);
    }

    /**
     * 到货编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody ArrivalDto arrivalDto) {
        arrivalService.edit(arrivalDto);
    }

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

    /**
     * 根据发货id获取本次发货的到货信息
     */
    @PostMapping("/arrivalInfo")
    public ArrivalVo arrivalInfo(@RequestBody ArrivalDto dto) {
        return arrivalService.arrivalInfo(dto.getDeliverGoodsId());
    }

}
