|
@@ -4,8 +4,10 @@ package com.hichina.main.back.hichinamainback.controller;
|
|
|
import com.hichina.main.back.hichinamainback.config.CustomAuthenticationProvider;
|
|
|
import com.hichina.main.back.hichinamainback.config.EnableHichinaAutoLog;
|
|
|
import com.hichina.main.back.hichinamainback.mapper.UserMapper;
|
|
|
+import com.hichina.main.back.hichinamainback.model.DTO.HiChinaResult;
|
|
|
import com.hichina.main.back.hichinamainback.model.DTO.HichinaResponse;
|
|
|
import com.hichina.main.back.hichinamainback.model.DTO.RegisterDTO;
|
|
|
+import com.hichina.main.back.hichinamainback.model.DTO.RegisterResult;
|
|
|
import com.hichina.main.back.hichinamainback.model.User;
|
|
|
import com.hichina.main.back.hichinamainback.utils.MailUtil;
|
|
|
import org.slf4j.Logger;
|
|
@@ -39,15 +41,13 @@ public class PublicRegisterController {
|
|
|
|
|
|
@PostMapping
|
|
|
@EnableHichinaAutoLog(description = "register api")
|
|
|
- public HichinaResponse register(@RequestBody RegisterDTO request){
|
|
|
- HichinaResponse ret = new HichinaResponse();
|
|
|
+ public HiChinaResult<RegisterResult> register(@RequestBody RegisterDTO request){
|
|
|
|
|
|
List<User> users = userMapper.findByEmail(request.getEmail());
|
|
|
|
|
|
if(!users.isEmpty()){
|
|
|
- ret.setOk(false);
|
|
|
- ret.setMessage(String.format("User %s already exist",request.getEmail()));
|
|
|
- return ret;
|
|
|
+ return HiChinaResult.error(String.format("User %s already exist",request.getEmail()),
|
|
|
+ RegisterResult.exist());
|
|
|
}
|
|
|
|
|
|
String redisKey = java.util.UUID.randomUUID().toString();
|
|
@@ -62,10 +62,7 @@ public class PublicRegisterController {
|
|
|
// LOG.info("Doing phone reg");
|
|
|
}
|
|
|
|
|
|
- ret.setOk(true);
|
|
|
- ret.setMessage("Succeed insert into redis");
|
|
|
-
|
|
|
- return ret;
|
|
|
+ return HiChinaResult.ok(RegisterResult.ok(request.getEmail()));
|
|
|
}
|
|
|
|
|
|
@PostMapping("/pushintodb/{regKey}")
|