package com.hdkj.lt.bf.controller;

import com.hdkj.lt.bf.entity.dto.SwitchContactEffectiveUpdateBatchRequest;
import com.hdkj.lt.bf.entity.dto.SwitchInfoListRequest;
import com.hdkj.lt.bf.entity.dto.SwitchInfoUpdateRequest;
import com.hdkj.lt.bf.entity.vo.SwitchIndoPageVO;
import com.hdkj.lt.bf.entity.vo.SwitchInfoVO;
import com.hdkj.lt.bf.service.DwdShbDsSwitchBaseService;
import com.hdkj.hussar.ApiResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
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 java.util.List;

/**
 * @author rj
 * @date 2025/6/27 8:57
 * @description
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/switch-info")
public class SwitchInfoLedgerController {


    private final DwdShbDsSwitchBaseService dwdShbDsSwitchBaseService;

    /**
     * 开关配置分页查询
     * @author luorui
     * @date 2025/8/8 9:44
     **/
    @PostMapping("/list")
    public ApiResponse<SwitchIndoPageVO> getSwitchInfoList(@RequestBody SwitchInfoListRequest request) {
        return ApiResponse.success(dwdShbDsSwitchBaseService.getSwitchInfoPageByCondition(request));
    }

    /**
     * 开关信息编辑修改
     * @author luorui
     * @date 2025/8/8 9:44
     **/
    @PostMapping("/update")
    public ApiResponse<String> updateSwitchInfo(@RequestBody @Validated SwitchInfoUpdateRequest request) {
        return ApiResponse.success(dwdShbDsSwitchBaseService.updateSwitchInfo(request));
    }

    /**
     * 批量修改联络开关是否有效
     * @author luorui
     * @date 2025/8/8 9:44
     *
     **/
    @PostMapping("/updateContactEffectiveBatch")
    public ApiResponse<String> updateContactEffectiveBatch(@RequestBody SwitchContactEffectiveUpdateBatchRequest request) {
        return ApiResponse.success(dwdShbDsSwitchBaseService.updateContactEffectiveBatch(request));
    }

    /**
     * 根据线路prsId 查询开关列表
     * @author luorui
     * @date 2025/9/18 16:17
     * @discription
     *
     **/
    @PostMapping("/getSwitchListByFeeder")
    public ApiResponse<List<SwitchInfoVO>> getSwitchListByFeeder(@RequestBody SwitchInfoListRequest request) {
        return ApiResponse.success(dwdShbDsSwitchBaseService.getSwitchListByFeeder(request));
    }

}
