package com.fjhx.supply.controller.supplier;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.common.constant.SourceConstant;
import com.fjhx.supply.entity.supplier.dto.SupplierInfoDto;
import com.fjhx.supply.entity.supplier.dto.SupplierInfoSelectDto;
import com.fjhx.supply.entity.supplier.vo.SupplierInfoVo;
import com.fjhx.supply.service.supplier.SupplierInfoService;
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.Map;


/**
 * <p>
 * 供应商 前端控制器
 * </p>
 *
 * @author
 * @since 2023-03-17
 */
@DS(SourceConstant.SUPPLY)
@RestController
@RequestMapping("/supplierInfo")
public class SupplierInfoController {

    @Autowired
    private SupplierInfoService supplierInfoService;

    /**
     * 供应商分页
     */
    @PostMapping("/page")
    public Page<SupplierInfoVo> page(@RequestBody SupplierInfoSelectDto dto) {
        return supplierInfoService.getPage(dto);
    }

    /**
     * 供应商分页 维多利亚
     */
    @PostMapping("/pageByWdly")
    public Page<SupplierInfoVo> pageByWdly(@RequestBody SupplierInfoSelectDto dto) {
        return supplierInfoService.getPageByWdly(dto);
    }

    /**
     * 供应商明细
     */
    @PostMapping("/detail")
    public SupplierInfoVo detail(@RequestBody BaseSelectDto dto) {
        return supplierInfoService.detail(dto.getId());
    }

    @PostMapping("/detailByWdly")
    public SupplierInfoVo detailByWdly(@RequestBody BaseSelectDto dto) {
        return supplierInfoService.detailByWdly(dto.getId());
    }

    /**
     * 供应商新增
     */
    @PostMapping("/add")
    public void add(@RequestBody SupplierInfoDto supplierInfoDto) {
        supplierInfoService.add(supplierInfoDto);
    }

    /**
     * 供应商编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody SupplierInfoDto supplierInfoDto) {
        supplierInfoService.edit(supplierInfoDto);
    }

    /**
     * 供应商删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        supplierInfoService.delete(dto.getId());
    }

    /**
     * 供应商统计（列表）
     */
    @PostMapping("/supplierStatistics")
    public Map<String,Object> supplierStatistics(@RequestBody BaseSelectDto dto) {
        return supplierInfoService.supplierStatistics(dto);
    }
}
