package com.mvc.controller.copy;


import com.mvc.model.CorrectMap;
import com.mvc.model.ErrorMap;
import com.mvc.model.TPackLogModel;
import com.mvc.service.copy.TPackLogService;
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("/TPackLogAction")
@Controller
public class TPackLogAction {

    @Autowired
    private TPackLogService tPackLogService;

    @ApiOperation("根据条件查询原始报文")
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> findAllTPackLog(@RequestBody TPackLogModel model){

        try {
            Map<String,Object> res= tPackLogService.findAllTPackLog(model);
            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 = "/findAllTPackLogByQueryModel", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> findAllTPackLogByQueryModel(@RequestBody TPackLogModel model){

        try {
            Map<String,Object> res= tPackLogService.findAllTPackLogByQueryModel(model);
            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("根据ID查询报文(带报文内容)")
    @RequestMapping(value = "/findTPackLogById/{id}", method = RequestMethod.GET)
    @ResponseBody
    public Map<String,Object> findTPackLogById(@PathVariable("id") Integer id) {
        try {
            TPackLogModel res= tPackLogService.findTPackLogById(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;
        }
    }
}
