package com.mvc.controller.alarm;

import com.mvc.model.ResPageModel;
import com.mvc.model.ResultGeekerModel;
import com.mvc.model.alarm.TAlarmNoticeModel;
import com.mvc.service.alarm.TAlarmNoticeService;
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("/TAlarmNoticeAction")
@Controller
public class TAlarmNoticeAction {

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

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

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

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