【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

相关推荐
apocelipes1 小时前
golang unique包和字符串内部化
java·python·性能优化·golang
Full Stack Developme2 小时前
java.text 包详解
java·开发语言·python
刘梦凡呀3 小时前
C#获取钉钉平台考勤记录
java·c#·钉钉
best_virtuoso3 小时前
PostgreSQL 常见数组操作函数语法、功能
java·数据结构·postgresql
yudiandian20143 小时前
02 Oracle JDK 下载及配置(解压缩版)
java·开发语言
Q_Q5110082853 小时前
python+uniapp基于微信小程序的旅游信息系统
spring boot·python·微信小程序·django·flask·uni-app·node.js
楚韵天工4 小时前
宠物服务平台(程序+文档)
java·网络·数据库·spring cloud·编辑器·intellij-idea·宠物
helloworddm4 小时前
Orleans Stream SubscriptionId 生成机制详解
java·系统架构·c#
失散134 小时前
分布式专题——43 ElasticSearch概述
java·分布式·elasticsearch·架构
ajsbxi4 小时前
【Java 基础】核心知识点梳理
java·开发语言·笔记