feat: Spring Boot示例项目

- 基础Spring Boot配置
- Docker支持
This commit is contained in:
likingcode
2026-03-07 05:43:15 +00:00
commit 539dc41868
47 changed files with 2746 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
package com.example.demo.model;
/**
* 用户实体类
*
* 学习点:
* - JavaBean / POJO 设计模式
* - Lombok 可以简化 getter/setter这里用原生写法演示
*/
public class User {
private Long id;
private String name;
private String email;
private Integer age;
public User() {}
public User(Long id, String name, String email, Integer age) {
this.id = id;
this.name = name;
this.email = email;
this.age = age;
}
// Getters and Setters
public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public String getEmail() { return email; }
public void setEmail(String email) { this.email = email; }
public Integer getAge() { return age; }
public void setAge(Integer age) { this.age = age; }
}

View File

@@ -0,0 +1,51 @@
package com.example.demo.model;
import java.time.LocalDateTime;
/**
* 用户事件 - 演示 Spring 事件机制
*
* 学习点:
* - ApplicationEvent 基类
* - 事件驱动架构
* - 观察者模式
*/
public class UserEvent {
public enum Type {
CREATED, // 用户创建
UPDATED, // 用户更新
DELETED, // 用户删除
LOGIN // 用户登录
}
private Type type;
private Long userId;
private String userName;
private LocalDateTime timestamp;
private String detail;
public UserEvent() {
this.timestamp = LocalDateTime.now();
}
public UserEvent(Type type, Long userId, String userName, String detail) {
this.type = type;
this.userId = userId;
this.userName = userName;
this.detail = detail;
this.timestamp = LocalDateTime.now();
}
// Getters and Setters
public Type getType() { return type; }
public void setType(Type type) { this.type = type; }
public Long getUserId() { return userId; }
public void setUserId(Long userId) { this.userId = userId; }
public String getUserName() { return userName; }
public void setUserName(String userName) { this.userName = userName; }
public LocalDateTime getTimestamp() { return timestamp; }
public void setTimestamp(LocalDateTime timestamp) { this.timestamp = timestamp; }
public String getDetail() { return detail; }
public void setDetail(String detail) { this.detail = detail; }
}