package com.fjhx.controller.supplier;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.params.JumpVo;
import com.fjhx.params.supplier.SupplierPriceVo;
import com.fjhx.service.flow.SupplierPriceUpdateFlow;
import com.fjhx.service.supplier.SupplierPriceService;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
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-09-07
 */
@RestController
@RequestMapping("/supplierPrice")
public class SupplierPriceController {

    @Autowired
    private SupplierPriceService supplierPriceService;

    @Autowired
    private SupplierPriceUpdateFlow supplierPriceUpdateFlow;

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

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

    @PostMapping("/add")
    public R add(@RequestBody SupplierPriceVo supplierPriceVo) {
        supplierPriceService.add(supplierPriceVo);
        return R.success();
    }

    @PostMapping("/updateFlowCreate")
    public R updateFlowCreate(@RequestBody SupplierPriceVo supplierPriceVo) {
        supplierPriceUpdateFlow.create(supplierPriceVo);
        return R.success();
    }

    @PostMapping("/updateFlowJump")
    public R updateFlowJump(@RequestBody JumpVo jumpVo) {
        supplierPriceUpdateFlow.jump(jumpVo);
        return R.success();
    }

    @PostMapping("/delete")
    public R delete(@RequestBody SupplierPriceVo supplierPriceVo) {
        supplierPriceService.delete(supplierPriceVo);
        return R.success();
    }

}

