添加了注册功能,但User中username意义不够明确,想改成accout,此版作备份用
This commit is contained in:
parent
9c7174e882
commit
5206c93083
@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.springframework.http.ResponseEntity.badRequest;
|
||||||
import static org.springframework.http.ResponseEntity.ok;
|
import static org.springframework.http.ResponseEntity.ok;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@ -26,7 +27,7 @@ public class UserController {
|
|||||||
System.out.println("hahaha");
|
System.out.println("hahaha");
|
||||||
return ResponseEntity.notFound().build();
|
return ResponseEntity.notFound().build();
|
||||||
}
|
}
|
||||||
@PostMapping("/hahaha")
|
@PostMapping("/checkLogin")
|
||||||
public ResponseEntity<User> hahaha(@RequestBody Map<String, String> credentials){
|
public ResponseEntity<User> hahaha(@RequestBody Map<String, String> credentials){
|
||||||
String username = credentials.get("username");
|
String username = credentials.get("username");
|
||||||
String password = credentials.get("password");
|
String password = credentials.get("password");
|
||||||
@ -37,21 +38,23 @@ public class UserController {
|
|||||||
User user = new User();
|
User user = new User();
|
||||||
user.setUsername(username);
|
user.setUsername(username);
|
||||||
user.setPassword(password);
|
user.setPassword(password);
|
||||||
return ResponseEntity.ok(user);
|
return ok(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/register")
|
@PostMapping("/checkRegister")
|
||||||
public ResponseEntity<User> register(@RequestBody Map<String, String> credentials) {
|
public String register(@RequestBody User user) {
|
||||||
String username = credentials.get("username");
|
// String username = user.getUsername();
|
||||||
String password = credentials.get("password");
|
// String password = user.getPassword();
|
||||||
String name = credentials.get("name");
|
// String name = user.getName();
|
||||||
String organization = credentials.get("organization");
|
// String organization = user.getOrganization();
|
||||||
String gender = credentials.get("gender");
|
// String gender = user.getGender();
|
||||||
String email = credentials.get("email");
|
// String email = user.getEmail();
|
||||||
String phone = credentials.get("phone");
|
// String phone = user.getPhone();
|
||||||
String pname = credentials.get("pname");;
|
// String pname = user.getPname();
|
||||||
User user = new User(username, password, name, organization, gender, email,phone,pname);
|
|
||||||
if(userService.RegisterUser(user) != null);
|
if(userService.RegisterUser(user) != null){
|
||||||
return null;
|
return "注册成功";
|
||||||
|
}
|
||||||
|
return "注册错误";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,6 +27,8 @@ public class User {
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private String organization;
|
private String organization;
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
private String gender;
|
private String gender;
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user