package com.mvc.controller.taizhang;

import com.mvc.model.TaskBatchRemoteDetailModel;
import com.mvc.model.CorrectMap;
import com.mvc.model.ErrorMap;
import com.mvc.service.taizhang.TaskBatchRemoteDetailService;
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.Map;

@Api(tags = "批量任务明细控制类")
@RequestMapping("/TaskBatchRemoteDetailAction")
@Controller
public class TaskBatchRemoteDetailAction {

    @Autowired
    private TaskBatchRemoteDetailService taskBatchRemoteDetailService;


    @ApiOperation("分页查询批量任务明细")
    @RequestMapping(value = "/list/{page}/{rows}",method = RequestMethod.GET)
    @ResponseBody
    public Map<String,Object> findAllTaskBatchRemoteDetail(@PathVariable("page") Integer page, @PathVariable("rows") Integer rows){
        try {
            Map<String,Object> res= taskBatchRemoteDetailService.findAllTaskBatchRemoteDetail(page,rows);
            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;
        }
    }



    @ApiOperation("新增批量任务明细")
    @RequestMapping(value = "/saveTaskBatchRemoteDetail",method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> saveTaskBatchRemoteDetail(@RequestBody TaskBatchRemoteDetailModel model){
        try {
            TaskBatchRemoteDetailModel resModel= taskBatchRemoteDetailService.saveTaskBatchRemoteDetail(model);
            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 = "/updateTaskBatchRemoteDetail",method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> updateDeviceAcc(@RequestBody TaskBatchRemoteDetailModel model){
        try {
            TaskBatchRemoteDetailModel resModel= taskBatchRemoteDetailService.updateTaskBatchRemoteDetail(model);
            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 = "/deleteTaskBatchRemoteDetail/{id}",method = RequestMethod.GET)
    @ResponseBody
    public Map<String,Object> deleteTaskBatchRemoteDetail(@PathVariable("id") int id){
        try {
            int  res= taskBatchRemoteDetailService.deleteTaskBatchRemoteDetail(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;
        }
    }
}
