Commit 9e643ee4 authored by hezhen's avatar hezhen

Merge branch 'hz_master' into dev

# Conflicts:
#	ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rpc/AppUserRest.java
parents eda3ef8f aeeff91a
...@@ -247,4 +247,15 @@ public class AuthController { ...@@ -247,4 +247,15 @@ public class AuthController {
return authService.checkToken(token); return authService.checkToken(token);
} }
@RequestMapping(value = "/updUsername", method = RequestMethod.POST)
public ObjectRestResponse updUsername(@RequestParam(value="username",defaultValue="")String username,
@RequestParam(value="mobilecode",defaultValue="")String mobilecode,
HttpServletRequest request)throws Exception {
log.info(username + "----require updUsername...");
String token = request.getHeader(tokenHeader);
return appAuthService.updUsername(username, mobilecode, token);
}
} }
...@@ -5,6 +5,8 @@ import com.github.wxiaoqi.security.api.vo.user.AppUserInfo; ...@@ -5,6 +5,8 @@ import com.github.wxiaoqi.security.api.vo.user.AppUserInfo;
import com.github.wxiaoqi.security.api.vo.user.UserInfo; import com.github.wxiaoqi.security.api.vo.user.UserInfo;
import com.github.wxiaoqi.security.auth.configuration.FeignConfiguration; import com.github.wxiaoqi.security.auth.configuration.FeignConfiguration;
import com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest; import com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -78,4 +80,8 @@ public interface IUserService { ...@@ -78,4 +80,8 @@ public interface IUserService {
@PostMapping("/api/app/imi/login") @PostMapping("/api/app/imi/login")
String loginImiWithToken(); String loginImiWithToken();
@ApiModelProperty("修改手机号码")
@GetMapping("/api/app/updUsername")
public ObjectRestResponse updUsername(@RequestParam(value = "username") String username, @RequestParam(value = "mobilecode") String mobilecode, @RequestParam(value = "userId",defaultValue = "0") Integer userId);
} }
...@@ -6,6 +6,8 @@ import com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest; ...@@ -6,6 +6,8 @@ import com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest;
public interface AuthService { public interface AuthService {
String login(JwtAuthenticationRequest authenticationRequest) throws Exception; String login(JwtAuthenticationRequest authenticationRequest) throws Exception;
ObjectRestResponse loginSmall(JwtAuthenticationRequest authenticationRequest) throws Exception; ObjectRestResponse loginSmall(JwtAuthenticationRequest authenticationRequest) throws Exception;
...@@ -39,4 +41,6 @@ public interface AuthService { ...@@ -39,4 +41,6 @@ public interface AuthService {
String loginImiWithToken(); String loginImiWithToken();
ObjectRestResponse checkToken(String token); ObjectRestResponse checkToken(String token);
ObjectRestResponse updUsername(String username, String mobilecode, String token);
} }
...@@ -13,10 +13,13 @@ import com.github.wxiaoqi.security.common.constant.RequestTypeConstants; ...@@ -13,10 +13,13 @@ import com.github.wxiaoqi.security.common.constant.RequestTypeConstants;
import com.github.wxiaoqi.security.common.exception.auth.UserInvalidException; import com.github.wxiaoqi.security.common.exception.auth.UserInvalidException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletRequest;
/** /**
* @author keliii * @author keliii
*/ */
...@@ -138,4 +141,27 @@ public class AppAuthServiceImpl implements AuthService { ...@@ -138,4 +141,27 @@ public class AppAuthServiceImpl implements AuthService {
} }
@Override
public ObjectRestResponse updUsername(String username, String mobilecode, String token) {
if (StringUtils.isEmpty(token)){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE,"token不能为空");
}
try {
IJWTInfo ijwtInfo=jwtTokenUtil.getInfoFromToken(token);
if (ijwtInfo==null){
return ObjectRestResponse.createFailedResult(10009,"token失效");
}
Integer userId= Integer.parseInt(ijwtInfo.getId());
ObjectRestResponse objectRestResponse=userService.updUsername(username,mobilecode,userId);
if (objectRestResponse.getStatus()==ResultCode.SUCCESS_CODE){
token=getToken(username,userId);
objectRestResponse.setData(token);
}
return objectRestResponse;
}catch (Exception e){
e.printStackTrace();
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"操作失败");
}
}
} }
...@@ -134,4 +134,27 @@ public class AuthServiceImpl implements AuthService { ...@@ -134,4 +134,27 @@ public class AuthServiceImpl implements AuthService {
} }
} }
@Override
public ObjectRestResponse updUsername(String username, String mobilecode, String token) {
if (StringUtils.isEmpty(token)){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE,"token不能为空");
}
try {
IJWTInfo ijwtInfo=jwtTokenUtil.getInfoFromToken(token);
if (ijwtInfo==null){
return ObjectRestResponse.createFailedResult(10009,"token失效");
}
Integer userId= Integer.parseInt(ijwtInfo.getId());
ObjectRestResponse objectRestResponse=userService.updUsername(username,mobilecode,userId);
if (objectRestResponse.getStatus()==ResultCode.SUCCESS_CODE){
token=getToken(username,userId);
objectRestResponse.setData(token);
}
return objectRestResponse;
}catch (Exception e){
e.printStackTrace();
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"操作失败");
}
}
} }
...@@ -257,15 +257,25 @@ public class AppUserRest { ...@@ -257,15 +257,25 @@ public class AppUserRest {
@ApiModelProperty("检查手机号验证码") @ApiModelProperty("检查手机号验证码")
@GetMapping("/unauth/checkMobilecode") @GetMapping("/unauth/checkMobilecode")
public ObjectRestResponse checkMobilecode(@RequestParam(value = "phone") String phone, public ObjectRestResponse checkMobilecode(@RequestParam(value = "phone") String phone,
@RequestParam(value = "mobilecode") String mobilecode){ @RequestParam(value = "mobilecode") String mobilecode) {
if (StringUtils.isBlank(phone)||StringUtils.isBlank(mobilecode)){ if (StringUtils.isBlank(phone) || StringUtils.isBlank(mobilecode)) {
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数为空"); return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数为空");
} }
String redisKey=appPermissionService.checkCodeByUsername(phone,mobilecode); String redisKey = appPermissionService.checkCodeByUsername(phone, mobilecode);
if (StringUtils.isBlank(redisKey)){ if (StringUtils.isBlank(redisKey)) {
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, "验证码错误"); return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, "验证码错误");
} }
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
}
@ApiModelProperty("修改手机号码")
@GetMapping("/updUsername")
public ObjectRestResponse updUsername(@RequestParam(value = "username") String username,
@RequestParam(value = "mobilecode") String mobilecode,
@RequestParam(value = "userId",defaultValue = "0") Integer userId){
return appPermissionService.updUsername(userId,username,mobilecode);
} }
......
...@@ -1134,4 +1134,26 @@ public class AppPermissionService { ...@@ -1134,4 +1134,26 @@ public class AppPermissionService {
public static final String CITY_NAME = "city"; public static final String CITY_NAME = "city";
} }
//修改手机号码
public ObjectRestResponse updUsername(Integer userId,String username,String mobileCode){
if (StringUtils.isBlank(username)||StringUtils.isBlank(mobileCode)||userId==0||userId==null){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE,"参数不能为空");
}
if (StringUtils.isBlank(checkCodeByUsername(username,mobileCode))){
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"验证码错误");
}
log.info("----updUsername----userId==="+userId+"---username==="+username);
// 是否已存在
AppUserLogin user = appUserLoginBiz.checkeUserLogin(username);
if (null != user) {
return ObjectRestResponse.createFailedResult(ResultCode.EXIST_CODE, "用户已存在");
}
AppUserLogin userLogin=new AppUserLogin();
userLogin.setId(userId);
userLogin.setUsername(username);
appUserLoginBiz.updateSelectiveById(userLogin);
return ObjectRestResponse.succ();
}
} }
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