package com.hdkj.lt.bf.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hdkj.lt.bf.entity.dto.LineRateCapacityDTO;
import com.hdkj.lt.bf.entity.vo.LineRateCapacityVO;
import com.hdkj.lt.bf.service.ILineRateCapacityService;
import com.hdkj.hussar.ApiResponse;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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;

/**
 * <p>
 * 负荷转供线路额定电路台账信息 前端控制器
 * </p>
 *
 * @author luorui
 * @since 2025-06-23
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/lineRateCapacity")
@Slf4j
public class LineRateCapacityController {

    private final ILineRateCapacityService lineRateCapacityService;

   /**
    *
    * 线路信息配置分页查询
    * @author luorui
    * @date 2025/6/23 11:08
    *
    **/
    @PostMapping("/getLineRateCapacityPage")
    @ApiOperation(value = "线路信息配置分页查询")
    public ApiResponse<Page<LineRateCapacityVO>> getLineRateCapacityPage(@RequestBody LineRateCapacityDTO lineRateCapacityDTO) {
        Page<LineRateCapacityVO> result = lineRateCapacityService.getLineRateCapacityPage(lineRateCapacityDTO);
        return ApiResponse.success(result);
    }


    /**
     *
     * 单条更新线路信息配置
     * @author luorui
     * @date 2025/6/23 11:08
     *
     **/
    @PostMapping("/updateLineRateCapacity")
    @ApiOperation(value = "单条更新线路信息配置")
    public ApiResponse<String> updateLineRateCapacity(@RequestBody LineRateCapacityDTO lineRateCapacityDTO) {
        Boolean result = lineRateCapacityService.saveOrUpdateLineRateCapacity(lineRateCapacityDTO);
        if (result) {
            return ApiResponse.success("更新成功");
        } else {
            return ApiResponse.fail("更新失败");
        }
    }

}
