一.AccountController
@RestController
@RequestMapping("account")
public class AccountController extends AbstractGameCenterServerController {
@Autowired
private AccountRegisterService accountRegisterService;
@Autowired
private AccountService accountLoginService;
@PostMapping("register")
public Object registerAccount(@RequestBody AccountRegisterRequest param) throws Exception {
AccountEntity account = new AccountEntity();
account.setUsername(param.getUsername());
account.setPassword(param.getPassword());
accountRegisterService.accountRegister(account);
AccountLoginResponse voLoginSuccess = accountLoginService.getLoginResponse(account);
return responseSuccess(voLoginSuccess);
}
@PostMapping("login")
public Object loginAccount(@RequestBody AccountLoginRequest loginParam) throws Exception {
AccountEntity account = accountLoginService.login(loginParam);
AccountLoginResponse loginSuccess = accountLoginService.getLoginResponse(account);
return responseSuccess(loginSuccess);
}
}
1.RestController+RequestMapping
2.PostMapping + @RequestBody