package com.ltgk.port.controller;

import com.ltgk.common.annotation.Log;
import com.ltgk.common.annotation.RepeatSubmit;
import com.ltgk.common.core.domain.AjaxResult;
import com.ltgk.common.enums.BusinessType;
import com.ltgk.port.domain.dto.RemoveByIdReq;
import com.ltgk.port.domain.dto.SaveWarnAreaTypeReq;
import com.ltgk.port.domain.dto.WarnAreaTypeListReq;
import com.ltgk.port.service.WarnAreaTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @Author: wan kun
 * @Description: 告警分类类型
 * @Date: 2025/2/11 16:27
 * @Version: 1.0
 */
@Api(tags = "告警分类类型")
@RestController
@RequestMapping("/fishingPort/warnAreaType")
public class WarnAreaTypeController {
    @Autowired
    private WarnAreaTypeService warnAreaTypeService;

    @RepeatSubmit(message = "请勿重复提交")
    @Log(title = "新增修改告警分类类型", businessType = BusinessType.INSERT_OR_UPDATE)
    @PostMapping("/save")
    @ApiOperation(value = "新增修改告警分类类型")
    public AjaxResult save(@Valid @RequestBody SaveWarnAreaTypeReq saveWarnAreaTypeReq) {
        return warnAreaTypeService.save(saveWarnAreaTypeReq);
    }

    @Log(title = "查询告警分类类型", businessType = BusinessType.QUERY)
    @PostMapping("/list")
    @ApiOperation(value = "查询告警分类类型")
    public AjaxResult list(@Valid @RequestBody WarnAreaTypeListReq warnAreaTypeListReq) {
        return AjaxResult.success(warnAreaTypeService.list(warnAreaTypeListReq));
    }

    @Log(title = "删除告警分类类型", businessType = BusinessType.DELETE)
    @PostMapping("/delete")
    @ApiOperation(value = "删除告警分类类型")
    public AjaxResult delete(@Valid @RequestBody RemoveByIdReq removeByIdReq) {
        return AjaxResult.success(warnAreaTypeService.removeById(removeByIdReq.getId()));
    }

    @Log(title = "查询所有告警分类", businessType = BusinessType.DELETE)
    @PostMapping("/selectAll")
    @ApiOperation(value = "查询所有告警分类")
    public AjaxResult selectAll() {
        return AjaxResult.success(warnAreaTypeService.selectAll());
    }
}
