|
@@ -3,17 +3,24 @@ package com.mooctest.crowd.site.controller;
|
|
|
import com.mooctest.crowd.domain.exception.*;
|
|
|
import com.mooctest.crowd.site.annotation.LoginRequired;
|
|
|
import com.mooctest.crowd.site.annotation.SysAdminRequired;
|
|
|
+import com.mooctest.crowd.site.anticorruption.impl.data.UserCommon;
|
|
|
+import com.mooctest.crowd.site.anticorruption.impl.data.UserInfo;
|
|
|
import com.mooctest.crowd.site.command.*;
|
|
|
import com.mooctest.crowd.site.data.dto.UserDTO;
|
|
|
+import com.mooctest.crowd.site.data.response.ResponseVO;
|
|
|
+import com.mooctest.crowd.site.data.response.ServerCode;
|
|
|
import com.mooctest.crowd.site.data.vo.BaseAuthVO;
|
|
|
import com.mooctest.crowd.site.data.vo.EnterpriseAuthVO;
|
|
|
import com.mooctest.crowd.site.data.vo.PersonalAuthVO;
|
|
|
import com.mooctest.crowd.site.service.UserService;
|
|
|
+import org.apache.juli.logging.Log;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpRequest;
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -24,7 +31,7 @@ import java.util.List;
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/api")
|
|
|
-public class UserController {
|
|
|
+public class UserController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private UserService userService;
|
|
@@ -37,34 +44,53 @@ public class UserController {
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/user", method = RequestMethod.PUT)
|
|
|
- public UserDTO updateUser(@Validated UserUpdateCommand command, BindingResult result){
|
|
|
+ public UserDTO updateUser(@Validated UserUpdateCommand command, BindingResult result) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/user/{userId}", method = RequestMethod.DELETE)
|
|
|
- public boolean deleteUser(@PathVariable("userId") Long userId){
|
|
|
+ public boolean deleteUser(@PathVariable("userId") Long userId) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/user/{userId}", method = RequestMethod.GET)
|
|
|
- public UserDTO getUser(@PathVariable Long userId){
|
|
|
+ public UserDTO getUser(@PathVariable Long userId) {
|
|
|
return userService.getUser(userId);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/user", method = RequestMethod.GET)
|
|
|
- public List<UserDTO> getUsers(){
|
|
|
+ public List<UserDTO> getUsers() {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/login", method = RequestMethod.GET)
|
|
|
- public UserDTO loginByMobileAndPwd(@Validated LoginCommand loginCommand, BindingResult result) throws PasswordErrorException, AccountNotExistException, BadRequestException {
|
|
|
+ public UserDTO loginByMobileAndPwd(@Validated @RequestBody LoginCommand loginCommand, BindingResult result, HttpServletRequest request) throws PasswordErrorException, AccountNotExistException, BadRequestException {
|
|
|
if (result.hasErrors())
|
|
|
throw new BadRequestException(result.getFieldError().getDefaultMessage());
|
|
|
return userService.loginByMobileAndPwd(loginCommand);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 修改密码
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/password/reset", method = RequestMethod.PUT)
|
|
|
+ public ResponseVO<UserCommon> resetPassword(@RequestBody RestPasswordCommand restPasswordCommand, BindingResult result) {
|
|
|
+ if (result.hasErrors())
|
|
|
+ throw new BadRequestException(result.getFieldError().getDefaultMessage());
|
|
|
+ return new ResponseVO<>(ServerCode.SUCCESS, userService.restPassword(restPasswordCommand));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取邮箱验证码
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/verify/email", method = RequestMethod.PUT)
|
|
|
+ public ResponseVO<Boolean> verifyMail(@RequestBody UserInfo userInfo) {
|
|
|
+ return new ResponseVO<>(ServerCode.SUCCESS, userService.verifyMail(userInfo.getEmail()));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 申请个人实名认证
|
|
|
+ *
|
|
|
* @param userId
|
|
|
* @param command
|
|
|
* @param result
|
|
@@ -73,19 +99,20 @@ public class UserController {
|
|
|
*/
|
|
|
@LoginRequired
|
|
|
@RequestMapping(value = "/user/{userId}/personalAuth", method = RequestMethod.POST)
|
|
|
- public PersonalAuthVO applyPersonalAuthentication(@PathVariable("userId")Long userId,
|
|
|
+ public PersonalAuthVO applyPersonalAuthentication(@PathVariable("userId") Long userId,
|
|
|
@Validated @RequestBody ApplyPersonalAuthCommand command,
|
|
|
- BindingResult result, HttpSession session){
|
|
|
- if (!userId.equals(Long.parseLong((String)session.getAttribute("userId"))))
|
|
|
+ BindingResult result, HttpSession session) {
|
|
|
+
|
|
|
+ if (!userId.equals(Long.parseLong((String) session.getAttribute("userId"))))
|
|
|
throw new UnauthorizedException("没有权限对他人账号进行操作!");
|
|
|
if (result.hasErrors())
|
|
|
throw new BaseException(result.getFieldError().getDefaultMessage());
|
|
|
-
|
|
|
return userService.applyPersonalAuth(userId, command);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改个人认证信息
|
|
|
+ *
|
|
|
* @param userId
|
|
|
* @param command
|
|
|
* @param result
|
|
@@ -93,64 +120,70 @@ public class UserController {
|
|
|
*/
|
|
|
@LoginRequired
|
|
|
@RequestMapping(value = "/user/{userId}/personalAuth", method = RequestMethod.PUT)
|
|
|
- public PersonalAuthVO updatePersonalAuthInfo(@PathVariable("userId")Long userId,
|
|
|
+ public PersonalAuthVO updatePersonalAuthInfo(@PathVariable("userId") Long userId,
|
|
|
@Validated @RequestBody ApplyPersonalAuthCommand command,
|
|
|
HttpSession session,
|
|
|
- BindingResult result){
|
|
|
- if (result.hasErrors())
|
|
|
+ BindingResult result) {
|
|
|
+ if (result.hasErrors()) {
|
|
|
throw new BaseException(result.getFieldError().getDefaultMessage());
|
|
|
+ }
|
|
|
return userService.updatePersonalAuthInfo(userId, command);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 个人认证:通过审核
|
|
|
+ *
|
|
|
* @param userId
|
|
|
* @return
|
|
|
*/
|
|
|
@LoginRequired
|
|
|
@SysAdminRequired
|
|
|
@RequestMapping(value = "/user/{userId}/personalAuth/status/accept", method = RequestMethod.PUT)
|
|
|
- public PersonalAuthVO passPersonalAuth(@PathVariable("userId") Long userId){
|
|
|
+ public PersonalAuthVO passPersonalAuth(@PathVariable("userId") Long userId) {
|
|
|
return userService.passPersonalAuth(userId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 个人认证:审核未通过
|
|
|
+ *
|
|
|
* @param userId
|
|
|
* @return
|
|
|
*/
|
|
|
@LoginRequired
|
|
|
@SysAdminRequired
|
|
|
@RequestMapping(value = "/user/{userId}/personalAuth/status/reject", method = RequestMethod.PUT)
|
|
|
- public PersonalAuthVO rejectPersonalAuth(@PathVariable("userId") Long userId, @RequestBody @Validated AuthRejectCommand command){
|
|
|
+ public PersonalAuthVO rejectPersonalAuth(@PathVariable("userId") Long userId, @RequestBody @Validated AuthRejectCommand command) {
|
|
|
return userService.rejectPersonalAuth(userId, command.getExplain());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查看个人认证信息
|
|
|
+ *
|
|
|
* @param userId
|
|
|
* @return
|
|
|
*/
|
|
|
@LoginRequired
|
|
|
@RequestMapping(value = "/user/{userId}/personalAuth", method = RequestMethod.GET)
|
|
|
- public PersonalAuthVO getPersonalAuthInfo(@PathVariable("userId") Long userId){
|
|
|
+ public PersonalAuthVO getPersonalAuthInfo(@PathVariable("userId") Long userId) {
|
|
|
return userService.getPersonalAuthInfo(userId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取企业认证信息
|
|
|
+ *
|
|
|
* @param userId
|
|
|
* @return
|
|
|
*/
|
|
|
@LoginRequired
|
|
|
@RequestMapping(value = "/user/{userId}/enterpriseAuth", method = RequestMethod.GET)
|
|
|
- public EnterpriseAuthVO getEnterpriseAuthInfo(@PathVariable("userId") Long userId){
|
|
|
+ public EnterpriseAuthVO getEnterpriseAuthInfo(@PathVariable("userId") Long userId) {
|
|
|
return userService.getEnterpriseAuthInfo(userId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 申请企业认证接口
|
|
|
+ *
|
|
|
* @param userId
|
|
|
* @param command
|
|
|
* @param result
|
|
@@ -159,10 +192,10 @@ public class UserController {
|
|
|
*/
|
|
|
@LoginRequired
|
|
|
@RequestMapping(value = "/user/{userId}/enterpriseAuth", method = RequestMethod.POST)
|
|
|
- public EnterpriseAuthVO applyEnterpriseAuth(@PathVariable("userId")Long userId,
|
|
|
- @Validated @RequestBody ApplyEnterpriseAuthCommand command,
|
|
|
- BindingResult result, HttpSession session){
|
|
|
- if (!userId.equals(Long.parseLong((String)session.getAttribute("userId"))))
|
|
|
+ public EnterpriseAuthVO applyEnterpriseAuth(@PathVariable("userId") Long userId,
|
|
|
+ @Validated @RequestBody ApplyEnterpriseAuthCommand command,
|
|
|
+ BindingResult result, HttpSession session) {
|
|
|
+ if (!userId.equals(Long.parseLong((String) session.getAttribute("userId"))))
|
|
|
throw new UnauthorizedException("没有权限对他人账号进行操作!");
|
|
|
if (result.hasErrors())
|
|
|
throw new BaseException(result.getFieldError().getDefaultMessage());
|
|
@@ -171,6 +204,7 @@ public class UserController {
|
|
|
|
|
|
/**
|
|
|
* 更新企业认证信息
|
|
|
+ *
|
|
|
* @param userId
|
|
|
* @param command
|
|
|
* @param result
|
|
@@ -178,9 +212,9 @@ public class UserController {
|
|
|
*/
|
|
|
@LoginRequired
|
|
|
@RequestMapping(value = "/user/{userId}/enterpriseAuth", method = RequestMethod.PUT)
|
|
|
- public EnterpriseAuthVO updatePersonalAuthInfo(@PathVariable("userId")Long userId,
|
|
|
- @Validated @RequestBody ApplyEnterpriseAuthCommand command,
|
|
|
- BindingResult result){
|
|
|
+ public EnterpriseAuthVO updatePersonalAuthInfo(@PathVariable("userId") Long userId,
|
|
|
+ @Validated @RequestBody ApplyEnterpriseAuthCommand command,
|
|
|
+ BindingResult result) {
|
|
|
if (result.hasErrors())
|
|
|
throw new BaseException(result.getFieldError().getDefaultMessage());
|
|
|
return userService.updateEnterpriseAuthInfo(userId, command);
|
|
@@ -188,38 +222,40 @@ public class UserController {
|
|
|
|
|
|
/**
|
|
|
* 企业认证:审核通过
|
|
|
+ *
|
|
|
* @param userId
|
|
|
* @return
|
|
|
*/
|
|
|
@LoginRequired
|
|
|
@SysAdminRequired
|
|
|
@RequestMapping(value = "/user/{userId}/enterpriseAuth/status/accept", method = RequestMethod.PUT)
|
|
|
- public EnterpriseAuthVO passEnterpriseAuth(@PathVariable("userId") Long userId){
|
|
|
+ public EnterpriseAuthVO passEnterpriseAuth(@PathVariable("userId") Long userId) {
|
|
|
return userService.passEnterpriseAuth(userId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 企业认证:审核未通过
|
|
|
+ *
|
|
|
* @param userId
|
|
|
* @return
|
|
|
*/
|
|
|
@LoginRequired
|
|
|
@RequestMapping(value = "/user/{userId}/enterpriseAuth/status/reject", method = RequestMethod.PUT)
|
|
|
- public EnterpriseAuthVO rejectEnterpriseAuth(@PathVariable("userId") Long userId, @RequestBody @Validated AuthRejectCommand command){
|
|
|
+ public EnterpriseAuthVO rejectEnterpriseAuth(@PathVariable("userId") Long userId, @RequestBody @Validated AuthRejectCommand command) {
|
|
|
return userService.rejectEnterpriseAuth(userId, command.getExplain());
|
|
|
}
|
|
|
|
|
|
@LoginRequired
|
|
|
@SysAdminRequired
|
|
|
@RequestMapping(value = "/user/authentication/handling", method = RequestMethod.GET)
|
|
|
- public List<BaseAuthVO> getAuthingList(){
|
|
|
+ public List<BaseAuthVO> getAuthingList() {
|
|
|
return userService.getAuthingList();
|
|
|
}
|
|
|
|
|
|
@LoginRequired
|
|
|
@SysAdminRequired
|
|
|
@RequestMapping(value = "/user/authentication/handled", method = RequestMethod.GET)
|
|
|
- public List<BaseAuthVO> getAuthedList(){
|
|
|
+ public List<BaseAuthVO> getAuthedList() {
|
|
|
return userService.getAuthedList();
|
|
|
}
|
|
|
|