|
|
@@ -1,16 +1,15 @@
|
|
|
package com.goafanti.user.controller;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.UUID;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
-import org.apache.shiro.authc.UnknownAccountException;
|
|
|
import org.apache.shiro.web.util.SavedRequest;
|
|
|
import org.apache.shiro.web.util.WebUtils;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
@@ -21,19 +20,16 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.goafanti.app.bo.UserBasicInfo;
|
|
|
import com.goafanti.common.bo.Result;
|
|
|
import com.goafanti.common.constant.ErrorConstants;
|
|
|
import com.goafanti.common.controller.BaseController;
|
|
|
import com.goafanti.common.dao.AdminMapper;
|
|
|
import com.goafanti.common.model.Admin;
|
|
|
-import com.goafanti.common.model.MessageConsumer;
|
|
|
-import com.goafanti.common.model.MessageProducer;
|
|
|
import com.goafanti.common.model.User;
|
|
|
+import com.goafanti.common.utils.PasswordUtil;
|
|
|
import com.goafanti.common.utils.TimeUtils;
|
|
|
import com.goafanti.common.utils.VerifyCodeUtils;
|
|
|
import com.goafanti.core.shiro.token.TokenManager;
|
|
|
-import com.goafanti.message.bo.MessageBo;
|
|
|
import com.goafanti.message.service.MessageService;
|
|
|
import com.goafanti.user.service.UserService;
|
|
|
|
|
|
@@ -46,6 +42,9 @@ public class UserLoginController extends BaseController {
|
|
|
@Resource
|
|
|
private MessageService messageService;
|
|
|
|
|
|
+ @Resource(name = "passwordUtil")
|
|
|
+ private PasswordUtil passwordUtil;
|
|
|
+
|
|
|
|
|
|
@RequestMapping(value = "/login", method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
@@ -74,9 +73,61 @@ public class UserLoginController extends BaseController {
|
|
|
jo.put("queryString", sr.getQueryString());
|
|
|
}
|
|
|
res.setToken(SecurityUtils.getSubject().getSession().getId());
|
|
|
+ Map<String, Object> map =new HashMap<>();
|
|
|
+ map.put("uid",TokenManager.getUserId());
|
|
|
+ map.put("type",TokenManager.getUserType());
|
|
|
+ res.data(map);
|
|
|
return res;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 登录检查
|
|
|
+ *
|
|
|
+ * @param remember
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/open/loginCheck", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public Result loginCheck(String mobile,String password) {
|
|
|
+ Result res = new Result();
|
|
|
+ if (StringUtils.isBlank(mobile)||StringUtils.isBlank(password)) {
|
|
|
+ res.getError().add(buildError("","手机号码不能为空"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ User user=userService.selectByMobieAndType(mobile,null);
|
|
|
+ String pwd=user.getPassword();
|
|
|
+ user.setPassword(password);
|
|
|
+ if (!pwd.equals(passwordUtil.getEncryptPwd(user))) {
|
|
|
+ res.getError().add(buildError("","手机密码错误"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ if (user!=null) {
|
|
|
+ res.data(user);
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ @RequestMapping(value = "/open/updateUser",method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public Result updateUser(User u){
|
|
|
+ Result res = new Result();
|
|
|
+ if(u!=null&&StringUtils.isNotEmpty(u.getMobile())){
|
|
|
+ //验证手机号码格式是否正确
|
|
|
+ Pattern p = Pattern.compile("^(1[1-9][0-9])\\d{8}$"); // 验证手机号
|
|
|
+ Matcher m = p.matcher(u.getMobile());
|
|
|
+ if(!m.matches()){
|
|
|
+ res.getError().add(buildError("电话号码格式不对","电话号码格式不对"));
|
|
|
+ }else{
|
|
|
+ //验证手机是否存在
|
|
|
+ int i = userService.getCountByMobile(u.getId(),u.getMobile(),u.getType());
|
|
|
+ if(i>0){
|
|
|
+ res.getError().add(buildError("电话号码重复","电话号码重复"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ res.data(userService.updateByPrimaryKeySelective(u));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 用户登录
|