package easydo.technology.controller;

import easydo.technology.model.ProductBom;
import easydo.technology.service.ProductBomService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/productBom")
public class ProductBomController {

    @Resource
    ProductBomService productBomService;

    @RequestMapping(value = "/getPage")
    public Object getPage(@RequestBody Map<String, Object> map) throws Exception {
        Object page = productBomService.getPage(map);
        return new ResponseEntity<>(page, HttpStatus.OK);
    }

    @RequestMapping(value = "/getChildrenList")
    public Object getChildrenList(@RequestBody Map<String, Object> map) throws Exception {
        Object list = productBomService.getChildrenList(map);
        return new ResponseEntity<>(list, HttpStatus.OK);
    }

    @RequestMapping(value = "/save")
    public Object save(@RequestBody ProductBom model) throws Exception {
        Object result = productBomService.save(model);
        return new ResponseEntity<>(result, HttpStatus.OK);
    }

    @RequestMapping(value = "/update")
    public Object update(@RequestBody ProductBom model) throws Exception {
        Object result = productBomService.update(model);
        return new ResponseEntity<>(result, HttpStatus.OK);
    }

    @RequestMapping(value = "/remove")
    public Object remove(@RequestBody ProductBom model) throws Exception {
        Object result = productBomService.remove(model);
        return new ResponseEntity<>(result, HttpStatus.OK);
    }
}
