|
@@ -4,15 +4,13 @@ package cn.seecoder.fdroidrepository.Controller;
|
|
|
|
|
|
|
|
import cn.seecoder.fdroidrepository.DataObject.User;
|
|
import cn.seecoder.fdroidrepository.DataObject.User;
|
|
|
import cn.seecoder.fdroidrepository.Service.ServiceImpl.USER_STATUS;
|
|
import cn.seecoder.fdroidrepository.Service.ServiceImpl.USER_STATUS;
|
|
|
-import cn.seecoder.fdroidrepository.Service.UserService;
|
|
|
|
|
|
|
+import cn.seecoder.fdroidrepository.Service.IUserService;
|
|
|
import cn.seecoder.fdroidrepository.config.WebSecurityConfig;
|
|
import cn.seecoder.fdroidrepository.config.WebSecurityConfig;
|
|
|
import cn.seecoder.fdroidrepository.result.Code;
|
|
import cn.seecoder.fdroidrepository.result.Code;
|
|
|
import cn.seecoder.fdroidrepository.result.SingleResult;
|
|
import cn.seecoder.fdroidrepository.result.SingleResult;
|
|
|
import cn.seecoder.fdroidrepository.utils.JwtUtil;
|
|
import cn.seecoder.fdroidrepository.utils.JwtUtil;
|
|
|
import cn.seecoder.fdroidrepository.result.Result;
|
|
import cn.seecoder.fdroidrepository.result.Result;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
|
|
import org.springframework.security.authentication.AuthenticationManager;
|
|
import org.springframework.security.authentication.AuthenticationManager;
|
|
|
import org.springframework.security.authentication.BadCredentialsException;
|
|
import org.springframework.security.authentication.BadCredentialsException;
|
|
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
|
@@ -27,7 +25,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
@RequestMapping("/api/users")
|
|
@RequestMapping("/api/users")
|
|
|
public class UserController {
|
|
public class UserController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- private UserService userService;
|
|
|
|
|
|
|
+ private IUserService IUserService;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private JwtUtil jwtTokenUtils;
|
|
private JwtUtil jwtTokenUtils;
|
|
@@ -37,16 +35,16 @@ public class UserController {
|
|
|
|
|
|
|
|
@PostMapping("/register")
|
|
@PostMapping("/register")
|
|
|
public SingleResult<?> register(@RequestBody User user) {
|
|
public SingleResult<?> register(@RequestBody User user) {
|
|
|
- if (!userService.isUsernameUnique(user.getUsername())) {
|
|
|
|
|
|
|
+ if (!IUserService.isUsernameUnique(user.getUsername())) {
|
|
|
return SingleResult.failure("400","username has been taken!");
|
|
return SingleResult.failure("400","username has been taken!");
|
|
|
}
|
|
}
|
|
|
- userService.save(user);
|
|
|
|
|
|
|
+ IUserService.save(user);
|
|
|
return SingleResult.success("register successfully!");
|
|
return SingleResult.success("register successfully!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("/activation/{userId}/{code}")
|
|
@GetMapping("/activation/{userId}/{code}")
|
|
|
private Result<?> activate(@PathVariable int userId,@PathVariable String code){
|
|
private Result<?> activate(@PathVariable int userId,@PathVariable String code){
|
|
|
- USER_STATUS result=userService.activate(userId,code);
|
|
|
|
|
|
|
+ USER_STATUS result= IUserService.activate(userId,code);
|
|
|
if(result==USER_STATUS.START_ACTIVATE){
|
|
if(result==USER_STATUS.START_ACTIVATE){
|
|
|
return new Result<>("200","activate success");
|
|
return new Result<>("200","activate success");
|
|
|
}else if(result==USER_STATUS.REPEAT_ACTIVATE){
|
|
}else if(result==USER_STATUS.REPEAT_ACTIVATE){
|