package com.fjhx.controller.material;

import com.alibaba.fastjson.JSONObject;
import com.fjhx.params.material.MaterialClassifyVo;
import com.fjhx.service.material.MaterialClassifyService;
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;

/**
 * <p>
 * 物料分类 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-08-05
 */
@RestController
@RequestMapping("/materialClassify")
public class MaterialClassifyController {

    @Autowired
    private MaterialClassifyService materialClassifyService;

    @PostMapping("/tree")
    public R tree() {
        List<JSONObject> result = materialClassifyService.tree();
        return R.success(result);
    }

    @PostMapping("/add")
    public R add(@RequestBody MaterialClassifyVo materialClassifyVo) {
        materialClassifyService.add(materialClassifyVo);
        return R.success();
    }

    @PostMapping("/edit")
    public R edit(@RequestBody MaterialClassifyVo materialClassifyVo) {
        materialClassifyService.edit(materialClassifyVo);
        return R.success();
    }

}

