 package com.huimv.management.controller;

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

import com.huimv.management.entity.dto.WarningInfoDto;
import com.huimv.management.entity.vo.WarningInfoVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

import javax.servlet.http.HttpServletRequest;


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

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

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


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

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

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

        return R.ok();
    }

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

        return R.ok();
    }

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

        return R.ok();
    }

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

        return R.ok();
    }

     /**
      * 条件查询所有
      * @param params
      * @return
      */
    @GetMapping("/queryByCondition")
    public R queryByCondition(@RequestParam Map<String, Object> params) {
        List<WarningInfoVo> warningInfoVoList = warningInfoService.queryByCondition(params);

        return R.ok().put("data", warningInfoVoList);
    }


}
