/*
 *    Copyright (c) 2018-2025, hnqz All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: hnqz
 */

package com.qunzhixinxi.hnqz.admin.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qunzhixinxi.hnqz.common.core.util.R;
import com.qunzhixinxi.hnqz.common.log.annotation.SysLog;
import com.qunzhixinxi.hnqz.admin.entity.MonitoringIndicator;
import com.qunzhixinxi.hnqz.admin.service.MonitoringIndicatorService;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 风险监控
 *
 * @author ryz
 * @date 2021-04-19 16:08:29
 */
@RestController
@AllArgsConstructor
@RequestMapping("/monitoringindicator" )
@Api(value = "monitoringindicator", tags = "风险监控管理")
public class MonitoringIndicatorController {

    private final  MonitoringIndicatorService monitoringIndicatorService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param monitoringIndicator 风险监控
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    @PreAuthorize("@pms.hasPermission('admin_monitoringindicator_view')" )
    public R getMonitoringIndicatorPage(Page page, MonitoringIndicator monitoringIndicator) {
        return R.ok(monitoringIndicatorService.page(page, Wrappers.query(monitoringIndicator)));
    }


    /**
     * 通过id查询风险监控
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('admin_monitoringindicator_view')" )
    public R getById(@PathVariable("id" ) Long id) {
        return R.ok(monitoringIndicatorService.getById(id));
    }

    /**
     * 新增风险监控
     * @param monitoringIndicator 风险监控
     * @return R
     */
    @ApiOperation(value = "新增风险监控", notes = "新增风险监控")
    @SysLog("新增风险监控" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('admin_monitoringindicator_add')" )
    public R save(@RequestBody MonitoringIndicator monitoringIndicator) {
        return R.ok(monitoringIndicatorService.save(monitoringIndicator));
    }

    /**
     * 修改风险监控
     * @param monitoringIndicator 风险监控
     * @return R
     */
    @ApiOperation(value = "修改风险监控", notes = "修改风险监控")
    @SysLog("修改风险监控" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('admin_monitoringindicator_edit')" )
    public R updateById(@RequestBody MonitoringIndicator monitoringIndicator) {
        return R.ok(monitoringIndicatorService.updateById(monitoringIndicator));
    }

    /**
     * 通过id删除风险监控
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除风险监控", notes = "通过id删除风险监控")
    @SysLog("通过id删除风险监控" )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('admin_monitoringindicator_del')" )
    public R removeById(@PathVariable Long id) {
        return R.ok(monitoringIndicatorService.removeById(id));
    }

}
