package com.fjhx.controller.supplier;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.params.supplier.SupplierVo;
import com.fjhx.service.supplier.SupplierService;
import org.springblade.core.tool.api.R;
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 ${author}
 * @since 2022-11-24
 */
@RestController
@RequestMapping("/supplier")
public class SupplierController {

    @Autowired
    private SupplierService supplierService;

    @PostMapping("/page")
    public R page(@RequestBody Map<String, Object> condition) {
        Page<Map<String, Object>> result = supplierService.getPage(condition);
        return R.success(result);
    }

    @PostMapping("/add")
    public R add(@RequestBody SupplierVo supplierVo) {
        supplierService.add(supplierVo);
        return R.success();
    }

    @PostMapping("/edit")
    public R edit(@RequestBody SupplierVo supplierVo) {
        supplierService.edit(supplierVo);
        return R.success();
    }

    @PostMapping("/delete")
    public R delete(@RequestBody SupplierVo supplierVo) {
        supplierService.delete(supplierVo);
        return R.success();
    }

    @PostMapping("/list")
    public R list(@RequestBody SupplierVo supplierVo) {
        List<Map<String, Object>> result = supplierService.getList(supplierVo);
        return R.success(result);
    }

}

