package com.sz.admin.monitor.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.sz.admin.monitor.pojo.dto.region.RegionCreateDTO;
import com.sz.admin.monitor.pojo.dto.region.RegionListDTO;
import com.sz.admin.monitor.pojo.dto.region.RegionUpdateDTO;
import com.sz.admin.monitor.pojo.vo.Region.RegionVO;
import com.sz.admin.monitor.service.RegionService;

import com.sz.core.common.constant.GlobalConstant;
import com.sz.core.common.entity.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Profile;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ClassName: RegionController
 * Package: com.sz.admin.monitor.controller
 * Description:
 */
@Tag(name = "区域表")
@RestController
@RequestMapping("region")
@RequiredArgsConstructor
@Profile({"dev", "local", "preview"})
public class RegionController {
    private final RegionService regionService;

    @Operation(summary = "新增")
    @PostMapping
    public ApiResult<Void> create(@RequestBody RegionCreateDTO dto) {
        regionService.create(dto);
        return ApiResult.success();
    }

    @Operation(summary = "修改")
    @PutMapping
    public ApiResult<Void> update(@RequestBody RegionUpdateDTO dto) {
        regionService.update(dto);
        return ApiResult.success();
    }

    @Operation(summary = "删除")
    @DeleteMapping
    public ApiResult<Void> remove(@RequestBody SelectIdsDTO dto) {
        regionService.remove(dto);
        return ApiResult.success();
    }

    @Operation(summary = "列表查询")
    @GetMapping
    public ApiResult<PageResult<RegionVO>> list(RegionListDTO dto) {
        return ApiPageResult.success(regionService.page(dto));
    }

    @Operation(summary = "详情")
    @GetMapping("/{id}")
    public ApiResult<RegionVO> detail(@PathVariable Long id) {
        return ApiResult.success(regionService.detail(id));
    }




}
