refactor application configuration and update user model with new fields
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user