diff --git a/src/main/java/com/share/help/controller/UserController.java b/src/main/java/com/share/help/controller/UserController.java index b4360fc..b1a29b5 100644 --- a/src/main/java/com/share/help/controller/UserController.java +++ b/src/main/java/com/share/help/controller/UserController.java @@ -131,21 +131,6 @@ public class UserController { - /** - * 查询用户信息 - * @param queryUserForm 搜索条件 - * @return 返回查询结果 - */ - @GetMapping(Constants.USER_INTERFACE_FIND_NAME) - public JSONResponse>> queryUser(QueryUserForm queryUserForm,@CookieValue(Constants.USER_COOKIE) String userId){ - if(userId!=null){ - queryUserForm.setUserId(userId); - return userService.queryUser(queryUserForm); - }else{ - return new JSONResponse<>(DefaultRes.fail, Result.FAIL); - } - } - /** * 留言列表 * @return 返回留言列表 @@ -219,6 +204,23 @@ public class UserController { } } + + + /** + * 查询用户信息 + * @param queryUserForm 搜索条件 + * @return 返回查询结果 + */ + @GetMapping(Constants.USER_INTERFACE_FIND_NAME) + public JSONResponse>> queryUser(QueryUserForm queryUserForm,@CookieValue(Constants.USER_COOKIE) String userId){ + if(userId!=null){ + queryUserForm.setUserId(userId); + return userService.queryUser(queryUserForm); + }else{ + return new JSONResponse<>(DefaultRes.fail, Result.FAIL); + } + } + /** * 刷新用户的聊天状态 * @param chatForm 刷新表单 diff --git a/src/main/java/com/share/help/dao/FriendMapper.java b/src/main/java/com/share/help/dao/FriendMapper.java index ff6b07b..7599797 100644 --- a/src/main/java/com/share/help/dao/FriendMapper.java +++ b/src/main/java/com/share/help/dao/FriendMapper.java @@ -24,16 +24,16 @@ public interface FriendMapper { /** * 获取好友邀请 * @param userId 目标用户 - * @param serviceAddress 服务地点 * @return 返回好友id */ - List getFriend(@Param("userId") String userId, @Param("name") String name, String serviceAddress, @Param("start") long start, @Param("count") long count); + List getFriend(@Param("userId") String userId, @Param("name") String name, + @Param("targetUserId") String targetUserId, @Param("start") long start, @Param("count") long count); /** * 统计好友分页数 * @param userId 目标用户 - * @param serviceAddress 服务地点 * @return 返回分页数 */ - Page> count(@Param("userId") String userId, @Param("name") String name, String serviceAddress, @Param("pageSize") Integer pageSize); + Page> count(@Param("userId") String userId, @Param("name") String name, + @Param("targetUserId") String targetUserId, @Param("pageSize") Integer pageSize); } diff --git a/src/main/java/com/share/help/form/SearchFrom.java b/src/main/java/com/share/help/form/SearchFrom.java index 026c562..eeda291 100644 --- a/src/main/java/com/share/help/form/SearchFrom.java +++ b/src/main/java/com/share/help/form/SearchFrom.java @@ -10,8 +10,6 @@ public class SearchFrom { private String targetUserId; //用户名 private String name; - //服务地点 - private String serviceAddress; //分页数 private Integer currentPage; @@ -46,12 +44,4 @@ public class SearchFrom { public void setUserId(String userId) { this.userId = userId; } - - public String getServiceAddress() { - return serviceAddress; - } - - public void setServiceAddress(String serviceAddress) { - this.serviceAddress = serviceAddress; - } } diff --git a/src/main/java/com/share/help/service/UserService.java b/src/main/java/com/share/help/service/UserService.java index 8f0f731..57dc60c 100644 --- a/src/main/java/com/share/help/service/UserService.java +++ b/src/main/java/com/share/help/service/UserService.java @@ -215,9 +215,9 @@ public class UserService{ * @return 返回好友列表 */ public JSONResponse>> searchFriend(SearchFrom searchFrom) { - Page> page=friendMapper.count(searchFrom.getUserId(),searchFrom.getName(),searchFrom.getServiceAddress(),friendSize); + Page> page=friendMapper.count(searchFrom.getUserId(),searchFrom.getName(),searchFrom.getTargetUserId(),friendSize); page.setCurrentPage(searchFrom.getCurrentPage()); - List list=friendMapper.getFriend(searchFrom.getUserId(),searchFrom.getName(),searchFrom.getServiceAddress(),(searchFrom.getCurrentPage()-1)*friendSize,friendSize); + List list=friendMapper.getFriend(searchFrom.getUserId(),searchFrom.getName(),searchFrom.getTargetUserId(),(searchFrom.getCurrentPage()-1)*friendSize,friendSize); page.setBody(list); return new JSONResponse>>(DefaultRes.ok,Result.OK).setBody(page); } diff --git a/src/main/resources/mapping/FriendMapper.xml b/src/main/resources/mapping/FriendMapper.xml index 5bf3670..1132e06 100644 --- a/src/main/resources/mapping/FriendMapper.xml +++ b/src/main/resources/mapping/FriendMapper.xml @@ -13,12 +13,12 @@ union all select target_user_id as userId from friend where target_user_id!=#{userId} and source_user_id=#{userId}) - - and name like '%${name}%' + + and user_id like '%${targetUserId}%' - - and service_address like '%${serviceAddress}%' + + and name like '%${name}%' limit #{start},#{count} @@ -39,12 +39,13 @@ where target_user_id != #{userId} and source_user_id = #{userId} ) - - and name like '%${name}%' + + + and user_id like '%${targetUserId}%' - - and service_address like '%${serviceAddress}%' + + and name like '%${name}%' diff --git a/src/test/java/com/share/help/HelpApplicationTests.java b/src/test/java/com/share/help/HelpApplicationTests.java index e5f0f73..c61f1b1 100644 --- a/src/test/java/com/share/help/HelpApplicationTests.java +++ b/src/test/java/com/share/help/HelpApplicationTests.java @@ -232,9 +232,9 @@ class HelpApplicationTests { */ @Test public void queryFriend(){ - Page> page=friendMapper.count("123","6", "", 3); + Page> page=friendMapper.count("123","", "2", 3); Assertions.assertEquals(1, (long) page.getCount()); - List user=friendMapper.getFriend("123","6", "上海", 0,3); + List user=friendMapper.getFriend("123","", "2", 0,3); Assertions.assertEquals(1,user.size()); user=friendMapper.getFriend("123","6", "广州", 0,3); Assertions.assertTrue(user.isEmpty());