package com.student.mathquiz.model; import com.student.mathquiz.constant.UserType; public class User { // ★★★ 1. 新增 username 字段 ★★★ private String username; private String email; private String encryptedPwd; private UserType userType; public User() { } // Gson需要无参构造 // ★★★ 2. 修改构造函数,加入 username ★★★ public User(String username, String email, String encryptedPwd, UserType userType) { this.username = username; this.email = email; this.encryptedPwd = encryptedPwd; this.userType = userType; } // ★★★ 3. 新增 username 的 Getter 和 Setter ★★★ public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } // --- 下面的代码保持不变 --- public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getEncryptedPwd() { return encryptedPwd; } public void setEncryptedPwd(String encryptedPwd) { this.encryptedPwd = encryptedPwd; } public UserType getUserType() { return userType; } public void setUserType(UserType userType) { this.userType = userType; } }