Преглед на файлове

获取验证码改为get方法

詹子聪 преди 5 години
родител
ревизия
3db8ef1c51
променени са 1 файла, в които са добавени 11 реда и са изтрити 5 реда
  1. 11 5
      src/main/java/com/miekir/shibei/controller/api/UserController.java

+ 11 - 5
src/main/java/com/miekir/shibei/controller/api/UserController.java

@@ -63,10 +63,9 @@ public class UserController {
     /**
      * 获取验证码,返回aes给客户端
      */
-    @RequestMapping(value = "/api/code", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
+    @RequestMapping(value = "/api/code", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
     @ResponseBody
-    public String getAuthCode(@RequestBody Map<String, Object> emailMap) {
-        String email = String.valueOf(emailMap.get("email"));
+    public String getAuthCode(String email) {
         ResponseResult<Boolean> responseResult = new ResponseResult<Boolean>();
         responseResult.setContent(false);
         responseResult.setMessage("获取验证码失败");
@@ -90,11 +89,17 @@ public class UserController {
      */
     @RequestMapping(value = "/api/register", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
     @ResponseBody
-    public String register(String email, String password, String code, String nickName) {
+    public String register(@RequestBody Map<String, Object> registerMap) {
         ResponseResult<User> responseResult = new ResponseResult<User>();
         responseResult.setCode(ResultCode.FAILED_COMMON);
         responseResult.setMessage("注册失败");
 
+        String email = String.valueOf(registerMap.get("email"));
+        String code = String.valueOf(registerMap.get("code"));
+        String password = String.valueOf(registerMap.get("password"));
+        String nickname = String.valueOf(registerMap.get("nickname"));
+        String cashAccount = String.valueOf(registerMap.get("cashAccount"));
+
         // 从数据库查询,如果没有这个email并且不在黑名单里,才可以继续注册
         User dbUser = userRepository.findUserByEmail(email);
         if (dbUser != null) {
@@ -121,9 +126,10 @@ public class UserController {
         // 开始注册,插入数据库
         User user = new User();
         user.setEmail(email);
-        user.setNickName(nickName);
+        user.setNickName(nickname);
         user.setRegisterTimeMillis(System.currentTimeMillis());
         user.setPassword(password);
+        user.setCashAccount(cashAccount);
         try {
             String token = TokenGenerator.getInstance().getToken(email);
             if (token == null || token.equals("")) {