package com.sikey.wa04.api.location.client.rest;

import com.sikey.wa04.business.application.service.location.FenceService;
import com.sikey.wa04.business.infrastructure.dto.request.fence.*;
import com.sikey.wa04.business.infrastructure.dto.response.fence.CreateFenceResponse;
import com.sikey.wa04.business.infrastructure.dto.response.fence.GetFenceResponse;
import com.sikey.wa04.business.infrastructure.dto.response.fence.TotalSwitchFenceResponse;
import com.sikey.wa04.common.BaseController;
import com.sikey.wa04.common.interceptor.Authenticated;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * 围栏 API
 *
 * @author luoyangwei
 * @date 2024年11月01日11:39:59
 */
@RestController
@RequestMapping("/api/v2/locatectx/fence")
public class FenceController extends BaseController {

    @Resource
    private FenceService fenceService;

    /**
     * 获取围栏信息
     *
     * @param request 请求参数
     * @return 围栏信息
     */
    @Authenticated
    @GetMapping("/get")
    public GetFenceResponse get(@Valid GetFenceRequest request) {
        return fenceService.get(request);
    }

    /**
     * 创建围栏
     *
     * @param request 请求参数
     * @return 创建围栏结果
     */
    @Authenticated
    @PostMapping("/create")
    public CreateFenceResponse create(@Valid @RequestBody CreateFenceRequest request) {
        return fenceService.create(request);
    }

    /**
     * 更新围栏
     *
     * @param request 请求参数
     */
    @Authenticated
    @PostMapping("/update")
    public void update(@Valid @RequestBody UpdateFenceRequest request) {
        fenceService.update(request);
    }

    /**
     * 删除围栏
     *
     * @param request 请求参数
     */
    @Authenticated
    @GetMapping("/delete")
    public void delete(@Valid DeleteFenceRequest request) {
        fenceService.delete(request);
    }

    /**
     * 开关围栏
     *
     * @param request 请求参数
     * @return 开关围栏结果
     */
    @Authenticated
    @GetMapping("/total/switch")
    public TotalSwitchFenceResponse totalSwitch(@Valid TotalSwitchFenceRequest request) {
        return fenceService.totalSwitch(request);
    }
}
