package com.mvc.controller.alarm;

import com.mvc.model.ResPageModel;
import com.mvc.model.ResultGeekerModel;
import com.mvc.model.alarm.TAlarmRecordModel;
import com.mvc.service.alarm.TAlarmRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;

@Api(tags = "报警通知记录接口")
@RequestMapping("/TAlarmRecordAction")
@Controller
public class TAlarmRecordAction {

    @Resource
    private TAlarmRecordService tAlarmRecordService;
    
    @ApiOperation("查询所有报警通知记录")
    @RequestMapping(value = "/list",method = RequestMethod.POST)
    @ResponseBody
    public ResultGeekerModel findAllTAlarmRecord(@RequestBody TAlarmRecordModel model){
        ResultGeekerModel resultModel;
        try {
            ResPageModel res = tAlarmRecordService.findAllTAlarmRecord(model);
            resultModel = new ResultGeekerModel(res);
        } catch (Exception e) {
            e.printStackTrace();
            resultModel = new ResultGeekerModel(e.getMessage());
        }
        return resultModel;
    }

    @ApiOperation("新增报警通知记录")
    @RequestMapping(value = "/saveTAlarmRecord",method = RequestMethod.POST)
    @ResponseBody
    public ResultGeekerModel saveTAlarmRecord(@RequestBody TAlarmRecordModel model){
        ResultGeekerModel resultModel;
        try {
            TAlarmRecordModel res= tAlarmRecordService.saveTAlarmRecord(model);
            resultModel = new ResultGeekerModel(res);
        } catch (Exception e) {
            e.printStackTrace();
            resultModel = new ResultGeekerModel(e.getMessage());
        }
        return resultModel;
    }

    @ApiOperation("更新报警通知记录")
    @RequestMapping(value = "/updateTAlarmRecord",method = RequestMethod.POST)
    @ResponseBody
    public ResultGeekerModel updateTAlarmRecord(@RequestBody TAlarmRecordModel model){
        ResultGeekerModel resultModel;
        try {
            TAlarmRecordModel res= tAlarmRecordService.updateTAlarmRecord(model);
            resultModel = new ResultGeekerModel(res);
        } catch (Exception e) {
            e.printStackTrace();
            resultModel = new ResultGeekerModel(e.getMessage());
        }
        return resultModel;
    }

    @ApiOperation("删除报警通知记录")
    @RequestMapping(value = "/deleteTAlarmRecord",method = RequestMethod.GET)
    @ResponseBody
    public ResultGeekerModel deleteTAlarmRecord(int id){
        ResultGeekerModel resultModel;
        try {
            int res= tAlarmRecordService.deleteTAlarmRecord(id);
            resultModel = new ResultGeekerModel(res);
        } catch (Exception e) {
            e.printStackTrace();
            resultModel = new ResultGeekerModel(e.getMessage());
        }
        return resultModel;
    }
}
