package com.muyu.server.controller;

import com.muyu.common.domain.WarnLogs;
import com.muyu.server.service.WarnLogsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
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.RestController;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.domain.Result;

/**
 * 预警日志Controller
 *
 * @author sx
 * @date 2024-09-20
 */
@RestController
@RequestMapping("/logs")
@Tag(name = "预警日志",description = "预警日志管理")
@Log4j2
public class WarnLogsController extends BaseController
{
    @Autowired
    private WarnLogsService warnLogsService;

    /**
     * 查询预警日志列表
     */
    @GetMapping("/selectWarnLogsList")
    @Operation(summary = "预警日志列表",description = "预警日志列表")
    public Result  selectWarnLogsList(){
        return Result.success(warnLogsService.selectWarnLogsList());
    }


    /**
     * 获取预警日志详细信息
     */
    @GetMapping(value = "selectWarnLogsById/{id}")
    @Operation(summary = "根据ID查询预警日志信息",description = "根据ID查询预警日志信息")
    public Result selectWarnLogsById(@PathVariable("id") Long id)
    {
        return success(warnLogsService.selectWarnLogsById(id));
    }

    /**
     * 新增预警日志
     */
    @PostMapping("/addWarnLogs")
    @Operation(summary = "新增预警日志",description = "新增预警日志")
    public Result<Integer> addWarnLogs(@RequestBody WarnLogs warnLogs)
    {
        int i = warnLogsService.addWarnLogs(warnLogs);
        return i>0?Result.success():Result.error();
    }

}
