 package com.huimv.management.controller;

import java.util.Arrays;
import java.util.Map;

import com.huimv.management.entity.dto.WarningInfoDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.huimv.management.entity.WarningInfoEntity;
import com.huimv.management.service.WarningInfoService;
import com.huimv.common.utils.PageUtils;
import com.huimv.common.utils.R;



/**
 * <p>
 * 报警信息Controller
 * </p>
 *
 * @author yinhao
 * @version 1.0
 * @date 2021-06-15 13:01:37
 */
@RestController
@RequestMapping("management/warningInfo")
public class WarningInfoController {
    @Autowired
    private WarningInfoService warningInfoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = warningInfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		WarningInfoEntity warningInfo = warningInfoService.getById(id);

        return R.ok().put("warningInfo", warningInfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody WarningInfoEntity warningInfo){
		warningInfoService.save(warningInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody WarningInfoEntity warningInfo){
		warningInfoService.updateById(warningInfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		warningInfoService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    /**
     * 确认
     * @param warningInfoDto
     * @return
     */
    @RequestMapping("/verity")
    public R verify(@RequestBody WarningInfoDto warningInfoDto) {
        warningInfoService.verify(warningInfoDto);

        return R.ok();
    }
}
