🎨 用户管理列表接口修改
This commit is contained in:
parent
b7585747d6
commit
fa9d9dd92c
@ -3,6 +3,7 @@ package com.rymcu.forest.dto;
|
|||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@ -40,4 +41,9 @@ public class UserInfoDTO implements Serializable {
|
|||||||
@JSONField(format = "yyyy-MM-dd HH:mm")
|
@JSONField(format = "yyyy-MM-dd HH:mm")
|
||||||
private Date lastOnlineTime;
|
private Date lastOnlineTime;
|
||||||
|
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createdTime;
|
||||||
|
|
||||||
|
private Integer onlineStatus;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ public interface UserMapper extends Mapper<User> {
|
|||||||
* @param searchDTO
|
* @param searchDTO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<User> selectUsers(@Param("searchDTO") UserSearchDTO searchDTO);
|
List<UserInfoDTO> selectUsers(@Param("searchDTO") UserSearchDTO searchDTO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新用户最后在线时间
|
* 更新用户最后在线时间
|
||||||
|
@ -142,7 +142,7 @@ public interface UserService extends Service<User> {
|
|||||||
* @param searchDTO
|
* @param searchDTO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<User> findUsers(UserSearchDTO searchDTO);
|
List<UserInfoDTO> findUsers(UserSearchDTO searchDTO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过邮箱查询用户信息
|
* 通过邮箱查询用户信息
|
||||||
|
@ -6,6 +6,7 @@ import com.rymcu.forest.dto.*;
|
|||||||
import com.rymcu.forest.entity.Role;
|
import com.rymcu.forest.entity.Role;
|
||||||
import com.rymcu.forest.entity.User;
|
import com.rymcu.forest.entity.User;
|
||||||
import com.rymcu.forest.entity.UserExtend;
|
import com.rymcu.forest.entity.UserExtend;
|
||||||
|
import com.rymcu.forest.jwt.def.JwtConstants;
|
||||||
import com.rymcu.forest.jwt.service.TokenManager;
|
import com.rymcu.forest.jwt.service.TokenManager;
|
||||||
import com.rymcu.forest.lucene.model.UserLucene;
|
import com.rymcu.forest.lucene.model.UserLucene;
|
||||||
import com.rymcu.forest.lucene.util.UserIndexUtil;
|
import com.rymcu.forest.lucene.util.UserIndexUtil;
|
||||||
@ -282,8 +283,20 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> findUsers(UserSearchDTO searchDTO) {
|
public List<UserInfoDTO> findUsers(UserSearchDTO searchDTO) {
|
||||||
return userMapper.selectUsers(searchDTO);
|
List<UserInfoDTO> users = userMapper.selectUsers(searchDTO);
|
||||||
|
users.forEach(user -> {
|
||||||
|
user.setOnlineStatus(getUserOnlineStatus(user.getEmail()));
|
||||||
|
});
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer getUserOnlineStatus(String email) {
|
||||||
|
String lastOnlineTime = redisService.get(JwtConstants.LAST_ONLINE + email);
|
||||||
|
if (StringUtils.isBlank(lastOnlineTime)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,10 +4,7 @@ import com.github.pagehelper.PageHelper;
|
|||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.rymcu.forest.core.result.GlobalResult;
|
import com.rymcu.forest.core.result.GlobalResult;
|
||||||
import com.rymcu.forest.core.result.GlobalResultGenerator;
|
import com.rymcu.forest.core.result.GlobalResultGenerator;
|
||||||
import com.rymcu.forest.dto.ArticleDTO;
|
import com.rymcu.forest.dto.*;
|
||||||
import com.rymcu.forest.dto.ArticleSearchDTO;
|
|
||||||
import com.rymcu.forest.dto.CommentDTO;
|
|
||||||
import com.rymcu.forest.dto.UserSearchDTO;
|
|
||||||
import com.rymcu.forest.dto.admin.TopicTagDTO;
|
import com.rymcu.forest.dto.admin.TopicTagDTO;
|
||||||
import com.rymcu.forest.dto.admin.UserRoleDTO;
|
import com.rymcu.forest.dto.admin.UserRoleDTO;
|
||||||
import com.rymcu.forest.entity.*;
|
import com.rymcu.forest.entity.*;
|
||||||
@ -47,8 +44,8 @@ public class AdminController {
|
|||||||
@GetMapping("/users")
|
@GetMapping("/users")
|
||||||
public GlobalResult<Map<String, Object>> users(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, UserSearchDTO searchDTO){
|
public GlobalResult<Map<String, Object>> users(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, UserSearchDTO searchDTO){
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
List<User> list = userService.findUsers(searchDTO);
|
List<UserInfoDTO> list = userService.findUsers(searchDTO);
|
||||||
PageInfo<User> pageInfo = new PageInfo<>(list);
|
PageInfo<UserInfoDTO> pageInfo = new PageInfo<>(list);
|
||||||
Map<String, Object> map = new HashMap<String, Object>(2);
|
Map<String, Object> map = new HashMap<String, Object>(2);
|
||||||
map.put("users", pageInfo.getList());
|
map.put("users", pageInfo.getList());
|
||||||
Map pagination = Utils.getPagination(pageInfo);
|
Map pagination = Utils.getPagination(pageInfo);
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
<result column="status" property="status"/>
|
<result column="status" property="status"/>
|
||||||
<result column="last_login_time" property="lastLoginTime"/>
|
<result column="last_login_time" property="lastLoginTime"/>
|
||||||
<result column="last_online_time" property="lastOnlineTime"/>
|
<result column="last_online_time" property="lastOnlineTime"/>
|
||||||
|
<result column="created_time" property="createdTime"/>
|
||||||
<result column="signature" property="signature"/>
|
<result column="signature" property="signature"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<resultMap id="DTOResultMapper" type="com.rymcu.forest.dto.UserDTO">
|
<resultMap id="DTOResultMapper" type="com.rymcu.forest.dto.UserDTO">
|
||||||
@ -105,7 +106,7 @@
|
|||||||
<select id="selectAuthor" resultMap="AuthorResultMap">
|
<select id="selectAuthor" resultMap="AuthorResultMap">
|
||||||
select * from forest_user where id = #{id}
|
select * from forest_user where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
<select id="selectUsers" resultMap="BaseResultMap">
|
<select id="selectUsers" resultMap="UserInfoResultMapper">
|
||||||
select id, nickname, sex, avatar_type, avatar_url, email, account, status, last_login_time, created_time, last_online_time from forest_user
|
select id, nickname, sex, avatar_type, avatar_url, email, account, status, last_login_time, created_time, last_online_time from forest_user
|
||||||
<where>
|
<where>
|
||||||
<if test="searchDTO.nickname != null and searchDTO.nickname != ''">
|
<if test="searchDTO.nickname != null and searchDTO.nickname != ''">
|
||||||
|
Loading…
Reference in New Issue
Block a user