diff --git a/backend-java/README.md b/backend-java/README.md deleted file mode 100644 index 3a16e95..0000000 --- a/backend-java/README.md +++ /dev/null @@ -1,82 +0,0 @@ -# NiuMall 后端服务 (Java 版本) - -活牛采购智能数字化系统 - 后端服务 - -## 项目介绍 - -本项目是将原有的 Node.js 后端服务重构为基于 Java 的微服务架构,使用 Spring Boot 和 Spring Cloud 构建。 - -## 技术栈 - -- Java 17 -- Spring Boot 3.1.0 -- Spring Cloud 2022.0.3 -- Spring Data JPA -- MySQL 8.0 -- Maven 3.8+ - -## 服务架构 - -- **user-service**: 用户服务 -- **auth-service**: 认证服务 -- **order-service**: 订单服务 -- **supplier-service**: 供应商服务 -- **transport-service**: 运输服务 -- **finance-service**: 财务服务 -- **quality-service**: 质检服务 - -## 项目结构 - -``` -backend-java/ -├── auth-service/ # 认证服务 -├── user-service/ # 用户服务 -├── order-service/ # 订单服务 -├── supplier-service/ # 供应商服务 -├── transport-service/ # 运输服务 -├── finance-service/ # 财务服务 -├── quality-service/ # 质检服务 -├── common/ # 公共模块 -└── docs/ # 文档 -``` - -## 构建和运行 - -### 环境要求 - -- JDK 17+ -- Maven 3.8+ -- MySQL 8.0+ - -### 构建项目 - -```bash -# 进入项目根目录 -cd backend-java - -# 编译项目 -mvn clean compile - -# 打包项目 -mvn clean package -``` - -### 运行服务 - -```bash -# 运行用户服务 -cd user-service -mvn spring-boot:run -``` - -## 数据库配置 - -项目使用 MySQL 数据库,连接配置在各个服务的 `application.yml` 文件中。 - -## API 文档 - -API 文档使用 Swagger 生成,启动服务后访问 `http://localhost:8080/swagger-ui.html` 查看。 - -## 部署 - -推荐使用 Docker 进行部署,每个服务都可以独立打包成 Docker 镜像。 \ No newline at end of file diff --git a/backend-java/RUN_INSTRUCTIONS.md b/backend-java/RUN_INSTRUCTIONS.md deleted file mode 100644 index 3bac14e..0000000 --- a/backend-java/RUN_INSTRUCTIONS.md +++ /dev/null @@ -1,103 +0,0 @@ -# Java 后端服务运行说明 - -## 环境要求 - -1. JDK 17 或更高版本 -2. Maven 3.8 或更高版本 - -## 安装 Maven(如果尚未安装) - -### macOS - -如果已安装 Homebrew: -```bash -brew install maven -``` - -如果没有安装 Homebrew,先安装 Homebrew: -```bash -/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -``` -然后安装 Maven: -```bash -brew install maven -``` - -### Windows - -1. 访问 [Maven 官网](https://maven.apache.org/download.cgi) -2. 下载最新版本的 Maven -3. 解压到指定目录 -4. 配置环境变量: - - 添加 MAVEN_HOME 环境变量,指向 Maven 安装目录 - - 将 %MAVEN_HOME%\bin 添加到 PATH 环境变量 - -### Linux (Ubuntu/Debian) - -```bash -sudo apt update -sudo apt install maven -``` - -## 构建和运行服务 - -### 1. 使用 Maven Wrapper(推荐) - -首先初始化 Maven Wrapper: -```bash -cd backend-java -mvn -N io.takari:maven:wrapper -``` - -然后构建项目: -```bash -cd user-service -./mvnw clean compile -``` - -### 2. 直接使用 Maven - -如果已安装 Maven: -```bash -cd backend-java/user-service -mvn clean compile -mvn spring-boot:run -``` - -### 3. 打包并运行 - -```bash -cd backend-java/user-service -mvn clean package -java -jar target/*.jar -``` - -## 服务访问 - -用户服务默认运行在 8081 端口: -- 健康检查: http://localhost:8081/actuator/health -- 用户 API: http://localhost:8081/api/users - -## 数据库配置 - -服务会自动连接到配置文件中指定的 MySQL 数据库: -- 主机: 129.211.213.226 -- 端口: 9527 -- 数据库: jiebandata -- 用户名: root -- 密码: aiotAiot123! - -确保网络可以访问该数据库服务器。 - -## 常见问题 - -1. **端口被占用**: 修改 `application.yml` 中的 `server.port` 配置 -2. **数据库连接失败**: 检查网络连接和数据库配置 -3. **依赖下载失败**: 配置 Maven 镜像源或检查网络连接 - -## 开发工具 - -推荐使用以下 IDE 进行开发: -- IntelliJ IDEA -- Eclipse with Spring Tools -- VS Code with Java extensions \ No newline at end of file diff --git a/backend-java/pom.xml b/backend-java/pom.xml deleted file mode 100644 index 2eb8f8a..0000000 --- a/backend-java/pom.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - 4.0.0 - - com.niumall - niumall-backend - 1.0.0 - pom - - NiuMall Backend - 活牛采购智能数字化系统 - 后端服务 (Java版本) - - - auth-service - user-service - order-service - supplier-service - transport-service - finance-service - quality-service - common - - - - 17 - 17 - UTF-8 - 3.1.0 - 2022.0.3 - - - - - - org.springframework.boot - spring-boot-dependencies - ${spring.boot.version} - pom - import - - - org.springframework.cloud - spring-cloud-dependencies - ${spring.cloud.version} - pom - import - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - \ No newline at end of file diff --git a/backend-java/user-service/pom.xml b/backend-java/user-service/pom.xml deleted file mode 100644 index 40d8517..0000000 --- a/backend-java/user-service/pom.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - 4.0.0 - - com.niumall - niumall-backend - 1.0.0 - - - user-service - User Service - 用户服务 - - - 17 - 17 - UTF-8 - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.springframework.boot - spring-boot-starter-validation - - - mysql - mysql-connector-java - 8.0.33 - - - org.projectlombok - lombok - true - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - \ No newline at end of file diff --git a/backend-java/user-service/run.sh b/backend-java/user-service/run.sh deleted file mode 100755 index ea5c976..0000000 --- a/backend-java/user-service/run.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -echo "=========================================" -echo " NiuMall User Service" -echo "=========================================" -echo -echo "要运行此服务,请确保已安装:" -echo "1. JDK 17 或更高版本" -echo "2. Maven 3.8 或更高版本" -echo -echo "运行步骤:" -echo "1. 打开终端并导航到 user-service 目录" -echo "2. 执行以下命令:" -echo " mvn spring-boot:run" -echo -echo "服务将在端口 8081 上启动" -echo "API 地址: http://localhost:8081/api/users" -echo -echo "注意:确保可以访问数据库服务器 129.211.213.226:9527" \ No newline at end of file diff --git a/backend-java/user-service/src/main/java/com/niumall/userservice/UserServiceApplication.java b/backend-java/user-service/src/main/java/com/niumall/userservice/UserServiceApplication.java deleted file mode 100644 index cbfda96..0000000 --- a/backend-java/user-service/src/main/java/com/niumall/userservice/UserServiceApplication.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.niumall.userservice; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class UserServiceApplication { - public static void main(String[] args) { - SpringApplication.run(UserServiceApplication.class, args); - } -} \ No newline at end of file diff --git a/backend-java/user-service/src/main/java/com/niumall/userservice/controller/UserController.java b/backend-java/user-service/src/main/java/com/niumall/userservice/controller/UserController.java deleted file mode 100644 index ac336e0..0000000 --- a/backend-java/user-service/src/main/java/com/niumall/userservice/controller/UserController.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.niumall.userservice.controller; - -import com.niumall.userservice.entity.User; -import com.niumall.userservice.service.UserService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -@RestController -@RequestMapping("/api/users") -public class UserController { - - @Autowired - private UserService userService; - - @GetMapping - public ResponseEntity> getAllUsers() { - List users = userService.getAllUsers(); - return ResponseEntity.ok(users); - } - - @GetMapping("/{id}") - public ResponseEntity getUserById(@PathVariable Long id) { - User user = userService.getUserById(id); - if (user != null) { - return ResponseEntity.ok(user); - } else { - return ResponseEntity.notFound().build(); - } - } - - @PostMapping - public ResponseEntity createUser(@RequestBody User user) { - User savedUser = userService.createUser(user); - return ResponseEntity.ok(savedUser); - } - - @PutMapping("/{id}") - public ResponseEntity updateUser(@PathVariable Long id, @RequestBody User user) { - User updatedUser = userService.updateUser(id, user); - if (updatedUser != null) { - return ResponseEntity.ok(updatedUser); - } else { - return ResponseEntity.notFound().build(); - } - } - - @DeleteMapping("/{id}") - public ResponseEntity deleteUser(@PathVariable Long id) { - userService.deleteUser(id); - return ResponseEntity.noContent().build(); - } -} \ No newline at end of file diff --git a/backend-java/user-service/src/main/java/com/niumall/userservice/entity/User.java b/backend-java/user-service/src/main/java/com/niumall/userservice/entity/User.java deleted file mode 100644 index 82b7ef6..0000000 --- a/backend-java/user-service/src/main/java/com/niumall/userservice/entity/User.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.niumall.userservice.entity; - -import jakarta.persistence.*; -import lombok.Data; -import java.time.LocalDateTime; - -@Data -@Entity -@Table(name = "api_users") -public class User { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(unique = true, nullable = false) - private String username; - - @Column(name = "password_hash", nullable = false) - private String passwordHash; - - @Column(unique = true, nullable = false) - private String phone; - - private String email; - - @Column(name = "user_type", nullable = false) - private String userType; - - @Column(name = "status") - private String status = "active"; - - @Column(name = "created_at") - private LocalDateTime createdAt; - - @Column(name = "updated_at") - private LocalDateTime updatedAt; -} \ No newline at end of file diff --git a/backend-java/user-service/src/main/java/com/niumall/userservice/repository/UserRepository.java b/backend-java/user-service/src/main/java/com/niumall/userservice/repository/UserRepository.java deleted file mode 100644 index 8d8a868..0000000 --- a/backend-java/user-service/src/main/java/com/niumall/userservice/repository/UserRepository.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.niumall.userservice.repository; - -import com.niumall.userservice.entity.User; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; -import java.util.Optional; - -@Repository -public interface UserRepository extends JpaRepository { - Optional findByUsername(String username); - Optional findByPhone(String phone); - Optional findByEmail(String email); -} \ No newline at end of file diff --git a/backend-java/user-service/src/main/java/com/niumall/userservice/service/UserService.java b/backend-java/user-service/src/main/java/com/niumall/userservice/service/UserService.java deleted file mode 100644 index e8d1afa..0000000 --- a/backend-java/user-service/src/main/java/com/niumall/userservice/service/UserService.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.niumall.userservice.service; - -import com.niumall.userservice.entity.User; -import java.util.List; - -public interface UserService { - List getAllUsers(); - User getUserById(Long id); - User createUser(User user); - User updateUser(Long id, User user); - void deleteUser(Long id); -} \ No newline at end of file diff --git a/backend-java/user-service/src/main/java/com/niumall/userservice/service/impl/UserServiceImpl.java b/backend-java/user-service/src/main/java/com/niumall/userservice/service/impl/UserServiceImpl.java deleted file mode 100644 index 148485f..0000000 --- a/backend-java/user-service/src/main/java/com/niumall/userservice/service/impl/UserServiceImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.niumall.userservice.service.impl; - -import com.niumall.userservice.entity.User; -import com.niumall.userservice.repository.UserRepository; -import com.niumall.userservice.service.UserService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import java.util.List; - -@Service -public class UserServiceImpl implements UserService { - - @Autowired - private UserRepository userRepository; - - @Override - public List getAllUsers() { - return userRepository.findAll(); - } - - @Override - public User getUserById(Long id) { - return userRepository.findById(id).orElse(null); - } - - @Override - public User createUser(User user) { - return userRepository.save(user); - } - - @Override - public User updateUser(Long id, User user) { - if (userRepository.existsById(id)) { - user.setId(id); - return userRepository.save(user); - } - return null; - } - - @Override - public void deleteUser(Long id) { - userRepository.deleteById(id); - } -} \ No newline at end of file diff --git a/backend-java/user-service/src/main/resources/application.yml b/backend-java/user-service/src/main/resources/application.yml deleted file mode 100644 index 4f285c6..0000000 --- a/backend-java/user-service/src/main/resources/application.yml +++ /dev/null @@ -1,20 +0,0 @@ -server: - port: 8081 - -spring: - application: - name: user-service - datasource: - url: jdbc:mysql://129.211.213.226:9527/jiebandata?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai - username: root - password: aiotAiot123! - driver-class-name: com.mysql.cj.jdbc.Driver - jpa: - hibernate: - ddl-auto: update - show-sql: true - database-platform: org.hibernate.dialect.MySQL8Dialect - -logging: - level: - com.niumall: debug \ No newline at end of file diff --git a/backend-java/user-service/target/classes/application.yml b/backend-java/user-service/target/classes/application.yml deleted file mode 100644 index 4f285c6..0000000 --- a/backend-java/user-service/target/classes/application.yml +++ /dev/null @@ -1,20 +0,0 @@ -server: - port: 8081 - -spring: - application: - name: user-service - datasource: - url: jdbc:mysql://129.211.213.226:9527/jiebandata?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai - username: root - password: aiotAiot123! - driver-class-name: com.mysql.cj.jdbc.Driver - jpa: - hibernate: - ddl-auto: update - show-sql: true - database-platform: org.hibernate.dialect.MySQL8Dialect - -logging: - level: - com.niumall: debug \ No newline at end of file diff --git a/backend-java/user-service/target/classes/com/niumall/userservice/UserServiceApplication.class b/backend-java/user-service/target/classes/com/niumall/userservice/UserServiceApplication.class deleted file mode 100644 index 97f4dec..0000000 Binary files a/backend-java/user-service/target/classes/com/niumall/userservice/UserServiceApplication.class and /dev/null differ diff --git a/backend-java/user-service/target/classes/com/niumall/userservice/controller/UserController.class b/backend-java/user-service/target/classes/com/niumall/userservice/controller/UserController.class deleted file mode 100644 index ba193a5..0000000 Binary files a/backend-java/user-service/target/classes/com/niumall/userservice/controller/UserController.class and /dev/null differ diff --git a/backend-java/user-service/target/classes/com/niumall/userservice/entity/User.class b/backend-java/user-service/target/classes/com/niumall/userservice/entity/User.class deleted file mode 100644 index 253a902..0000000 Binary files a/backend-java/user-service/target/classes/com/niumall/userservice/entity/User.class and /dev/null differ diff --git a/backend-java/user-service/target/classes/com/niumall/userservice/repository/UserRepository.class b/backend-java/user-service/target/classes/com/niumall/userservice/repository/UserRepository.class deleted file mode 100644 index 6c823ae..0000000 Binary files a/backend-java/user-service/target/classes/com/niumall/userservice/repository/UserRepository.class and /dev/null differ diff --git a/backend-java/user-service/target/classes/com/niumall/userservice/service/UserService.class b/backend-java/user-service/target/classes/com/niumall/userservice/service/UserService.class deleted file mode 100644 index 8cfbb15..0000000 Binary files a/backend-java/user-service/target/classes/com/niumall/userservice/service/UserService.class and /dev/null differ diff --git a/backend-java/user-service/target/classes/com/niumall/userservice/service/impl/UserServiceImpl.class b/backend-java/user-service/target/classes/com/niumall/userservice/service/impl/UserServiceImpl.class deleted file mode 100644 index fa8a94c..0000000 Binary files a/backend-java/user-service/target/classes/com/niumall/userservice/service/impl/UserServiceImpl.class and /dev/null differ