|
@@ -2,17 +2,18 @@ package cn.iselab.mooctest.site.web.ctrl;
|
|
|
|
|
|
|
|
import cn.iselab.mooctest.site.common.constant.UrlConstants;
|
|
import cn.iselab.mooctest.site.common.constant.UrlConstants;
|
|
|
import cn.iselab.mooctest.site.configure.realm.DefaultUsernamepasswordToken;
|
|
import cn.iselab.mooctest.site.configure.realm.DefaultUsernamepasswordToken;
|
|
|
|
|
+import cn.iselab.mooctest.site.dao.MobileVerificationDao;
|
|
|
|
|
+import cn.iselab.mooctest.site.models.MobileVerification;
|
|
|
import cn.iselab.mooctest.site.models.User;
|
|
import cn.iselab.mooctest.site.models.User;
|
|
|
import cn.iselab.mooctest.site.service.UserService;
|
|
import cn.iselab.mooctest.site.service.UserService;
|
|
|
-import cn.iselab.mooctest.site.util.data.EncryptionUtil;
|
|
|
|
|
import cn.iselab.mooctest.site.web.data.ManagerPropertyVO;
|
|
import cn.iselab.mooctest.site.web.data.ManagerPropertyVO;
|
|
|
import cn.iselab.mooctest.site.web.data.UserVO;
|
|
import cn.iselab.mooctest.site.web.data.UserVO;
|
|
|
import cn.iselab.mooctest.site.web.data.wrapper.UserVOWrapper;
|
|
import cn.iselab.mooctest.site.web.data.wrapper.UserVOWrapper;
|
|
|
import cn.iselab.mooctest.site.web.exception.HttpBadRequestException;
|
|
import cn.iselab.mooctest.site.web.exception.HttpBadRequestException;
|
|
|
import cn.iselab.mooctest.site.web.exception.HttpUnauthorizedException;
|
|
import cn.iselab.mooctest.site.web.exception.HttpUnauthorizedException;
|
|
|
|
|
+import cn.iselab.mooctest.site.web.logic.ManagerPropertyLogic;
|
|
|
import cn.iselab.mooctest.site.web.logic.MenuLogic;
|
|
import cn.iselab.mooctest.site.web.logic.MenuLogic;
|
|
|
import cn.iselab.mooctest.site.web.logic.UserLogic;
|
|
import cn.iselab.mooctest.site.web.logic.UserLogic;
|
|
|
-import jdk.nashorn.internal.ir.RuntimeNode;
|
|
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
import org.apache.shiro.authc.*;
|
|
import org.apache.shiro.authc.*;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
@@ -40,32 +41,37 @@ public class UserController {
|
|
|
private MenuLogic menuLogic;
|
|
private MenuLogic menuLogic;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private UserVOWrapper userVOWrapper;
|
|
private UserVOWrapper userVOWrapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MobileVerificationDao mobileVerificationDao;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ManagerPropertyLogic managerPropertyLogic;
|
|
|
|
|
|
|
|
private Logger LOG = LoggerFactory.getLogger(getClass());
|
|
private Logger LOG = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
|
|
@RequiresPermissions("personInfo:update")
|
|
@RequiresPermissions("personInfo:update")
|
|
|
- @RequestMapping(value = UrlConstants.API+ "user/name", method = RequestMethod.PUT)
|
|
|
|
|
|
|
+ @RequestMapping(value = UrlConstants.API + "user/name", method = RequestMethod.PUT)
|
|
|
public UserVO updateUserName(@RequestBody UserVO userVO) {
|
|
public UserVO updateUserName(@RequestBody UserVO userVO) {
|
|
|
return userLogic.updateName(userVO);
|
|
return userLogic.updateName(userVO);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@RequiresPermissions("personInfo:update")
|
|
@RequiresPermissions("personInfo:update")
|
|
|
- @RequestMapping(value = UrlConstants.API+ "user/school", method = RequestMethod.PUT)
|
|
|
|
|
|
|
+ @RequestMapping(value = UrlConstants.API + "user/school", method = RequestMethod.PUT)
|
|
|
public UserVO updateUserSchool(@RequestBody UserVO userVO) {
|
|
public UserVO updateUserSchool(@RequestBody UserVO userVO) {
|
|
|
return userLogic.updateSchool(userVO);
|
|
return userLogic.updateSchool(userVO);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@RequiresPermissions("personInfo:update")
|
|
@RequiresPermissions("personInfo:update")
|
|
|
- @RequestMapping(value = UrlConstants.API+ "user/mobile", method = RequestMethod.PUT)
|
|
|
|
|
|
|
+ @RequestMapping(value = UrlConstants.API + "user/mobile", method = RequestMethod.PUT)
|
|
|
public UserVO updateMobile(@RequestBody UserVO userVO) {
|
|
public UserVO updateMobile(@RequestBody UserVO userVO) {
|
|
|
return userLogic.updateMobile(userVO);
|
|
return userLogic.updateMobile(userVO);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequiresPermissions("password:update")
|
|
@RequiresPermissions("password:update")
|
|
|
- @RequestMapping(value = UrlConstants.API+ "user/password", method = RequestMethod.PUT)
|
|
|
|
|
- public UserVO updateUserPassword(@RequestBody UserVO userVO,HttpServletRequest request) {
|
|
|
|
|
- return userLogic.updateUserPassword(userVO,request);
|
|
|
|
|
|
|
+ @RequestMapping(value = UrlConstants.API + "user/password", method = RequestMethod.PUT)
|
|
|
|
|
+ public UserVO updateUserPassword(@RequestBody UserVO userVO, HttpServletRequest request) {
|
|
|
|
|
+ return userLogic.updateUserPassword(userVO, request);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@RequestMapping(value = "/api/test/managerApplication", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/api/test/managerApplication", method = RequestMethod.POST)
|
|
@@ -75,20 +81,8 @@ public class UserController {
|
|
|
return userLogic.applyForManager(user.getId());
|
|
return userLogic.applyForManager(user.getId());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @RequiresRoles("admin")
|
|
|
|
|
- @RequestMapping(value = UrlConstants.API + "test/managerApproval/{id:\\d+}", method = RequestMethod.PUT)
|
|
|
|
|
- public void approveManagerApplication(@PathVariable("id") Long userId) {
|
|
|
|
|
- userLogic.approveofManager(userId);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @RequiresRoles("admin")
|
|
|
|
|
- @RequestMapping(value = "/api/test/property/{id:\\d+}", method = RequestMethod.PUT)
|
|
|
|
|
- public ManagerPropertyVO updatePropertyInfoOfManager(@PathVariable("id") Long managerId) {
|
|
|
|
|
- return userLogic.updateUserProperty(managerId);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
@RequestMapping(value = "/api/mobileLogin", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/api/mobileLogin", method = RequestMethod.POST)
|
|
|
- public UserVO loginByMobile(@RequestBody UserVO userVO, BindingResult bindingResult, RedirectAttributes redirectAttributes){
|
|
|
|
|
|
|
+ public UserVO loginByMobile(@RequestBody UserVO userVO, BindingResult bindingResult, RedirectAttributes redirectAttributes) {
|
|
|
if (bindingResult.hasErrors()) {
|
|
if (bindingResult.hasErrors()) {
|
|
|
throw new HttpUnauthorizedException("unauthorized");
|
|
throw new HttpUnauthorizedException("unauthorized");
|
|
|
|
|
|
|
@@ -97,7 +91,7 @@ public class UserController {
|
|
|
if (username == null) {
|
|
if (username == null) {
|
|
|
throw new HttpBadRequestException("empty user");
|
|
throw new HttpBadRequestException("empty user");
|
|
|
}
|
|
}
|
|
|
- DefaultUsernamepasswordToken token = new DefaultUsernamepasswordToken(username,userVO.getCaptcha());
|
|
|
|
|
|
|
+ DefaultUsernamepasswordToken token = new DefaultUsernamepasswordToken(username, userVO.getCaptcha());
|
|
|
token.setLoginType("mobile");
|
|
token.setLoginType("mobile");
|
|
|
// token.setRememberMe(true);
|
|
// token.setRememberMe(true);
|
|
|
//获取当前的Subject
|
|
//获取当前的Subject
|
|
@@ -140,4 +134,34 @@ public class UserController {
|
|
|
throw new HttpUnauthorizedException("login failed");
|
|
throw new HttpUnauthorizedException("login failed");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @RequestMapping(value = "/api/common/captcha/zhong", method = RequestMethod.GET)
|
|
|
|
|
+ public String getCaptcha() {
|
|
|
|
|
+ MobileVerification mobileVerification = mobileVerificationDao.findTop1ByMobileOrderByCreateTimeDesc("13006107158");
|
|
|
|
|
+ return mobileVerification.getCode();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @RequiresRoles("admin")
|
|
|
|
|
+ @RequestMapping(value = UrlConstants.API + "user/verification", method = RequestMethod.PUT)
|
|
|
|
|
+ public void approveManager(@RequestBody UserVO userVO) {
|
|
|
|
|
+ userLogic.authorizeManagerRole(userVO);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @RequiresRoles("admin")
|
|
|
|
|
+ @RequestMapping(value = UrlConstants.API + "user/property/{userId}", method = RequestMethod.PUT)
|
|
|
|
|
+ public ManagerPropertyVO updatePropertyInfoOfManager(@PathVariable("userId") Long userId, @RequestBody ManagerPropertyVO managerPropertyVO) {
|
|
|
|
|
+ return userLogic.updateUserProperty(userId, managerPropertyVO);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @RequiresRoles("admin")
|
|
|
|
|
+ @RequestMapping(value = UrlConstants.API + "user/info", method = RequestMethod.POST)
|
|
|
|
|
+ public UserVO getUserBasicInfo(@RequestBody UserVO userVO) {
|
|
|
|
|
+ return userLogic.getUserBasicInfo(userVO);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @RequiresRoles("admin")
|
|
|
|
|
+ @RequestMapping(value = UrlConstants.API + "user/property/{userId}", method = RequestMethod.GET)
|
|
|
|
|
+ public ManagerPropertyVO getManagerProperty(@PathVariable("userId") Long userId) {
|
|
|
|
|
+ return managerPropertyLogic.getManagerPropertyByUserId(userId);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|