package com.njzscloud.supervisory.biz.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.supervisory.biz.pojo.entity.BizWarnEntity;
import com.njzscloud.supervisory.biz.pojo.result.BizWarnDetailVO;
import com.njzscloud.supervisory.biz.service.BizWarnService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 预警
 */
@Slf4j
@RestController
@RequestMapping("/biz_warn")
@RequiredArgsConstructor
public class BizWarnController {

    private final BizWarnService bizWarnService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody BizWarnEntity bizWarnEntity) {
        bizWarnService.add(bizWarnEntity);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody BizWarnEntity bizWarnEntity) {
        bizWarnService.modify(bizWarnEntity);
        return R.success();
    }

    /**
     * 删除
     */
    @PostMapping("/del")
    public R<?> del(@RequestBody List<Long> ids) {
        bizWarnService.del(ids);
        return R.success();
    }

    /**
     * 详情
     */
    @GetMapping("/detail")
    public R<BizWarnDetailVO> detail(@RequestParam Long id) {
        return R.success(bizWarnService.detail(id));
    }

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<BizWarnDetailVO>> paging(PageParam pageParam, BizWarnEntity bizWarnEntity) {
        return R.success(bizWarnService.paging(pageParam, bizWarnEntity));
    }

}
