Commit 0c1814a8 authored by 周健威's avatar 周健威

自动注册

parent 0de0ed4c
......@@ -28,6 +28,9 @@ public interface IUserService {
@RequestMapping(value = "/api/app/user/validate", method = RequestMethod.POST)
AppUserInfo AppValidate(@RequestBody JwtAuthenticationRequest authenticationRequest);
@RequestMapping(value = "/api/app/user/validateMaxkey", method = RequestMethod.POST)
AppUserInfo AppValidateMaxkey(@RequestBody JwtAuthenticationRequest authenticationRequest);
@RequestMapping(value = "/api/app/user/sendsms", method = RequestMethod.POST)
public JSONObject sendsms(@RequestParam(value="username",defaultValue="")String username, @RequestParam(value="type",defaultValue="0")Integer type, @RequestParam(value="pointList", defaultValue = "")String pointList);
@RequestMapping(value = "/api/app/user/register", method = RequestMethod.POST)
......
......@@ -33,7 +33,8 @@ public class AppAuthServiceImpl implements AuthService {
@Override
public String login(JwtAuthenticationRequest authenticationRequest) throws Exception {
AppUserInfo info = userService.AppValidate(authenticationRequest);
// AppUserInfo info = userService.AppValidate(authenticationRequest);
AppUserInfo info = userService.AppValidateMaxkey(authenticationRequest);
if (info!=null&&!StringUtils.isEmpty(info.getId())) {
// 在jwt中加入requestType
return jwtTokenUtil.generateToken(new JWTInfo(info.getUsername(), info.getId() + "", info.getName(),
......
......@@ -73,6 +73,29 @@ public class AppUserRest {
}
}
@RequestMapping(value = "/user/validateMaxkey", method = RequestMethod.POST)
public @ResponseBody
AppUserInfo validateMaxkey(@RequestBody Map<String,String> body){
if(null != body.get("checkpass") && body.get("checkpass").equals("0")) {
AppUserInfo info = new AppUserInfo();
AppUserLogin user = appUserLoginBiz.checkeUserLogin(body.get("username"));
if (user != null ) {
info.setUsername(user.getUsername());
info.setId(user.getId() + "");
}else {
String nickname=SystemConfig.USER_NIKENAME_DEFAULT+(int)((Math.random()*9+1)*100000);
appPermissionService.registerCommon(body.get("username"), "123456", SystemConfig.USER_HEADER_URL_DEFAULT,nickname,
null, null,0, "",1, null);
user = appUserLoginBiz.checkeUserLogin(body.get("username"));
info.setUsername(user.getUsername());
info.setId(user.getId() + "");
}
return info;
}else {
return appPermissionService.validate(body.get("username"),body.get("password"));
}
}
/**
* 发送验证码
* @param username
......
......@@ -264,6 +264,10 @@ public class AppPermissionService {
if (StringUtils.isBlank(mobilecodeRedis)) {
return JsonResultUtil.createFailedResult(ResultCode.NOTEXIST_CODE, "验证码错误");
}
return registerCommon(username, password, headimgurl, nickname, openId, unionid, type, code, channel, activityCode);
}
public JSONObject registerCommon(String username, String password, String headimgurl, String nickname, String openId, String unionid, Integer type, String code, Integer channel, String activityCode) {
// 是否已存在
AppUserLogin user = appUserLoginBiz.checkeUserLogin(username);
if (null != user) {
......@@ -313,7 +317,7 @@ public class AppPermissionService {
rsUserDetail.setChannel(channel);
appUserDetailBiz.insertSelective(rsUserDetail);
// 登录结果要做做统一处理
JSONObject data = autoLogin(userid, username, headimgurl, nickname,code,activityCode,1);
JSONObject data = autoLogin(userid, username, headimgurl, nickname, code, activityCode,1);
log.info("注册:登录结果要做做统一处理: " + userid+"---time===="+System.currentTimeMillis()/1000L);
if (data != null) {
return JsonResultUtil.createSuccessResultWithObj(data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment