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