|
|
@@ -1,19 +1,25 @@
|
|
|
package com.uas.platform.b2bManage.controller;
|
|
|
|
|
|
import com.uas.platform.b2bManage.core.support.SystemSession;
|
|
|
+import com.uas.platform.b2bManage.core.util.StringUtils;
|
|
|
import com.uas.platform.b2bManage.model.UseType;
|
|
|
+import com.uas.platform.b2bManage.model.User;
|
|
|
+import com.uas.platform.b2bManage.page.exception.IllegalOperatorException;
|
|
|
import com.uas.platform.b2bManage.service.UseLogService;
|
|
|
import com.uas.platform.b2bManage.service.UserService;
|
|
|
import com.uas.platform.b2bManage.web.BaseController;
|
|
|
import com.uas.platform.core.util.AgentUtils;
|
|
|
import com.uas.platform.core.util.encry.Md5Utils;
|
|
|
+import javassist.NotFoundException;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
|
|
|
/**
|
|
|
@@ -43,7 +49,7 @@ public class AccountController extends BaseController {
|
|
|
*
|
|
|
*/
|
|
|
@RequestMapping(value = "/login", method = RequestMethod.POST)
|
|
|
- public void login(String userName, String passWord, HttpServletRequest request) throws IllegalAccessException {
|
|
|
+ public void login(String userName, String passWord) throws IllegalAccessException {
|
|
|
userService.login(userName.trim(), passWord.trim(), request);
|
|
|
useLogService.appendLog(UseType.LOGIN.code(), null, AgentUtils.getIp(request));
|
|
|
}
|
|
|
@@ -54,10 +60,70 @@ public class AccountController extends BaseController {
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
@RequestMapping(value = "/logout", method = RequestMethod.POST)
|
|
|
- public ModelMap logout(HttpServletRequest request) throws IOException {
|
|
|
+ public ModelMap logout() throws IOException {
|
|
|
SystemSession.clear();
|
|
|
request.getSession().removeAttribute("user");
|
|
|
+ useLogService.appendLog(UseType.LOGOUT.code(), null, AgentUtils.getIp(request));
|
|
|
return success();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 检验手机号
|
|
|
+ *
|
|
|
+ * @param tel 手机号码
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/valid/tel", method = RequestMethod.POST)
|
|
|
+ public ModelMap validTel(String tel) {
|
|
|
+ User user = userService.findByTel(tel);
|
|
|
+ if (null != user) {
|
|
|
+ throw new IllegalOperatorException("手机已注册");
|
|
|
+ }
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检验邮箱
|
|
|
+ *
|
|
|
+ * @param email 邮箱
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/valid/email", method = RequestMethod.POST)
|
|
|
+ public ModelMap validEmail(String email) {
|
|
|
+ User user = userService.findUserByUserEmail(email);
|
|
|
+ if (null != user) {
|
|
|
+ throw new IllegalOperatorException("邮箱已注册");
|
|
|
+ }
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 注册
|
|
|
+ *
|
|
|
+ * @param user 用户信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/register", method = RequestMethod.POST)
|
|
|
+ public ModelMap register(User user) {
|
|
|
+ return success(userService.register(user));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 找回密码
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/restPwd", method = RequestMethod.POST)
|
|
|
+ public void resetPwd(@RequestBody String email) {
|
|
|
+ if (StringUtils.isEmpty(email)) {
|
|
|
+ throw new IllegalOperatorException("请输入邮箱地址");
|
|
|
+ }
|
|
|
+ userService.sendResetPwdUrl(email);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过链接修改密码
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/restPwd", method = RequestMethod.GET)
|
|
|
+ public ModelMap resetPwdByUrl(String secretKey, HttpServletResponse response) throws IOException, NotFoundException {
|
|
|
+ return success(userService.resetPwd(secretKey,response));
|
|
|
+ }
|
|
|
}
|