自由的羽毛 发表于 2024-12-20 18:35:41

【SpringBoot中SpringMVC服务之处置惩罚post请求】

一.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




免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: 【SpringBoot中SpringMVC服务之处置惩罚post请求】