Commit 375d4022 authored by jiaorz's avatar jiaorz

获取用户信息异常

parent 021fd02b
......@@ -10,7 +10,6 @@ import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.admin.vo.AppUserVo;
import com.github.wxiaoqi.security.admin.vo.UserMemberVo;
import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import org.apache.commons.beanutils.BeanUtils;
......@@ -19,7 +18,6 @@ import org.springframework.web.bind.annotation.*;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
/**
......@@ -55,11 +53,11 @@ public class PublicController {
ObjectRestResponse userinfoByToken(String token) throws Exception {
String username = userAuthUtil.getInfoFromToken(token).getUniqueName();
if (username == null) {
throw new BaseException(ResultCode.NOTEXIST_CODE);
return ObjectRestResponse.createFailedResult(ResultCode.USER_NOTEXIST_CODE, ResultCode.getMsg(ResultCode.USER_NOTEXIST_CODE));
}
User user = userBiz.getUserByUsername(username);
if (user == null) {
throw new BaseException(ResultCode.NOTEXIST_CODE);
return ObjectRestResponse.createFailedResult(ResultCode.USER_NOTEXIST_CODE, ResultCode.getMsg(ResultCode.USER_NOTEXIST_CODE));
}
return new ObjectRestResponse<User>().rel(true).data(user);
}
......@@ -69,8 +67,7 @@ public class PublicController {
ObjectRestResponse userDetailByToken(String token) throws Exception {
String username = userAuthUtil.getInfoFromToken(token).getId();
if (username == null) {
throw new BaseException(ResultCode.NOTEXIST_CODE
, new HashSet<String>() {{add("用户名不存在!");}});
return ObjectRestResponse.createFailedResult(ResultCode.USER_NOTEXIST_CODE, ResultCode.getMsg(ResultCode.USER_NOTEXIST_CODE));
}
Integer userid = Integer.parseInt(username);
return ObjectRestResponse.succ(getAppUserInfoById(userid));
......@@ -90,13 +87,11 @@ public class PublicController {
ObjectRestResponse<AppUserDTO> userDetailByUsername(String name) throws Exception {
AppUserLogin appUserLogin;
if (StrUtil.isBlank(name)) {
throw new BaseException(ResultCode.NOTEXIST_CODE
, new HashSet<String>() {{add("用户名不存在!");}});
return ObjectRestResponse.paramIsEmpty();
}else {
appUserLogin = appUserLoginBiz.selectOne(new AppUserLogin(){{setUsername(name);}});
if(null == appUserLogin) {
throw new BaseException(ResultCode.NOTEXIST_CODE
, new HashSet<String>() {{add("用户名不存在!");}});
return ObjectRestResponse.createFailedResult(ResultCode.USER_NOTEXIST_CODE, ResultCode.getMsg(ResultCode.USER_NOTEXIST_CODE));
}
}
return ObjectRestResponse.succ(getAppUserInfoById(appUserLogin.getId()));
......@@ -129,15 +124,15 @@ public class PublicController {
@RequestMapping(value = "/userinfo-by-uid", method = RequestMethod.GET)
public @ResponseBody
ObjectRestResponse userinfoByUid(Integer uid) throws Exception {
ObjectRestResponse<User> userinfoByUid(Integer uid) throws Exception {
if (uid == null||uid==0) {
throw new BaseException();
return ObjectRestResponse.paramIsEmpty();
}
User user = userBiz.getUserByUid(uid);
if (user == null) {
throw new BaseException();
return ObjectRestResponse.createFailedResult(ResultCode.USER_NOTEXIST_CODE, ResultCode.getMsg(ResultCode.USER_NOTEXIST_CODE));
}
return new ObjectRestResponse<User>().rel(true).data(user);
return ObjectRestResponse.succ(user);
}
@GetMapping("/getByUserIds")
......
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