package com.fjhx.sale.controller.contract;

import com.fjhx.sale.entity.contract.dto.ContractSelectDto;
import com.fjhx.sale.entity.contract.po.ContractDocumentary;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.sale.entity.contract.vo.ContractDocumentaryVo;
import com.fjhx.sale.entity.contract.dto.ContractDocumentarySelectDto;
import com.fjhx.sale.entity.contract.dto.ContractDocumentaryDto;
import com.ruoyi.common.core.domain.BaseSelectDto;
import com.fjhx.sale.service.contract.ContractDocumentaryService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;


/**
 * <p>
 * 外销跟单表 前端控制器
 * </p>
 *
 * @author 
 * @since 2023-08-30
 */
@RestController
@RequestMapping("/contractDocumentary")
public class EhsdDocumentaryController {

    @Autowired
    private ContractDocumentaryService contractDocumentaryService;

    /**
     * 外销跟单表分页
     */
    @PostMapping("/page")
    public Page<ContractDocumentary> page(@RequestBody ContractDocumentarySelectDto dto) {
        return contractDocumentaryService.getPage(dto);
    }

    /**
     * 外销跟单表明细
     */
    @PostMapping("/detail")
    public ContractDocumentaryVo detail(@RequestBody BaseSelectDto dto) {
        return contractDocumentaryService.detail(dto.getId());
    }

    /**
     * 外销跟单表新增
     */
    @PostMapping("/add")
    public void add(@RequestBody ContractDocumentaryDto contractDocumentaryDto) {
        contractDocumentaryService.add(contractDocumentaryDto);
    }

    /**
     * 外销跟单表编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody ContractDocumentaryDto contractDocumentaryDto) {
        contractDocumentaryService.edit(contractDocumentaryDto);
    }

    /**
     * 外销跟单表删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        contractDocumentaryService.delete(dto.getId());
    }

    /**
     * 销售跟单---统计数量
     */
    @PostMapping("/getSumCount")
    public Map<String,Integer> getSumCount(@RequestBody ContractSelectDto dto) {
       return contractDocumentaryService.getSumCount(dto);
    }


}
