package com.fjhx.purchase.controller.subscribe;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.purchase.entity.subscribe.dto.SubscribeDetailDto;
import com.fjhx.purchase.entity.subscribe.dto.SubscribeDetailSelectDto;
import com.fjhx.purchase.entity.subscribe.vo.SubscribeDetailVo;
import com.fjhx.purchase.service.subscribe.SubscribeDetailService;
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;

import java.util.List;
import java.util.Map;


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

    @Autowired
    private SubscribeDetailService subscribeDetailService;

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

    /**
     * 申购统计（申购单分页）
     */
    @PostMapping("/subscribeStatistics")
    public Map<String, Object> subscribeStatistics(@RequestBody SubscribeDetailSelectDto dto) {
        return subscribeDetailService.subscribeStatistics(dto);
    }

    /**
     * 申购单明细
     */
    @PostMapping("/detail")
    public List<SubscribeDetailVo> detail(@RequestBody SubscribeDetailSelectDto dto) {
        return subscribeDetailService.detail(dto.getIds());
    }

    /**
     * 申购单新增
     */
    @PostMapping("/add")
    public void add(@RequestBody SubscribeDetailDto subscribeDetailDto) {
        subscribeDetailService.add(subscribeDetailDto);
    }

    /**
     * 申购单编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody SubscribeDetailDto subscribeDetailDto) {
        subscribeDetailService.edit(subscribeDetailDto);
    }

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

}
