Explorar el Código

feat(charging): 新增站点详情信息查询与修改功能

- 新增站点详情查询接口,支持获取banner、提示语、营业时间及客服电话
- 新增站点详情修改接口,支持更新站点banner、提示语、营业时间及客服电话
- 扩展ThirdPartyStationInfo实体,添加自有营业时间、客服热线及Banner图片字段
- 实现站点详情业务逻辑,包括JSON序列化与反序列化banner图片列表
- 增加StationDetailDTO和StationDetailVO用于数据传输和视图展示
- 加强接口日志记录,提升操作追踪能力
SheepHy hace 2 días
padre
commit
0c6738d550

+ 21 - 0
src/main/java/com/zsElectric/boot/business/controller/ThirdPartyChargingController.java

@@ -3,9 +3,11 @@ package com.zsElectric.boot.business.controller;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.zsElectric.boot.business.model.query.ThirdPartyStationInfoQuery;
 import com.zsElectric.boot.business.model.query.ThirdPartyEquipmentInfoQuery;
+import com.zsElectric.boot.business.model.dto.StationDetailDTO;
 import com.zsElectric.boot.business.model.vo.PartyStationInfoVO;
 import com.zsElectric.boot.business.model.vo.ThirdPartyStationInfoVO;
 import com.zsElectric.boot.business.model.vo.ThirdPartyEquipmentInfoVO;
+import com.zsElectric.boot.business.model.vo.StationDetailVO;
 import com.zsElectric.boot.business.service.ThirdPartyChargingService;
 import com.zsElectric.boot.common.annotation.Log;
 import com.zsElectric.boot.common.enums.LogModuleEnum;
@@ -13,8 +15,11 @@ import com.zsElectric.boot.core.web.PageResult;
 import com.zsElectric.boot.core.web.Result;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.validation.Valid;
 import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -51,4 +56,20 @@ public class ThirdPartyChargingController {
         return PageResult.success(result);
     }
 
+    @Operation(summary = "查询站点详情信息", description = "查询站点的banner信息、提示语、营业时间、客服电话")
+    @GetMapping("/stations/detail/{stationId}")
+    @Log(value = "查询站点详情信息", module = LogModuleEnum.OTHER)
+    public Result<StationDetailVO> getStationDetail(@PathVariable Long stationId) {
+        StationDetailVO result = chargingService.getStationDetail(stationId);
+        return Result.success(result);
+    }
+
+    @Operation(summary = "修改站点详情信息", description = "修改站点的banner信息、提示语、营业时间、客服电话")
+    @PostMapping("/stations/detail/update")
+    @Log(value = "修改站点详情信息", module = LogModuleEnum.OTHER)
+    public Result<Boolean> updateStationDetail(@Valid @RequestBody StationDetailDTO dto) {
+        boolean result = chargingService.updateStationDetail(dto);
+        return Result.success(result);
+    }
+
 }

+ 39 - 0
src/main/java/com/zsElectric/boot/business/model/dto/StationDetailDTO.java

@@ -0,0 +1,39 @@
+package com.zsElectric.boot.business.model.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 充电站详情修改DTO
+ *
+ * @author system
+ * @since 2025-12-17
+ */
+@Data
+@Schema(description = "充电站详情修改DTO")
+public class StationDetailDTO implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    @Schema(description = "站点ID", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotNull(message = "站点ID不能为空")
+    private Long id;
+
+    @Schema(description = "站点提示语")
+    private String stationTips;
+
+    @Schema(description = "自有营业时间(如:周一至周日 00:00-24:00)")
+    private String ownBusinessHours;
+
+    @Schema(description = "客服热线(如:400-0000-0000)")
+    private String customerServiceHotline;
+
+    @Schema(description = "站点Banner图片列表")
+    private List<String> bannerPictures;
+}

+ 40 - 0
src/main/java/com/zsElectric/boot/business/model/vo/StationDetailVO.java

@@ -0,0 +1,40 @@
+package com.zsElectric.boot.business.model.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 充电站详情VO
+ *
+ * @author system
+ * @since 2025-12-17
+ */
+@Data
+@Schema(description = "充电站详情VO")
+public class StationDetailVO implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    @Schema(description = "站点ID")
+    private Long id;
+
+    @Schema(description = "充电站名称")
+    private String stationName;
+
+    @Schema(description = "站点提示语")
+    private String stationTips;
+
+    @Schema(description = "自有营业时间(如:周一至周日 00:00-24:00)")
+    private String ownBusinessHours;
+
+    @Schema(description = "客服热线(如:400-0000-0000)")
+    private String customerServiceHotline;
+
+    @Schema(description = "站点Banner图片列表")
+    private List<String> bannerPictures;
+}

+ 18 - 0
src/main/java/com/zsElectric/boot/business/service/ThirdPartyChargingService.java

@@ -1,11 +1,13 @@
 package com.zsElectric.boot.business.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.zsElectric.boot.business.model.dto.StationDetailDTO;
 import com.zsElectric.boot.business.model.query.ThirdPartyEquipmentInfoQuery;
 import com.zsElectric.boot.business.model.query.ThirdPartyStationInfoQuery;
 import com.zsElectric.boot.business.model.vo.PartyStationInfoVO;
 import com.zsElectric.boot.business.model.vo.ThirdPartyEquipmentInfoVO;
 import com.zsElectric.boot.business.model.vo.ThirdPartyStationInfoVO;
+import com.zsElectric.boot.business.model.vo.StationDetailVO;
 import com.zsElectric.boot.charging.vo.ChargingPricePolicyVO;
 import com.zsElectric.boot.charging.vo.QueryStationsInfoVO;
 
@@ -72,4 +74,20 @@ public interface ThirdPartyChargingService {
      * @return 操作结果
      */
     boolean updateStationTips(Long stationId, String stationTips);
+
+    /**
+     * 查询站点详情信息(banner、提示语、营业时间、客服电话)
+     *
+     * @param stationId 站点ID
+     * @return 站点详情信息
+     */
+    StationDetailVO getStationDetail(Long stationId);
+
+    /**
+     * 修改站点详情信息(banner、提示语、营业时间、客服电话)
+     *
+     * @param dto 站点详情修改DTO
+     * @return 操作结果
+     */
+    boolean updateStationDetail(StationDetailDTO dto);
 }

+ 60 - 1
src/main/java/com/zsElectric/boot/business/service/impl/ThirdPartyChargingServiceImpl.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.zsElectric.boot.charging.entity.*;
 import com.zsElectric.boot.business.mapper.FirmInfoMapper;
@@ -21,6 +22,8 @@ import com.zsElectric.boot.business.model.query.ThirdPartyStationInfoQuery;
 import com.zsElectric.boot.business.model.vo.PartyStationInfoVO;
 import com.zsElectric.boot.business.model.vo.ThirdPartyEquipmentInfoVO;
 import com.zsElectric.boot.business.model.vo.ThirdPartyStationInfoVO;
+import com.zsElectric.boot.business.model.vo.StationDetailVO;
+import com.zsElectric.boot.business.model.dto.StationDetailDTO;
 import com.zsElectric.boot.business.service.ThirdPartyChargingService;
 import com.zsElectric.boot.charging.vo.ChargingPricePolicyVO;
 import com.zsElectric.boot.charging.vo.QueryStationsInfoVO;
@@ -184,8 +187,12 @@ public class ThirdPartyChargingServiceImpl implements ThirdPartyChargingService
         ThirdPartyStationInfo entity = new ThirdPartyStationInfo();
         if (existingStation != null) {
             entity.setId(existingStation.getId());
-            // 保留原有的配置状态
+            // 保留原有的自有字段(不会被第三方接口覆盖)
             entity.setPolicyConfigured(existingStation.getPolicyConfigured());
+            entity.setStationTips(existingStation.getStationTips());
+            entity.setOwnBusinessHours(existingStation.getOwnBusinessHours());
+            entity.setCustomerServiceHotline(existingStation.getCustomerServiceHotline());
+            entity.setBannerPictures(existingStation.getBannerPictures());
         }
 
         // 设置字段值
@@ -692,4 +699,56 @@ public class ThirdPartyChargingServiceImpl implements ThirdPartyChargingService
                 .eq(ThirdPartyStationInfo::getId, stationId)
                 .set(ThirdPartyStationInfo::getStationTips, stationTips)) > 0;
     }
+
+    @Override
+    public StationDetailVO getStationDetail(Long stationId) {
+        ThirdPartyStationInfo station = stationInfoMapper.selectById(stationId);
+        if (station == null) {
+            return null;
+        }
+
+        StationDetailVO vo = new StationDetailVO();
+        vo.setId(station.getId());
+        vo.setStationName(station.getStationName());
+        vo.setStationTips(station.getStationTips());
+        vo.setOwnBusinessHours(station.getOwnBusinessHours());
+        vo.setCustomerServiceHotline(station.getCustomerServiceHotline());
+
+        // 解析banner图片JSON
+        if (station.getBannerPictures() != null) {
+            try {
+                vo.setBannerPictures(objectMapper.readValue(station.getBannerPictures(), new TypeReference<List<String>>() {}));
+            } catch (JsonProcessingException e) {
+                log.warn("解析banner图片失败", e);
+            }
+        }
+
+        return vo;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean updateStationDetail(StationDetailDTO dto) {
+        ThirdPartyStationInfo station = stationInfoMapper.selectById(dto.getId());
+        if (station == null) {
+            return false;
+        }
+
+        // 转banner图片为JSON
+        String bannerJson = null;
+        if (dto.getBannerPictures() != null) {
+            try {
+                bannerJson = objectMapper.writeValueAsString(dto.getBannerPictures());
+            } catch (JsonProcessingException e) {
+                log.warn("banner图片转JSON失败", e);
+            }
+        }
+
+        return stationInfoMapper.update(null, Wrappers.<ThirdPartyStationInfo>lambdaUpdate()
+                .eq(ThirdPartyStationInfo::getId, dto.getId())
+                .set(ThirdPartyStationInfo::getStationTips, dto.getStationTips())
+                .set(ThirdPartyStationInfo::getOwnBusinessHours, dto.getOwnBusinessHours())
+                .set(ThirdPartyStationInfo::getCustomerServiceHotline, dto.getCustomerServiceHotline())
+                .set(bannerJson != null, ThirdPartyStationInfo::getBannerPictures, bannerJson)) > 0;
+    }
 }

+ 15 - 0
src/main/java/com/zsElectric/boot/charging/entity/ThirdPartyStationInfo.java

@@ -151,6 +151,21 @@ public class ThirdPartyStationInfo extends BaseEntity {
      */
     private String stationTips;
 
+    /**
+     * 自有营业时间(如:周一至周日 00:00-24:00)
+     */
+    private String ownBusinessHours;
+
+    /**
+     * 客服热线(如:400-0000-0000)
+     */
+    private String customerServiceHotline;
+
+    /**
+     * 站点Banner图片(JSON数组)
+     */
+    private String bannerPictures;
+
     /**
      * 创建人ID
      */