package com.fjhx.purchase.controller.subscribe;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.fjhx.common.constant.SourceConstant;
import com.fjhx.purchase.entity.subscribe.dto.SubscribeDetailDto;
import com.fjhx.purchase.entity.subscribe.dto.SubscribeDetailSelectDto;
import com.fjhx.purchase.entity.subscribe.po.Subscribe;
import com.ruoyi.common.core.domain.entity.SysDept;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.purchase.entity.subscribe.vo.SubscribeVo;
import com.fjhx.purchase.entity.subscribe.dto.SubscribeSelectDto;
import com.fjhx.purchase.entity.subscribe.dto.SubscribeDto;
import com.ruoyi.common.core.domain.BaseSelectDto;
import com.fjhx.purchase.service.subscribe.SubscribeService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;


/**
 * <p>
 * 申购单 前端控制器
 * </p>
 *
 * @author 
 * @since 2023-04-03
 */
@DS(SourceConstant.PURCHASE)
@RestController
@RequestMapping("/subscribe")
public class SubscribeController {

    @Autowired
    private SubscribeService subscribeService;

    /**
     * 申购单分页
     */
    @PostMapping("/page")
    public Page<SubscribeVo> page(@RequestBody SubscribeSelectDto dto) {
        return subscribeService.getPage(dto);
    }

    /**
     * 申购单明细
     */
    @PostMapping("/detail")
    public Subscribe detail(@RequestBody BaseSelectDto dto) {
        return subscribeService.detail(dto.getId());
    }

    /**
     * 申购单明细 维多利亚
     */
    @PostMapping("/detailByWdly")
    public Subscribe detailByWdly(@RequestBody BaseSelectDto dto) {
        return subscribeService.detailByWdly(dto.getId());
    }

    /**
     * 申购单新增
     */
    @PostMapping("/add")
    public void add(@RequestBody Subscribe subscribe) {
        subscribeService.add(subscribe);
    }

    /**
     * 申购单编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody SubscribeDto subscribeDto) {
        subscribeService.edit(subscribeDto);
    }

    /**
     * 申购单删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        subscribeService.delete(dto.getId());
    }

    @PostMapping("/getDepts")
    public List<SysDept> getDepts(@RequestBody SubscribeDetailSelectDto subscribeDetailSelectDto) {
        return subscribeService.getDepts(subscribeDetailSelectDto);
    }

}
