优化用户查询接口:先校验是否登录,然后才能查询用户数据
This commit is contained in:
@@ -219,7 +219,7 @@ public class UserController {
|
||||
public JSONArray getUserList(HttpServletRequest request)throws Exception {
|
||||
JSONArray dataArray = new JSONArray();
|
||||
try {
|
||||
List<User> dataList = userService.getUser();
|
||||
List<User> dataList = userService.getUser(request);
|
||||
if (null != dataList) {
|
||||
for (User user : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
@@ -476,7 +476,7 @@ public class UserController {
|
||||
Long userId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"userId").toString());
|
||||
User user = userService.getUser(userId);
|
||||
//获取当前用户数
|
||||
int userCurrentNum = userService.getUser().size();
|
||||
int userCurrentNum = userService.getUser(request).size();
|
||||
Tenant tenant = tenantService.getTenantByTenantId(user.getTenantId());
|
||||
if(tenant.getExpireTime()!=null && tenant.getExpireTime().getTime()<System.currentTimeMillis()){
|
||||
//租户已经过期,移除token
|
||||
|
||||
@@ -96,12 +96,16 @@ public class UserService {
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<User> getUser()throws Exception {
|
||||
UserExample example = new UserExample();
|
||||
example.createCriteria().andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL);
|
||||
public List<User> getUser(HttpServletRequest request) throws Exception {
|
||||
List<User> list=null;
|
||||
try{
|
||||
//先校验是否登录,然后才能查询用户数据
|
||||
Long userId = this.getUserId(request);
|
||||
if(userId!=null) {
|
||||
UserExample example = new UserExample();
|
||||
example.createCriteria().andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL);
|
||||
list = userMapper.selectByExample(example);
|
||||
}
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
@@ -111,6 +115,10 @@ public class UserService {
|
||||
public List<UserEx> select(String userName, String loginName, int offset, int rows)throws Exception {
|
||||
List<UserEx> list=null;
|
||||
try {
|
||||
//先校验是否登录,然后才能查询用户数据
|
||||
HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
|
||||
Long userId = this.getUserId(request);
|
||||
if(userId!=null) {
|
||||
list = userMapperEx.selectByConditionUser(userName, loginName, offset, rows);
|
||||
for (UserEx ue : list) {
|
||||
String userType = "";
|
||||
@@ -131,6 +139,7 @@ public class UserService {
|
||||
}
|
||||
ue.setLeaderFlagStr(leaderFlagStr);
|
||||
}
|
||||
}
|
||||
} catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
@@ -875,7 +884,7 @@ public class UserService {
|
||||
//选中的用户的数量
|
||||
int selectUserSize = list.size();
|
||||
//查询启用状态的用户的数量
|
||||
int enableUserSize = getUser().size();
|
||||
int enableUserSize = getUser(request).size();
|
||||
User userInfo = userService.getCurrentUser();
|
||||
Tenant tenant = tenantService.getTenantByTenantId(userInfo.getTenantId());
|
||||
if(tenant!=null) {
|
||||
|
||||
Reference in New Issue
Block a user