Commit b2074d29 authored by jiaorz's avatar jiaorz

获取用户信息异常

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