package com.usky.iot.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.common.core.bean.CommonPage;
import com.usky.iot.domain.BaseAlarmType;
import com.usky.iot.service.BaseAlarmTypeService;
import com.usky.iot.service.vo.BaseAlarmTypeRequestVO;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 * 告警类型表 前端控制器
 * </p>
 *
 * @author han
 * @since 2023-07-12
 */
@RestController
@RequestMapping("/baseAlarmType")
public class BaseAlarmTypeController {

    @Autowired
    private BaseAlarmTypeService baseAlarmTypeService;

    /**
     * 新增
     * @param baseAlarmType
     * @return
     */
    @PostMapping
    public ApiResult<Void> add(@RequestBody BaseAlarmType baseAlarmType){
        baseAlarmTypeService.add(baseAlarmType);
        return ApiResult.success();
    }

    /**
     * 修改
     * @param baseAlarmType
     * @return
     */
    @PutMapping
    public ApiResult<Void> update(@RequestBody BaseAlarmType baseAlarmType){
        baseAlarmTypeService.update(baseAlarmType);
        return ApiResult.success();
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public ApiResult<Void> remove(@PathVariable("id") Integer id){
        baseAlarmTypeService.remove(id);
        return ApiResult.success();
    }

    /**
     * 分页
     * @param baseAlarmTypeRequestVO
     * @return
     */
    @PostMapping("page")
    public ApiResult<CommonPage<BaseAlarmType>> page(@RequestBody BaseAlarmTypeRequestVO baseAlarmTypeRequestVO){
        return ApiResult.success(baseAlarmTypeService.page(baseAlarmTypeRequestVO));
    }

    /**
     * 租户告警类型列表
     * @return
     */
    @GetMapping("tenantIdAlarmTypeList")
    public ApiResult<List<BaseAlarmType>> tenantIdAlarmTypeList(){
        return ApiResult.success(baseAlarmTypeService.tenantIdAlarmTypeList());
    }

}

