Commit 55b73c24 by 段启岩

优化用户dto命名

parent 55b2cf55
......@@ -23,7 +23,6 @@ import cn.meteor.beyondclouds.modules.search.service.ISearchService;
import cn.meteor.beyondclouds.modules.topic.service.ITopicService;
import cn.meteor.beyondclouds.modules.user.dto.UserInfoDTO;
import cn.meteor.beyondclouds.modules.user.entity.User;
import cn.meteor.beyondclouds.modules.user.entity.UserStatistics;
import cn.meteor.beyondclouds.modules.user.exception.UserServiceException;
import cn.meteor.beyondclouds.modules.user.service.IUserService;
import com.baomidou.mybatisplus.core.metadata.IPage;
......
......@@ -9,12 +9,10 @@ import cn.meteor.beyondclouds.core.api.Response;
import cn.meteor.beyondclouds.core.authentication.Subject;
import cn.meteor.beyondclouds.core.flow.AccessInfo;
import cn.meteor.beyondclouds.core.flow.ParamType;
import cn.meteor.beyondclouds.modules.user.dto.UserAuthDTO;
import cn.meteor.beyondclouds.modules.user.dto.UserInfoDTO;
import cn.meteor.beyondclouds.modules.user.dto.UserInfoWithStatisticsDTO;
import cn.meteor.beyondclouds.modules.user.dto.FollowUserDTO;
import cn.meteor.beyondclouds.modules.user.entity.User;
import cn.meteor.beyondclouds.modules.user.entity.UserBlacklist;
import cn.meteor.beyondclouds.modules.user.entity.UserFollow;
import cn.meteor.beyondclouds.modules.user.entity.UserStatistics;
import cn.meteor.beyondclouds.modules.user.exception.UserServiceException;
import cn.meteor.beyondclouds.modules.user.form.*;
......@@ -33,7 +31,6 @@ import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* @author meteor
......@@ -299,10 +296,10 @@ public class UserApi {
@ApiOperation(("获取我的粉丝"))
@GetMapping("/my/fans")
public Response<PageDTO<UserInfoWithStatisticsDTO>> myFans(@Valid PageForm pageForm, @CurrentSubject Subject subject){
public Response<PageDTO<FollowUserDTO>> myFans(@Valid PageForm pageForm, @CurrentSubject Subject subject){
// 根据userId获取粉丝并返回
PageDTO<UserInfoWithStatisticsDTO> fansPage = userFollowService.getFansPage(pageForm.getPage(), pageForm.getSize(), (String) subject.getId());
PageDTO<FollowUserDTO> fansPage = userFollowService.getFansPage(pageForm.getPage(), pageForm.getSize(), (String) subject.getId());
return Response.success(fansPage);
}
......@@ -310,10 +307,10 @@ public class UserApi {
@Anonymous
@ApiOperation(("获取他人粉丝"))
@GetMapping("/user/{userId}/fans")
public Response<PageDTO<UserInfoWithStatisticsDTO>> otherFans(@Valid PageForm pageForm, @PathVariable(name = "userId") String userId){
public Response<PageDTO<FollowUserDTO>> otherFans(@Valid PageForm pageForm, @PathVariable(name = "userId") String userId){
// 根据userId获取粉丝并返回
PageDTO<UserInfoWithStatisticsDTO> fansPage = userFollowService.getFansPage(pageForm.getPage(), pageForm.getSize(),userId);
PageDTO<FollowUserDTO> fansPage = userFollowService.getFansPage(pageForm.getPage(), pageForm.getSize(),userId);
return Response.success(fansPage);
}
......@@ -323,14 +320,14 @@ public class UserApi {
public Response myFollower(@Valid PageForm pageForm, @CurrentSubject Subject subject){
// 根据userId获取关注列表并返回
PageDTO<UserInfoWithStatisticsDTO> followedPage = userFollowService.getFollowedPage(pageForm.getPage(), pageForm.getSize(), String.valueOf(subject.getId()));
PageDTO<FollowUserDTO> followedPage = userFollowService.getFollowedPage(pageForm.getPage(), pageForm.getSize(), String.valueOf(subject.getId()));
return Response.success(followedPage);
}
@Anonymous
@ApiOperation(("获取他人关注"))
@GetMapping("/user/{userId}/follower")
public Response<PageDTO<UserInfoWithStatisticsDTO>> otherFollower(@Valid PageForm pageForm, @PathVariable(name = "userId") String userId){
public Response<PageDTO<FollowUserDTO>> otherFollower(@Valid PageForm pageForm, @PathVariable(name = "userId") String userId){
// 根据userId获取关注列表并返回
PageDTO followedPage = userFollowService.getFollowedPage(pageForm.getPage(), pageForm.getSize(), userId);
......
......@@ -10,7 +10,7 @@ import java.util.Date;
* @author meteor
*/
@Data
public class UserInfoWithStatisticsDTO {
public class FollowUserDTO {
private String userId;
......
package cn.meteor.beyondclouds.modules.user.service;
import cn.meteor.beyondclouds.common.dto.PageDTO;
import cn.meteor.beyondclouds.modules.user.dto.UserInfoWithStatisticsDTO;
import cn.meteor.beyondclouds.modules.user.dto.FollowUserDTO;
import cn.meteor.beyondclouds.modules.user.entity.UserFollow;
import cn.meteor.beyondclouds.modules.user.exception.UserServiceException;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.Set;
/**
* @author 段启岩
......@@ -41,7 +38,7 @@ public interface IUserFollowService extends IService<UserFollow> {
* @param userId
* @return
*/
PageDTO<UserInfoWithStatisticsDTO> getFansPage(Integer pageNumber, Integer pageSize, String userId);
PageDTO<FollowUserDTO> getFansPage(Integer pageNumber, Integer pageSize, String userId);
/**
* 根据userId查询关注的用户
......@@ -50,7 +47,7 @@ public interface IUserFollowService extends IService<UserFollow> {
* @param userId
* @return
*/
PageDTO<UserInfoWithStatisticsDTO> getFollowedPage(Integer pageNumber, Integer pageSize, String userId);
PageDTO<FollowUserDTO> getFollowedPage(Integer pageNumber, Integer pageSize, String userId);
/**
* 判断当前用户有没有关注目标用户
......
package cn.meteor.beyondclouds.modules.user.service;
import cn.meteor.beyondclouds.common.dto.QQAuthResultDTO;
import cn.meteor.beyondclouds.modules.user.dto.UserAuthDTO;
import cn.meteor.beyondclouds.modules.user.dto.UserInfoDTO;
import cn.meteor.beyondclouds.modules.user.entity.User;
import cn.meteor.beyondclouds.modules.user.entity.UserStatistics;
import cn.meteor.beyondclouds.modules.user.exception.UserServiceException;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* @author meteor
*/
......
......@@ -7,7 +7,7 @@ import cn.meteor.beyondclouds.core.queue.message.DataItemChangeMessage;
import cn.meteor.beyondclouds.core.queue.message.DataItemType;
import cn.meteor.beyondclouds.core.redis.RedisKey;
import cn.meteor.beyondclouds.modules.queue.service.IMessageQueueService;
import cn.meteor.beyondclouds.modules.user.dto.UserInfoWithStatisticsDTO;
import cn.meteor.beyondclouds.modules.user.dto.FollowUserDTO;
import cn.meteor.beyondclouds.modules.user.entity.User;
import cn.meteor.beyondclouds.modules.user.entity.UserBlacklist;
import cn.meteor.beyondclouds.modules.user.entity.UserFollow;
......@@ -183,7 +183,7 @@ public class UserFollowServiceImpl extends ServiceImpl<UserFollowMapper, UserFol
* @return
*/
@Override
public PageDTO<UserInfoWithStatisticsDTO> getFansPage(Integer pageNumber, Integer pageSize, String userId) {
public PageDTO<FollowUserDTO> getFansPage(Integer pageNumber, Integer pageSize, String userId) {
IPage<UserFollow> page = new Page<>(pageNumber, pageSize);
QueryWrapper<UserFollow> userFollowQueryWrapper = new QueryWrapper<>();
userFollowQueryWrapper.eq("followed_id", userId);
......@@ -192,7 +192,7 @@ public class UserFollowServiceImpl extends ServiceImpl<UserFollowMapper, UserFol
List<UserFollow> userFollowList = userFollowPage.getRecords();
List<UserInfoWithStatisticsDTO> userInfoWithStatisticsDTOList;
List<FollowUserDTO> followUserDTOList;
if (!CollectionUtils.isEmpty(userFollowList)) {
// 取出我的粉丝的ID
List<String> fanUserIds = userFollowList.stream()
......@@ -209,31 +209,31 @@ public class UserFollowServiceImpl extends ServiceImpl<UserFollowMapper, UserFol
));
// 通过userFollowList构造userInfoWithStatisticsDTOList
userInfoWithStatisticsDTOList = userFollowList.stream()
followUserDTOList = userFollowList.stream()
.map(userFollow -> {
UserInfoWithStatisticsDTO userInfoWithStatisticsDTO = new UserInfoWithStatisticsDTO();
FollowUserDTO followUserDTO = new FollowUserDTO();
String fansId = userFollow.getFollowerId();
userInfoWithStatisticsDTO.setUserId(fansId);
userInfoWithStatisticsDTO.setUserNick(userFollow.getFollowerNick());
userInfoWithStatisticsDTO.setUserAvatar(userFollow.getFollowerAvatar());
userInfoWithStatisticsDTO.setStatistics(userStatisticsMap.get(fansId));
followUserDTO.setUserId(fansId);
followUserDTO.setUserNick(userFollow.getFollowerNick());
followUserDTO.setUserAvatar(userFollow.getFollowerAvatar());
followUserDTO.setStatistics(userStatisticsMap.get(fansId));
if (SubjectUtils.isAuthenticated()) {
userInfoWithStatisticsDTO.setFollowedUser(hasFollowedUser(fansId));
followUserDTO.setFollowedUser(hasFollowedUser(fansId));
} else {
userInfoWithStatisticsDTO.setFollowedUser(false);
followUserDTO.setFollowedUser(false);
}
return userInfoWithStatisticsDTO;
return followUserDTO;
}).collect(Collectors.toList());
} else {
userInfoWithStatisticsDTOList = List.of();
followUserDTOList = List.of();
}
// 3.转换分页并返回
PageDTO<UserInfoWithStatisticsDTO> pageDTO = new PageDTO<>();
PageDTO<FollowUserDTO> pageDTO = new PageDTO<>();
PageUtils.copyMeta(userFollowPage, pageDTO);
pageDTO.setDataList(userInfoWithStatisticsDTOList);
pageDTO.setDataList(followUserDTOList);
return pageDTO;
}
......@@ -266,7 +266,7 @@ public class UserFollowServiceImpl extends ServiceImpl<UserFollowMapper, UserFol
* @return
*/
@Override
public PageDTO<UserInfoWithStatisticsDTO> getFollowedPage(Integer pageNumber, Integer pageSize, String userId) {
public PageDTO<FollowUserDTO> getFollowedPage(Integer pageNumber, Integer pageSize, String userId) {
// 1.获取所有的关注
IPage<UserFollow> page = new Page<>(pageNumber, pageSize);
......@@ -277,7 +277,7 @@ public class UserFollowServiceImpl extends ServiceImpl<UserFollowMapper, UserFol
List<UserFollow> userFollowList = userFollowPage.getRecords();
// 2.查询关注的用户的统计信息并填充到userInfoWithStatisticsDTOList里面
List<UserInfoWithStatisticsDTO> userInfoWithStatisticsDTOList;
List<FollowUserDTO> followUserDTOList;
if (!CollectionUtils.isEmpty(userFollowList)) {
List<String> followedUserIds = userFollowList.stream()
.map(UserFollow::getFollowedId).collect(Collectors.toList());
......@@ -288,31 +288,31 @@ public class UserFollowServiceImpl extends ServiceImpl<UserFollowMapper, UserFol
userStatistics -> userStatistics
));
userInfoWithStatisticsDTOList = userFollowList.stream()
followUserDTOList = userFollowList.stream()
.map(userFollow -> {
UserInfoWithStatisticsDTO userInfoWithStatisticsDTO = new UserInfoWithStatisticsDTO();
FollowUserDTO followUserDTO = new FollowUserDTO();
String followedId = userFollow.getFollowedId();
userInfoWithStatisticsDTO.setUserId(followedId);
userInfoWithStatisticsDTO.setUserNick(userFollow.getFollowedNick());
userInfoWithStatisticsDTO.setUserAvatar(userFollow.getFollowedAvatar());
userInfoWithStatisticsDTO.setStatistics(userStatisticsMap.get(followedId));
followUserDTO.setUserId(followedId);
followUserDTO.setUserNick(userFollow.getFollowedNick());
followUserDTO.setUserAvatar(userFollow.getFollowedAvatar());
followUserDTO.setStatistics(userStatisticsMap.get(followedId));
if (SubjectUtils.isAuthenticated()) {
userInfoWithStatisticsDTO.setFollowedUser(hasFollowedUser(followedId));
followUserDTO.setFollowedUser(hasFollowedUser(followedId));
} else {
userInfoWithStatisticsDTO.setFollowedUser(false);
followUserDTO.setFollowedUser(false);
}
return userInfoWithStatisticsDTO;
return followUserDTO;
}).collect(Collectors.toList());
} else {
userInfoWithStatisticsDTOList = List.of();
followUserDTOList = List.of();
}
// 3.转换分页并返回
PageDTO<UserInfoWithStatisticsDTO> pageDTO = new PageDTO<>();
PageDTO<FollowUserDTO> pageDTO = new PageDTO<>();
PageUtils.copyMeta(userFollowPage, pageDTO);
pageDTO.setDataList(userInfoWithStatisticsDTOList);
pageDTO.setDataList(followUserDTOList);
return pageDTO;
}
......
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