package com.mvc.controller.dic;

import com.mvc.model.CorrectMap;
import com.mvc.model.DicChkplatCellModel;
import com.mvc.model.ErrorMap;
import com.mvc.service.dic.DicChkplatCellService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(tags = "工位接口")
@RequestMapping("/DicChkplatCellAction")
@Controller
public class DicChkplatCellAction {


        @Autowired
        private DicChkplatCellService dicChkplatCellService;


        @ApiOperation("查询工位")
        @RequestMapping(value = "/list/{platId}",method = RequestMethod.GET)
        @ResponseBody
        public Map<String,Object> findAllDicChkplatCell(@PathVariable("platId") String platId){
        try {
            List<DicChkplatCellModel> resList= dicChkplatCellService.findAllDicChkplatCell(platId);
            Map<String,Object> resMap=new CorrectMap();
            resMap.put("res",resList);
            return resMap;
        } catch (Exception e) {
            e.printStackTrace();
            Map<String,Object> resMap=new ErrorMap();
            resMap.put("error",e.getMessage());
            return resMap;
        }
    }

        @ApiOperation("新增工位")
        @RequestMapping(value = "/saveDicChkplatCell",method = RequestMethod.POST)
        @ResponseBody
        public Map<String,Object> saveDicChkplatCell(@RequestBody DicChkplatCellModel DicChkplatCell){
        try {
            DicChkplatCellModel resModel= dicChkplatCellService.saveDicChkplatCell(DicChkplatCell);
            Map<String,Object> resMap=new CorrectMap();
            resMap.put("res",resModel);
            return resMap;
        } catch (Exception e) {
            e.printStackTrace();
            Map<String,Object> resMap=new ErrorMap();
            resMap.put("error",e.getMessage());
            return resMap;
        }
    }

        @ApiOperation("更新工位")
        @RequestMapping(value = "/updateDicChkplatCell",method = RequestMethod.POST)
        @ResponseBody
        public Map<String,Object> updateDicChkplatCell(@RequestBody DicChkplatCellModel DicChkplatCell){
        try {
            DicChkplatCellModel resModel= dicChkplatCellService.updateDicChkplatCell(DicChkplatCell);
            Map<String,Object> resMap=new CorrectMap();
            resMap.put("res",resModel);
            return resMap;
        } catch (Exception e) {
            e.printStackTrace();
            Map<String,Object> resMap=new ErrorMap();
            resMap.put("error",e.getMessage());
            return resMap;
        }
    }

        @ApiOperation("删除工位")
        @RequestMapping(value = "/deleteDicChkplatCell/{id}",method = RequestMethod.GET)
        @ResponseBody
        public Map<String,Object> deleteDicChkplatCell(@PathVariable("id") int id){
        try {
            int  res= dicChkplatCellService.deleteDicChkplatCell(id);
            Map<String,Object> resMap=new CorrectMap();
            resMap.put("res",res);
            return resMap;
        } catch (Exception e) {
            e.printStackTrace();
            Map<String,Object> resMap=new ErrorMap();
            resMap.put("error",e.getMessage());
            return resMap;
        }
    }


}
