ソースを参照

refactor(price-policy): 修改更新计费策略接口返回值为布尔类型

- 将Controller层updatePricePolicy方法返回类型改为Result<Boolean>
- 服务接口及实现方法updatePricePolicy由void改为boolean类型,反映操作成功与否
- 在实现类中添加逻辑判断是否找到充电桩接口,未找到时返回false
- 成功完成更新后返回true,增强接口调用的结果反馈能力
SheepHy 3 日 前
コミット
b92febe776

+ 2 - 3
src/main/java/com/zsElectric/boot/business/controller/PricePolicyManagementController.java

@@ -45,8 +45,7 @@ public class PricePolicyManagementController {
     @Operation(summary = "修改计费策略")
     @PostMapping("/update")
     @Log(value = "修改计费策略", module = LogModuleEnum.PARKING_CALL, params = true, result = true)
-    public Result<Void> updatePricePolicy(@RequestBody UpdatePricePolicyDTO dto) {
-        pricePolicyManagementService.updatePricePolicy(dto);
-        return Result.success();
+    public Result<Boolean> updatePricePolicy(@RequestBody UpdatePricePolicyDTO dto) {
+        return Result.success(pricePolicyManagementService.updatePricePolicy(dto));
     }
 }

+ 1 - 1
src/main/java/com/zsElectric/boot/business/service/PricePolicyManagementService.java

@@ -26,5 +26,5 @@ public interface PricePolicyManagementService {
      *
      * @param dto 修改参数
      */
-    void updatePricePolicy(UpdatePricePolicyDTO dto);
+    boolean updatePricePolicy(UpdatePricePolicyDTO dto);
 }

+ 3 - 2
src/main/java/com/zsElectric/boot/business/service/impl/PricePolicyManagementServiceImpl.java

@@ -181,7 +181,7 @@ public class PricePolicyManagementServiceImpl implements PricePolicyManagementSe
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void updatePricePolicy(UpdatePricePolicyDTO dto) {
+    public boolean updatePricePolicy(UpdatePricePolicyDTO dto) {
         // 查询该充电站的所有充电桩接口
         List<ThirdPartyConnectorInfo> connectors = connectorInfoMapper.selectList(
                 Wrappers.<ThirdPartyConnectorInfo>lambdaQuery()
@@ -190,7 +190,7 @@ public class PricePolicyManagementServiceImpl implements PricePolicyManagementSe
 
         if (CollectionUtils.isEmpty(connectors)) {
             log.warn("未找到充电站的充电桩接口信息, stationId: {}", dto.getStationId());
-            return;
+            return Boolean.FALSE;
         }
 
         BigDecimal operationServiceFee = dto.getHasContractServiceFee() && dto.getContractServiceFee() != null 
@@ -203,6 +203,7 @@ public class PricePolicyManagementServiceImpl implements PricePolicyManagementSe
         }
 
         log.info("更新充电站价格策略成功, stationId: {}, operationServiceFee: {}", dto.getStationId(), operationServiceFee);
+        return Boolean.TRUE;
     }
 
     /**