Parcourir la source

feat(third-party): 新增第三方对接信息管理模块

- 添加ThirdPartyInfo实体类,定义第三方对接信息数据结构
- 新增ThirdPartyInfoMapper及对应XML,支持分页查询及数据操作
- 创建ThirdPartyInfoService接口及实现类,实现增删改查及列表获取功能
- 开发ThirdPartyInfoController提供REST API,实现分页查询、详情获取、新增、修改、删除接口
- 新增ThirdPartyInfoForm和ThirdPartyInfoQuery,用于请求参数封装及校验
- 添加ThirdPartyInfoVO用于对外数据展示
- 修改PartyStationInfoVO,优化字段描述为“名称”而非“充电站名称”
SheepHy il y a 1 jour
Parent
commit
2f91ab37d9

+ 76 - 0
src/main/java/com/zsElectric/boot/business/controller/ThirdPartyInfoController.java

@@ -0,0 +1,76 @@
+package com.zsElectric.boot.business.controller;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zsElectric.boot.business.model.form.ThirdPartyInfoForm;
+import com.zsElectric.boot.business.model.query.ThirdPartyInfoQuery;
+import com.zsElectric.boot.business.model.vo.ThirdPartyInfoVO;
+import com.zsElectric.boot.business.service.ThirdPartyInfoService;
+import com.zsElectric.boot.common.annotation.Log;
+import com.zsElectric.boot.common.enums.LogModuleEnum;
+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.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 第三方对接信息控制器
+ *
+ * @author system
+ * @since 2025-12-15
+ */
+@Tag(name = "渠道方对接信息管理接口")
+@RestController
+@RequestMapping("/api/v1/third-party-info")
+@RequiredArgsConstructor
+public class ThirdPartyInfoController {
+
+    private final ThirdPartyInfoService thirdPartyInfoService;
+
+    @Operation(summary = "渠道方对接信息分页列表")
+    @PostMapping("/page")
+    @Log(value = "渠道方对接信息分页列表", module = LogModuleEnum.OTHER)
+    public PageResult<ThirdPartyInfoVO> getThirdPartyInfoPage(@RequestBody ThirdPartyInfoQuery queryParams) {
+        Page<ThirdPartyInfoVO> result = thirdPartyInfoService.getThirdPartyInfoPage(queryParams);
+        return PageResult.success(result);
+    }
+
+    @Operation(summary = "根据ID获取渠道方对接信息详情")
+    @GetMapping("/{id}")
+    @Log(value = "获取渠道方对接信息详情", module = LogModuleEnum.OTHER)
+    public Result<ThirdPartyInfoVO> getThirdPartyInfoById(
+            @Parameter(description = "主键ID") @PathVariable Long id) {
+        ThirdPartyInfoVO result = thirdPartyInfoService.getThirdPartyInfoById(id);
+        return Result.success(result);
+    }
+
+    @Operation(summary = "新增渠道方对接信息")
+    @PostMapping
+    @Log(value = "新增渠道方对接信息", module = LogModuleEnum.OTHER)
+    public Result<Boolean> addThirdPartyInfo(@Validated @RequestBody ThirdPartyInfoForm form) {
+        boolean result = thirdPartyInfoService.addThirdPartyInfo(form);
+        return Result.success(result);
+    }
+
+    @Operation(summary = "修改第三方对接信息")
+    @PutMapping
+    @Log(value = "修改渠道方对接信息", module = LogModuleEnum.OTHER)
+    public Result<Boolean> updateThirdPartyInfo(@Validated @RequestBody ThirdPartyInfoForm form) {
+        boolean result = thirdPartyInfoService.updateThirdPartyInfo(form);
+        return Result.success(result);
+    }
+
+    @Operation(summary = "删除第三方对接信息")
+    @DeleteMapping("/{id}")
+    @Log(value = "删除渠道方对接信息", module = LogModuleEnum.OTHER)
+    public Result<Boolean> deleteThirdPartyInfo(
+            @Parameter(description = "主键ID") @PathVariable Long id) {
+        boolean result = thirdPartyInfoService.deleteThirdPartyInfo(id);
+        return Result.success(result);
+    }
+
+
+}

+ 28 - 0
src/main/java/com/zsElectric/boot/business/mapper/ThirdPartyInfoMapper.java

@@ -0,0 +1,28 @@
+package com.zsElectric.boot.business.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zsElectric.boot.business.model.entity.ThirdPartyInfo;
+import com.zsElectric.boot.business.model.query.ThirdPartyInfoQuery;
+import com.zsElectric.boot.business.model.vo.ThirdPartyInfoVO;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 第三方对接信息Mapper接口
+ *
+ * @author system
+ * @since 2025-12-15
+ */
+@Mapper
+public interface ThirdPartyInfoMapper extends BaseMapper<ThirdPartyInfo> {
+
+    /**
+     * 分页查询第三方对接信息
+     *
+     * @param page 分页对象
+     * @param query 查询条件
+     * @return 第三方对接信息分页列表
+     */
+    Page<ThirdPartyInfoVO> selectThirdPartyInfoPage(Page<ThirdPartyInfoVO> page, @Param("query") ThirdPartyInfoQuery query);
+}

+ 73 - 0
src/main/java/com/zsElectric/boot/business/model/entity/ThirdPartyInfo.java

@@ -0,0 +1,73 @@
+package com.zsElectric.boot.business.model.entity;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.zsElectric.boot.common.base.BaseEntity;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 第三方对接信息实体
+ *
+ * @author system
+ * @since 2025-12-15
+ */
+@TableName("c_third_party_info")
+@Getter
+@Setter
+public class ThirdPartyInfo extends BaseEntity {
+
+    /**
+     * 对接商名称
+     */
+    private String ecName;
+
+    /**
+     * 联系人
+     */
+    private String contactName;
+
+    /**
+     * 联系人电话
+     */
+    private String contactPhone;
+
+    /**
+     * 协议附件
+     */
+    private String ecAttach;
+
+    /**
+     * 对接编号
+     */
+    private String appId;
+
+    /**
+     * 授权码
+     */
+    private String authCode;
+
+    /**
+     * 状态(0-正常 1-停用)
+     */
+    private Integer status;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 创建人ID
+     */
+    @TableField(fill = FieldFill.INSERT)
+    private Long createBy;
+
+    /**
+     * 逻辑删除(0-未删除 1-已删除)
+     */
+    @TableLogic
+    private Integer isDeleted;
+}

+ 45 - 0
src/main/java/com/zsElectric/boot/business/model/form/ThirdPartyInfoForm.java

@@ -0,0 +1,45 @@
+package com.zsElectric.boot.business.model.form;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * 第三方对接信息表单
+ *
+ * @author system
+ * @since 2025-12-15
+ */
+@Schema(description = "第三方对接信息表单")
+@Data
+public class ThirdPartyInfoForm {
+
+    @Schema(description = "主键ID")
+    private Long id;
+
+    @Schema(description = "对接商名称", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotBlank(message = "对接商名称不能为空")
+    private String ecName;
+
+    @Schema(description = "联系人")
+    private String contactName;
+
+    @Schema(description = "联系人电话")
+    private String contactPhone;
+
+    @Schema(description = "协议附件")
+    private String ecAttach;
+
+    @Schema(description = "对接编号")
+    private String appId;
+
+    @Schema(description = "授权码")
+    private String authCode;
+
+    @Schema(description = "状态(0-正常 1-停用)")
+    private Integer status;
+
+    @Schema(description = "备注")
+    private String remark;
+}

+ 33 - 0
src/main/java/com/zsElectric/boot/business/model/query/ThirdPartyInfoQuery.java

@@ -0,0 +1,33 @@
+package com.zsElectric.boot.business.model.query;
+
+import com.zsElectric.boot.common.base.BasePageQuery;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 第三方对接信息查询对象
+ *
+ * @author system
+ * @since 2025-12-15
+ */
+@Schema(description = "第三方对接信息查询对象")
+@Getter
+@Setter
+public class ThirdPartyInfoQuery extends BasePageQuery {
+
+    @Schema(description = "对接商名称")
+    private String ecName;
+
+    @Schema(description = "联系人")
+    private String contactName;
+
+    @Schema(description = "联系人电话")
+    private String contactPhone;
+
+    @Schema(description = "对接编号")
+    private String appId;
+
+    @Schema(description = "状态(0-正常 1-停用)")
+    private Integer status;
+}

+ 1 - 1
src/main/java/com/zsElectric/boot/business/model/vo/PartyStationInfoVO.java

@@ -8,6 +8,6 @@ import lombok.Data;
 public class PartyStationInfoVO {
     @Schema(description = "主键ID")
     private Long id;
-    @Schema(description = "充电站名称")
+    @Schema(description = "名称")
     private String stationName;
 }

+ 53 - 0
src/main/java/com/zsElectric/boot/business/model/vo/ThirdPartyInfoVO.java

@@ -0,0 +1,53 @@
+package com.zsElectric.boot.business.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * 第三方对接信息VO
+ *
+ * @author system
+ * @since 2025-12-15
+ */
+@Schema(description = "第三方对接信息VO")
+@Data
+public class ThirdPartyInfoVO {
+
+    @Schema(description = "主键ID")
+    private Long id;
+
+    @Schema(description = "对接商名称")
+    private String ecName;
+
+    @Schema(description = "联系人")
+    private String contactName;
+
+    @Schema(description = "联系人电话")
+    private String contactPhone;
+
+    @Schema(description = "协议附件")
+    private String ecAttach;
+
+    @Schema(description = "对接编号")
+    private String appId;
+
+    @Schema(description = "授权码")
+    private String authCode;
+
+    @Schema(description = "状态(0-正常 1-停用)")
+    private Integer status;
+
+    @Schema(description = "备注")
+    private String remark;
+
+    @Schema(description = "创建时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime createTime;
+
+    @Schema(description = "更新时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime updateTime;
+}

+ 63 - 0
src/main/java/com/zsElectric/boot/business/service/ThirdPartyInfoService.java

@@ -0,0 +1,63 @@
+package com.zsElectric.boot.business.service;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zsElectric.boot.business.model.form.ThirdPartyInfoForm;
+import com.zsElectric.boot.business.model.query.ThirdPartyInfoQuery;
+import com.zsElectric.boot.business.model.vo.PartyStationInfoVO;
+import com.zsElectric.boot.business.model.vo.ThirdPartyInfoVO;
+
+import java.util.List;
+
+/**
+ * 第三方对接信息服务接口
+ *
+ * @author system
+ * @since 2025-12-15
+ */
+public interface ThirdPartyInfoService {
+
+    /**
+     * 分页查询第三方对接信息
+     *
+     * @param queryParams 查询参数
+     * @return 第三方对接信息分页列表
+     */
+    Page<ThirdPartyInfoVO> getThirdPartyInfoPage(ThirdPartyInfoQuery queryParams);
+
+    /**
+     * 根据ID获取第三方对接信息详情
+     *
+     * @param id 主键ID
+     * @return 第三方对接信息详情
+     */
+    ThirdPartyInfoVO getThirdPartyInfoById(Long id);
+
+    /**
+     * 新增第三方对接信息
+     *
+     * @param form 表单数据
+     * @return 是否成功
+     */
+    boolean addThirdPartyInfo(ThirdPartyInfoForm form);
+
+    /**
+     * 修改第三方对接信息
+     *
+     * @param form 表单数据
+     * @return 是否成功
+     */
+    boolean updateThirdPartyInfo(ThirdPartyInfoForm form);
+
+    /**
+     * 删除第三方对接信息
+     *
+     * @param id 主键ID
+     * @return 是否成功
+     */
+    boolean deleteThirdPartyInfo(Long id);
+
+    /**
+     * 获取渠道方集合
+     * */
+    List<PartyStationInfoVO> getPartyStationInfoList();
+}

+ 92 - 0
src/main/java/com/zsElectric/boot/business/service/impl/ThirdPartyInfoServiceImpl.java

@@ -0,0 +1,92 @@
+package com.zsElectric.boot.business.service.impl;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zsElectric.boot.business.mapper.ThirdPartyInfoMapper;
+import com.zsElectric.boot.business.model.entity.ThirdPartyInfo;
+import com.zsElectric.boot.business.model.form.ThirdPartyInfoForm;
+import com.zsElectric.boot.business.model.query.ThirdPartyInfoQuery;
+import com.zsElectric.boot.business.model.vo.PartyStationInfoVO;
+import com.zsElectric.boot.business.model.vo.ThirdPartyInfoVO;
+import com.zsElectric.boot.business.service.ThirdPartyInfoService;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 第三方对接信息服务实现
+ *
+ * @author system
+ * @since 2025-12-15
+ */
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class ThirdPartyInfoServiceImpl implements ThirdPartyInfoService {
+
+    private final ThirdPartyInfoMapper thirdPartyInfoMapper;
+
+    @Override
+    public Page<ThirdPartyInfoVO> getThirdPartyInfoPage(ThirdPartyInfoQuery queryParams) {
+        // 构建分页
+        Page<ThirdPartyInfoVO> page = new Page<>(queryParams.getPageNum(), queryParams.getPageSize());
+
+        // 调用Mapper分页查询
+        return thirdPartyInfoMapper.selectThirdPartyInfoPage(page, queryParams);
+    }
+
+    @Override
+    public ThirdPartyInfoVO getThirdPartyInfoById(Long id) {
+        ThirdPartyInfo entity = thirdPartyInfoMapper.selectById(id);
+        if (entity == null) {
+            return null;
+        }
+
+        ThirdPartyInfoVO vo = new ThirdPartyInfoVO();
+        BeanUtils.copyProperties(entity, vo);
+        return vo;
+    }
+
+    @Override
+    public boolean addThirdPartyInfo(ThirdPartyInfoForm form) {
+        ThirdPartyInfo entity = new ThirdPartyInfo();
+        BeanUtils.copyProperties(form, entity);
+
+        return thirdPartyInfoMapper.insert(entity) > 0;
+    }
+
+    @Override
+    public boolean updateThirdPartyInfo(ThirdPartyInfoForm form) {
+        if (form.getId() == null) {
+            throw new IllegalArgumentException("ID不能为空");
+        }
+
+        ThirdPartyInfo entity = new ThirdPartyInfo();
+        BeanUtils.copyProperties(form, entity);
+
+        return thirdPartyInfoMapper.updateById(entity) > 0;
+    }
+
+    @Override
+    public boolean deleteThirdPartyInfo(Long id) {
+        return thirdPartyInfoMapper.deleteById(id) > 0;
+    }
+
+    @Override
+    public List<PartyStationInfoVO> getPartyStationInfoList() {
+        List<ThirdPartyInfo> thirdPartyInfos = thirdPartyInfoMapper.selectList(null);
+        
+        // 转换为VO列表
+        return thirdPartyInfos.stream()
+                .map(info -> {
+                    PartyStationInfoVO vo = new PartyStationInfoVO();
+                    vo.setId(info.getId());
+                    vo.setStationName(info.getEcName());
+                    return vo;
+                })
+                .collect(Collectors.toList());
+    }
+}

+ 40 - 0
src/main/resources/mapper/business/ThirdPartyInfoMapper.xml

@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zsElectric.boot.business.mapper.ThirdPartyInfoMapper">
+
+    <select id="selectThirdPartyInfoPage" resultType="com.zsElectric.boot.business.model.vo.ThirdPartyInfoVO">
+        SELECT
+            id,
+            ec_name,
+            contact_name,
+            contact_phone,
+            ec_attach,
+            app_id,
+            auth_code,
+            status,
+            remark,
+            create_time,
+            update_time
+        FROM c_third_party_info
+        <where>
+            is_deleted = 0
+            <if test="query.ecName != null and query.ecName != ''">
+                AND ec_name LIKE CONCAT('%', #{query.ecName}, '%')
+            </if>
+            <if test="query.contactName != null and query.contactName != ''">
+                AND contact_name LIKE CONCAT('%', #{query.contactName}, '%')
+            </if>
+            <if test="query.contactPhone != null and query.contactPhone != ''">
+                AND contact_phone = #{query.contactPhone}
+            </if>
+            <if test="query.appId != null and query.appId != ''">
+                AND app_id = #{query.appId}
+            </if>
+            <if test="query.status != null">
+                AND status = #{query.status}
+            </if>
+        </where>
+        ORDER BY create_time DESC
+    </select>
+
+</mapper>