Commit b2074d29 authored by jiaorz's avatar jiaorz

获取用户信息异常

parent f33f9811
......@@ -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.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;
......@@ -18,7 +17,6 @@ import org.springframework.web.bind.annotation.*;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
/**
......@@ -54,11 +52,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);
}
......@@ -68,8 +66,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));
......@@ -89,13 +86,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()));
......@@ -106,7 +101,7 @@ public class PublicController {
//获取用户基础信息
AppUserVo userVo = detailBiz.getUserInfoById(userid);
if (userVo == null) {
return null;
return null;
}
Integer id= userVo.getId();
Integer positionId=userVo.getPositionId();
......@@ -128,15 +123,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")
......@@ -149,9 +144,7 @@ public class PublicController {
AppUserVo userVo = detailBiz.getUserInfoById(id);
appUserVos.add(userVo);
}
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