refactor application configuration and update user model with new fields
This commit is contained in:
@@ -3,7 +3,11 @@
|
||||
"allow": [
|
||||
"Bash(mkdir:*)",
|
||||
"Bash(rmdir:*)",
|
||||
"Bash(rm:*)"
|
||||
"Bash(rm:*)",
|
||||
"Bash(mvn:*)",
|
||||
"Bash(./mvnw clean compile)",
|
||||
"Bash(cd:*)",
|
||||
"Bash(ls:*)"
|
||||
],
|
||||
"deny": []
|
||||
}
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -19,7 +19,7 @@
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<mybatis-flex.version>1.8.6</mybatis-flex.version>
|
||||
<mybatis-flex.version>1.9.3</mybatis-flex.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -3,8 +3,9 @@ package com.yundage.chat;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
|
||||
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication(exclude = {HibernateJpaAutoConfiguration.class})
|
||||
@MapperScan("com.yundage.chat.mapper")
|
||||
public class ChatApplication {
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ public class UserController {
|
||||
|
||||
@PostMapping
|
||||
public User createUser(@RequestBody User user) {
|
||||
user.setCreateTime(LocalDateTime.now());
|
||||
user.setUpdateTime(LocalDateTime.now());
|
||||
user.setCreatedAt(LocalDateTime.now());
|
||||
user.setUpdatedAt(LocalDateTime.now());
|
||||
userMapper.insert(user);
|
||||
return user;
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public class UserController {
|
||||
@PutMapping("/{id}")
|
||||
public User updateUser(@PathVariable Long id, @RequestBody User user) {
|
||||
user.setId(id);
|
||||
user.setUpdateTime(LocalDateTime.now());
|
||||
user.setUpdatedAt(LocalDateTime.now());
|
||||
userMapper.update(user);
|
||||
return user;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.yundage.chat.entity;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@@ -12,10 +13,17 @@ public class PasswordResetToken {
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
@Column("user_id")
|
||||
private Long userId;
|
||||
|
||||
private String token;
|
||||
|
||||
@Column("expires_at")
|
||||
private LocalDateTime expiresAt;
|
||||
|
||||
private Boolean used;
|
||||
|
||||
@Column("created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
public PasswordResetToken() {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.yundage.chat.entity;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.yundage.chat.enums.UserType;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
@@ -19,15 +20,31 @@ public class User implements UserDetails {
|
||||
private Long id;
|
||||
|
||||
private String username;
|
||||
|
||||
@Column("password_hash")
|
||||
private String passwordHash;
|
||||
|
||||
private String phone;
|
||||
private String email;
|
||||
|
||||
@Column("avatar_url")
|
||||
private String avatarUrl;
|
||||
|
||||
@Column("user_type")
|
||||
private UserType userType;
|
||||
|
||||
@Column("membership_level_id")
|
||||
private Integer membershipLevelId;
|
||||
|
||||
private Integer status;
|
||||
|
||||
@Column("created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Column("updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
@Column("last_login_at")
|
||||
private LocalDateTime lastLoginAt;
|
||||
|
||||
public User() {
|
||||
|
||||
@@ -4,12 +4,6 @@ spring:
|
||||
url: jdbc:mysql://101.200.154.78:3306/yunda_qa?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: mysql_Jt3yzh
|
||||
|
||||
# JPA configuration (optional, if you need JPA alongside MyBatis-Flex)
|
||||
jpa:
|
||||
show-sql: true
|
||||
hibernate:
|
||||
ddl-auto: update
|
||||
|
||||
# Mail configuration
|
||||
mail:
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/chat?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
|
||||
url: jdbc:mysql://101.200.154.78:3306/yunda_qa?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: password
|
||||
|
||||
# JPA configuration (optional, if you need JPA alongside MyBatis-Flex)
|
||||
jpa:
|
||||
show-sql: true
|
||||
hibernate:
|
||||
ddl-auto: update
|
||||
password: mysql_Jt3yzh
|
||||
|
||||
# Mail configuration
|
||||
mail:
|
||||
host: smtp.gmail.com
|
||||
port: 587
|
||||
username: your-email@gmail.com
|
||||
password: your-app-password
|
||||
properties:
|
||||
mail:
|
||||
smtp:
|
||||
auth: true
|
||||
starttls:
|
||||
enable: true
|
||||
|
||||
# MyBatis-Flex configuration
|
||||
mybatis-flex:
|
||||
@@ -19,6 +26,15 @@ mybatis-flex:
|
||||
# Mapper XML location (optional)
|
||||
mapper-locations: classpath*:mapper/*.xml
|
||||
|
||||
# JWT configuration
|
||||
jwt:
|
||||
secret: mySecretKeyForJWTTokenGenerationAndValidation
|
||||
expiration: 86400000 # 24 hours in milliseconds
|
||||
|
||||
# App configuration
|
||||
app:
|
||||
reset-password-url: http://localhost:3000/reset-password
|
||||
|
||||
# Server configuration
|
||||
server:
|
||||
port: 8080
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.yundage.chat.entity.table;
|
||||
|
||||
import com.mybatisflex.core.query.QueryColumn;
|
||||
import com.mybatisflex.core.table.TableDef;
|
||||
|
||||
// Auto generate by mybatis-flex, do not modify it.
|
||||
public class PasswordResetTokenTableDef extends TableDef {
|
||||
|
||||
public static final PasswordResetTokenTableDef PASSWORD_RESET_TOKEN = new PasswordResetTokenTableDef();
|
||||
|
||||
public final QueryColumn ID = new QueryColumn(this, "id");
|
||||
|
||||
public final QueryColumn USED = new QueryColumn(this, "used");
|
||||
|
||||
public final QueryColumn TOKEN = new QueryColumn(this, "token");
|
||||
|
||||
public final QueryColumn USER_ID = new QueryColumn(this, "user_id");
|
||||
|
||||
public final QueryColumn CREATED_AT = new QueryColumn(this, "created_at");
|
||||
|
||||
public final QueryColumn EXPIRES_AT = new QueryColumn(this, "expires_at");
|
||||
|
||||
/**
|
||||
* 所有字段。
|
||||
*/
|
||||
public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");
|
||||
|
||||
/**
|
||||
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||
*/
|
||||
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, USED, TOKEN, USER_ID, CREATED_AT, EXPIRES_AT};
|
||||
|
||||
public PasswordResetTokenTableDef() {
|
||||
super("", "password_reset_tokens");
|
||||
}
|
||||
|
||||
private PasswordResetTokenTableDef(String schema, String name, String alisa) {
|
||||
super(schema, name, alisa);
|
||||
}
|
||||
|
||||
public PasswordResetTokenTableDef as(String alias) {
|
||||
String key = getNameWithSchema() + "." + alias;
|
||||
return getCache(key, k -> new PasswordResetTokenTableDef("", "password_reset_tokens", alias));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.yundage.chat.entity.table;
|
||||
|
||||
import com.mybatisflex.core.query.QueryColumn;
|
||||
import com.mybatisflex.core.table.TableDef;
|
||||
|
||||
// Auto generate by mybatis-flex, do not modify it.
|
||||
public class UserTableDef extends TableDef {
|
||||
|
||||
public static final UserTableDef USER = new UserTableDef();
|
||||
|
||||
public final QueryColumn ID = new QueryColumn(this, "id");
|
||||
|
||||
public final QueryColumn EMAIL = new QueryColumn(this, "email");
|
||||
|
||||
public final QueryColumn PHONE = new QueryColumn(this, "phone");
|
||||
|
||||
public final QueryColumn STATUS = new QueryColumn(this, "status");
|
||||
|
||||
public final QueryColumn USER_TYPE = new QueryColumn(this, "user_type");
|
||||
|
||||
public final QueryColumn USERNAME = new QueryColumn(this, "username");
|
||||
|
||||
public final QueryColumn AVATAR_URL = new QueryColumn(this, "avatar_url");
|
||||
|
||||
public final QueryColumn CREATED_AT = new QueryColumn(this, "created_at");
|
||||
|
||||
public final QueryColumn UPDATED_AT = new QueryColumn(this, "updated_at");
|
||||
|
||||
public final QueryColumn LAST_LOGIN_AT = new QueryColumn(this, "last_login_at");
|
||||
|
||||
public final QueryColumn PASSWORD_HASH = new QueryColumn(this, "password_hash");
|
||||
|
||||
public final QueryColumn MEMBERSHIP_LEVEL_ID = new QueryColumn(this, "membership_level_id");
|
||||
|
||||
/**
|
||||
* 所有字段。
|
||||
*/
|
||||
public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");
|
||||
|
||||
/**
|
||||
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||
*/
|
||||
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, EMAIL, PHONE, STATUS, USER_TYPE, USERNAME, AVATAR_URL, CREATED_AT, UPDATED_AT, LAST_LOGIN_AT, PASSWORD_HASH, MEMBERSHIP_LEVEL_ID};
|
||||
|
||||
public UserTableDef() {
|
||||
super("", "users");
|
||||
}
|
||||
|
||||
private UserTableDef(String schema, String name, String alisa) {
|
||||
super(schema, name, alisa);
|
||||
}
|
||||
|
||||
public UserTableDef as(String alias) {
|
||||
String key = getNameWithSchema() + "." + alias;
|
||||
return getCache(key, k -> new UserTableDef("", "users", alias));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user