Initialize patbond microservice modules

This commit is contained in:
nmbh1122@126.com
2026-07-13 09:41:15 +08:00
commit b1252b991d
48 changed files with 1002 additions and 0 deletions
@@ -0,0 +1,4 @@
/**
* Shared code for Patbond microservices.
*/
package com.patbond.patbond.common;
@@ -0,0 +1,53 @@
package com.patbond.patbond.common.response;
public class ApiResponse<T> {
private Integer code;
private String message;
private T data;
public ApiResponse() {
}
public ApiResponse(Integer code, String message, T data) {
this.code = code;
this.message = message;
this.data = data;
}
public static <T> ApiResponse<T> success(T data) {
return new ApiResponse<>(0, "success", data);
}
public static <T> ApiResponse<T> failure(Integer code, String message) {
return new ApiResponse<>(code, message, null);
}
public boolean isSuccess() {
return Integer.valueOf(0).equals(code);
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}
@@ -0,0 +1,63 @@
package com.patbond.patbond.common.user;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
public class CreateUserRequest {
@NotBlank(message = "用户名不能为空")
@Size(min = 3, max = 32, message = "用户名长度必须在3到32位之间")
private String username;
@NotBlank(message = "密码不能为空")
@Size(min = 6, max = 64, message = "密码长度必须在6到64位之间")
private String password;
@Size(max = 32, message = "昵称长度不能超过32位")
private String nickname;
@Size(max = 20, message = "手机号长度不能超过20位")
private String phone;
public CreateUserRequest() {
}
public CreateUserRequest(String username, String password, String nickname, String phone) {
this.username = username;
this.password = password;
this.nickname = nickname;
this.phone = phone;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}
@@ -0,0 +1,63 @@
package com.patbond.patbond.common.user;
import java.time.LocalDateTime;
public class UserProfile {
private Long id;
private String username;
private String nickname;
private String phone;
private LocalDateTime createdAt;
public UserProfile() {
}
public UserProfile(Long id, String username, String nickname, String phone, LocalDateTime createdAt) {
this.id = id;
this.username = username;
this.nickname = nickname;
this.phone = phone;
this.createdAt = createdAt;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public LocalDateTime getCreatedAt() {
return createdAt;
}
public void setCreatedAt(LocalDateTime createdAt) {
this.createdAt = createdAt;
}
}
@@ -0,0 +1,36 @@
package com.patbond.patbond.common.user;
import javax.validation.constraints.NotBlank;
public class VerifyPasswordRequest {
@NotBlank(message = "用户名不能为空")
private String username;
@NotBlank(message = "密码不能为空")
private String password;
public VerifyPasswordRequest() {
}
public VerifyPasswordRequest(String username, String password) {
this.username = username;
this.password = password;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
@@ -0,0 +1,41 @@
package com.patbond.patbond.common.user;
public class VerifyPasswordResponse {
private Long userId;
private String username;
private String nickname;
public VerifyPasswordResponse() {
}
public VerifyPasswordResponse(Long userId, String username, String nickname) {
this.userId = userId;
this.username = username;
this.nickname = nickname;
}
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 String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
}