package com.fjhx.controller.material;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.service.material.MaterialExService;
import com.fjhx.service.MaterialService;
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-07-14
 */
@RestController
@RequestMapping("/material")
public class MaterialExController {

    @Autowired
    private MaterialExService materialExService;

    @Autowired
    private MaterialService materialService;

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

    @PostMapping("/add")
    public R add(@RequestBody Map<String, Object> map) {
        materialExService.add(map);
        return R.success();
    }

    @PostMapping("/edit")
    public R edit(@RequestBody Map<String, Object> map) {
        materialExService.edit(map);
        return R.success();
    }

    @PostMapping("/delete")
    public R delete(@RequestBody Map<String, Object> map) {
        materialExService.delete(map);
        return R.success();
    }

    @PostMapping("getUnitList")
    public R getUnitList() {
        List<String> unitList = materialService.getUnitList();
        return R.success(unitList);
    }

}

