add RegisterRequest
This commit is contained in:
parent
d51f666dc2
commit
e4b61bc609
@ -29,7 +29,19 @@ public class AuthController {
|
||||
|
||||
```
|
||||
|
||||
##### 2. 创建实体类User
|
||||
##### 2. 创建请求类RegisterRequest
|
||||
```java
|
||||
package com.lk.paopao.dto.rest.request;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class RegisterRequest {
|
||||
String username;
|
||||
String password;
|
||||
}
|
||||
```
|
||||
|
||||
##### 3. 创建实体类User
|
||||
|
||||
```java
|
||||
package com.lk.paopao.domain;
|
||||
@ -106,13 +118,13 @@ public class User {
|
||||
}
|
||||
```
|
||||
|
||||
##### 3. 创建接口UserRepository
|
||||
##### 4. 创建接口UserRepository
|
||||
```java
|
||||
public interface UserRepository extends JpaRepository<User, Long> {
|
||||
|
||||
}
|
||||
```
|
||||
##### 4. 创建AuthService
|
||||
##### 5. 创建AuthService
|
||||
```java
|
||||
package com.lk.paopao.service;
|
||||
|
||||
@ -141,15 +153,13 @@ public class AuthService {
|
||||
user.setAvatar(DEFAULT_HEAD_ICON); // 设置默认头像
|
||||
user.setNickname(reg.getUsername()); // 设置昵称为用户名
|
||||
user.setUsername(reg.getUsername()); // 设置用户名
|
||||
user.setSalt(""); // 盐值,默认未使用
|
||||
user.setPhone(""); // 电话号码,默认未设置
|
||||
return userRepository.save(user); // 保存用户到数据库
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
##### 5. 测试
|
||||
##### 6. 测试
|
||||
|
||||
http://localhost:8080/api-docs
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user