PigX Server 後端開發

👤 zhibuyu 📦 v1.0.0 ⭐ 4.1 ⬇️ 714 下載
💻 開發程式設計 免費

📖 技能介紹


name: pigxserver-skill version: 1.0.0 description: PigX 企業級微服務平臺後端開發指南 - Spring Cloud Alibaba + Java 17。當用戶提到 PigX Server、PigX 後端、lhb-server 專案、Spring Cloud 微服務開發、PigX 微服務架構時使用此技能。


PigX Server 後端開發 Skill

PigX 企業級微服務平臺開發指南 - Spring Cloud Alibaba + Java 17

專案資訊

屬性
Java 版本 Java 17
Spring Boot 3.5.9
Spring Cloud 2025.0.1
Spring Cloud Alibaba 2023.0.3.3
AI/ML LangChain4j 1.6.0, Spring AI 1.0.2
資料庫 MySQL + PostgreSQL (pgvector)
ORM MyBatis-Plus
服務發現 Nacos
構建工具 Maven
版本 5.11.0

本地專案路徑

D:\WorkSpace\my_workspace\lhb\lhb-server

官方文件

  • 文件入口: https://docs.pig4cloud.com(需要微信掃碼登入)

常用命令

# 構建專案(微服務模式)
mvn clean install

# 構建單體模式
mvn clean install -P boot

# 構建指定模組
mvn clean install -pl pigx-knowledge

# 跳過測試
mvn clean install -DskipTests

# 格式化程式碼
mvn spring-javaformat:apply

# 執行單體模式
cd pigx-boot && mvn spring-boot:run

專案結構

lhb-server/
├── pigx-boot/           # 單體部署啟動器
├── pigx-auth/           # 認證模組
├── pigx-upms/           # 使用者許可權管理模組
├── pigx-gateway/        # API 閘道器
├── pigx-register/       # Nacos 註冊中心
├── pigx-visual/         # 視覺化管理模組
├── pigx-common/         # 公共模組
├── db/                  # 資料庫初始化指令碼
└── docker-compose.yml   # Docker 編排配置

公共模組說明

模組 功能
pigx-common-bom 依賴版本管理
pigx-common-core 核心工具類
pigx-common-security 安全認證
pigx-common-oss 物件儲存
pigx-common-excel Excel 處理
pigx-common-feign Feign 遠端呼叫
pigx-common-gateway 閘道器配置
pigx-common-job 定時任務
pigx-common-log 日誌處理
pigx-common-swagger API 文件
pigx-common-websocket WebSocket 支援
pigx-common-seata 分散式事務
pigx-common-sentinel 限流熔斷

核心開發規範

1. 包命名規範

型別 命名規則 示例
Controller 字尾 Controller AiDatasetController
Service 介面 無後綴 EmbeddingStoreService
Service 實現 字尾 Impl EmbeddingStoreServiceImpl
Mapper 字尾 Mapper AiDatasetMapper
Entity 字尾 Entity AiDatasetEntity
DTO 字尾 DTO AiMultimodalEmbeddingArkDTO
Enum 字尾 Enums EmbedBizTypeEnums

2. Controller 示例

@RestController
@RequestMapping("/xxx")
@RequiredArgsConstructor
public class XxxController {

    private final XxxService xxxService;

    @GetMapping("/page")
    public R<IPage<XxxEntity>> page(Page page, XxxEntity entity) {
        return R.ok(xxxService.page(page, entity));
    }

    @PostMapping
    public R<Boolean> save(@RequestBody XxxEntity entity) {
        return R.ok(xxxService.save(entity));
    }

    @DeleteMapping("/{id}")
    public R<Boolean> deleteById(@PathVariable Long id) {
        return R.ok(xxxService.removeById(id));
    }
}

3. Service 示例

public interface XxxService extends IService<XxxEntity> {}

@Service
@RequiredArgsConstructor
public class XxxServiceImpl implements XxxService {
    private final XxxMapper xxxMapper;

    @Override
    public IPage<XxxEntity> page(Page page, XxxEntity entity) {
        return xxxMapper.selectPage(page, entity);
    }
}

4. Entity 示例

@Data
@TableName("xxx_table")
public class XxxEntity implements Serializable {
    @TableId(type = IdType.ASSIGN_ID)
    private Long id;
    private String name;
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;
}

AI/RAG 開發

向量儲存工廠模式

@Component
public class QdrantEmbeddingStoreFactory implements EmbeddingStoreFactory {
    @Override
    public boolean support(String storeType) {
        return "QDRANT".equals(storeType);
    }

    @Override
    public EmbeddingStore createEmbeddingStore(EmbedStoreEntity store, DatasetEntity dataset) {
        // 建立向量儲存例項
    }
}

支援的向量儲存

Qdrant、Milvus、Chroma、PGVector、Neo4j


資料庫配置

spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/pigxx_boot
    username: postgres
    password: postgres
  redis:
    host: 127.0.0.1
    database: 5
  cloud:
    nacos:
      server-addr: pigx-register:8848

注意事項

  1. 程式碼格式化:提交前執行 mvn spring-javaformat:apply
  2. 安全配置:配置檔案已加密,密碼為 pigx
  3. Git 分支:主分支 dev
  4. 版本:Java 17+,Spring Boot 3.5.9

參考文件

  • Spring Cloud Alibaba: https://sca.aliyun.com
  • MyBatis-Plus: https://baomidou.com
  • LangChain4j: https://docs.langchain4j.dev

參考資料

7w4.net收錄了海量優質技能外掛。

更多後端文件請參考 references/ 目錄下的文件檔案。

🤖 AI 評測

這個 Skill 提供了 PigX 後端專案的基本框架和使用方向,結構清晰、容易理解,程式碼規範說明較為實用。但內容整體偏基礎,實際開發指導不夠深入,複雜功能的使用方法介紹較少,作為開發參考時可能需要補充其他資料。適合初步瞭解專案結構,不適合作為深入開發的唯一依據。

📊 多維度評分

適應性3.8
規範性4.1
有效性4.2
可靠性3.8
可信度4.8

📁 包含檔案 (2 個)

📄 SKILL.md 5.2 KB
📄 _meta.json 135 B