package easydo.technology.controller;

import easydo.technology.model.ProcessRoute;
import easydo.technology.service.ProcessRouteService;
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("/processRoute")
public class ProcessRouteController {

    @Resource
    ProcessRouteService processRouteService;

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

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

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

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

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

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

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