package com.mvc.controller.forwarding;

import com.mvc.model.CorrectMap;
import com.mvc.model.ErrorMap;
import com.mvc.model.forwarding.TForwarderRecordsModel;
import com.mvc.service.forwarding.TForwarderRecordsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Map;

@Api(tags = "数据转发记录表控制类")
@RequestMapping("/TForwarderRecordsAction")
@Controller
public class TForwarderRecordsAction {

    @Resource
    private TForwarderRecordsService tForwarderRecordsService;
    
    @ApiOperation("查询数据转发记录表")
    @RequestMapping(value = "/findAllTForwarderRecords",method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> findAllTForwarderRecords(){
        try {
            Map<String, Object> res= tForwarderRecordsService.findAllTForwarderRecords(1,1);
            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 = "/saveTForwarderRecords",method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> saveTForwarderRecords(@RequestBody TForwarderRecordsModel model){
        try {
            TForwarderRecordsModel resModel= tForwarderRecordsService.saveTForwarderRecords(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 = "/updateTForwarderRecords",method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> updateDeviceAcc(@RequestBody TForwarderRecordsModel model){
        try {
            TForwarderRecordsModel resModel= tForwarderRecordsService.updateTForwarderRecords(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 = "/deleteTForwarderRecords/{id}",method = RequestMethod.GET)
    @ResponseBody
    public Map<String,Object> deleteTForwarderRecords(@PathVariable("id") int id){
        try {
            int  res= tForwarderRecordsService.deleteTForwarderRecords(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;
        }
    }
}
