Kaynağa Gözat

搜索用户信息增加分页

fangqing 3 gün önce
ebeveyn
işleme
0bf44b4dd3

+ 11 - 4
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityArticleController.java

@@ -994,16 +994,20 @@ public class CommunityArticleController extends BaseController {
     }
 
 
-    @ApiOperation("搜索用户列表信息")
+    @ApiOperation("根据条件搜索用户列表信息(无权限卡控)")
     @GetMapping("/userList")
     public AjaxResult userList(String SearchValue) {
         if (Objects.isNull(SearchValue)) {
             return AjaxResult.error();
         }
+        int pageNum = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
+        int pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
+        int offset = (pageNum - 1) * pageSize;
+
         Long userId = SecurityUtils.getLoginUser().getUserId();
         List<CommunityUserInfoVo> communityUserInfoVos = null;
         try {
-            communityUserInfoVos = communityArticleService.selectUserBySearchValue(SearchValue);
+            communityUserInfoVos = communityArticleService.selectUserBySearchValue(SearchValue, offset, pageSize);
 
             List<CommunityUserInfoVo> communityUserInfoVos_copy = new ArrayList<>(communityUserInfoVos);
             for (CommunityUserInfoVo communityUserInfoVo : communityUserInfoVos_copy) {
@@ -1053,15 +1057,18 @@ public class CommunityArticleController extends BaseController {
         return AjaxResult.success(communityUserInfoVos);
     }
 
-    @ApiOperation("根据条件查询账户")
+    @ApiOperation("根据条件搜索用户列表信息(有权限卡控)")
     @GetMapping("/selectUserList")
     public AjaxResult selectUserList(String SearchValue) {
         if (Objects.isNull(SearchValue)) {
             return AjaxResult.error();
         }
+        int pageNum = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
+        int pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
+        int offset = (pageNum - 1) * pageSize;
         List<CommunityUserInfoVo> communityUserInfoVos = null;
         try {
-            communityUserInfoVos = communityArticleService.selectUsersByAccountOrName(SearchValue);
+            communityUserInfoVos = communityArticleService.selectUsersByAccountOrName(SearchValue, offset, pageSize);
         } catch (Exception e) {
             log.info(e.getMessage());
             throw new ProjectException();

+ 10 - 6
ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/community/CommunityUserInfoMapper.java

@@ -11,12 +11,14 @@ import java.util.List;
 @Mapper
 public interface CommunityUserInfoMapper extends BaseMapper<CommunityUserInfo> {
     /**
-     * 根据搜索值,搜索用户
+     * 根据条件搜索用户列表信息(无权限卡控)
      *
-     * @param SearchValue 搜索值
+     * @param searchValue 搜索值
      * @return 用户
      */
-    List<CommunityUserInfoVo> selectUserBySearchValue(String SearchValue);
+    List<CommunityUserInfoVo> selectUserBySearchValue(@Param("searchValue") String searchValue,
+                                                      @Param("offset") int offset,
+                                                      @Param("limit") int limit);
 
     /**
      * 根据拉黑用户信息
@@ -29,9 +31,11 @@ public interface CommunityUserInfoMapper extends BaseMapper<CommunityUserInfo> {
                                                             @Param("offset") int offset,
                                                             @Param("limit") int limit);
     /**
-     * 根据账户或者用户名称,搜索用户
-     * @param SearchValue 搜索值
+     * 根据条件搜索用户列表信息(有权限卡控)
+     * @param searchValue 搜索值
      * @return 用户
      */
-    List<CommunityUserInfoVo> selectUsersByAccountOrName(String SearchValue);
+    List<CommunityUserInfoVo> selectUsersByAccountOrName(@Param("searchValue") String searchValue,
+                                                         @Param("offset") int offset,
+                                                         @Param("limit") int limit);
 }

+ 12 - 8
ruoyi-generator/src/main/java/com/ruoyi/generator/service/CommunityArticleServiceImpl.java

@@ -1253,14 +1253,16 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
     }
 
     /**
-     * 根据搜索值,搜索用户
+     * 根据条件搜索用户列表信息(无权限卡控)
      *
-     * @param SearchValue 搜索值
+     * @param searchValue 搜索值
      * @return 用户
      */
     @Override
-    public List<CommunityUserInfoVo> selectUserBySearchValue(String SearchValue) {
-        return communityUserInfoMapper.selectUserBySearchValue(SearchValue);
+    public List<CommunityUserInfoVo> selectUserBySearchValue(@Param("searchValue") String searchValue,
+                                                             @Param("offset") int offset,
+                                                             @Param("limit") int limit) {
+        return communityUserInfoMapper.selectUserBySearchValue(searchValue,offset,limit);
     }
 
     @Override
@@ -1272,14 +1274,16 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
     }
 
     /**
-     * 根据账户或者用户名称,搜索用户
+     * 根据条件搜索用户列表信息(有权限卡控)
      *
-     * @param SearchValue 搜索值
+     * @param searchValue 搜索值
      * @return 用户
      */
     @Override
-    public List<CommunityUserInfoVo> selectUsersByAccountOrName(String SearchValue) {
-        List<CommunityUserInfoVo> communityUserInfoVos = communityUserInfoMapper.selectUsersByAccountOrName(SearchValue);
+    public List<CommunityUserInfoVo> selectUsersByAccountOrName(@Param("searchValue") String searchValue,
+                                                                @Param("offset") int offset,
+                                                                @Param("limit") int limit) {
+        List<CommunityUserInfoVo> communityUserInfoVos = communityUserInfoMapper.selectUsersByAccountOrName(searchValue, offset, limit);
         communityUserInfoVos.forEach(item -> {
             CommunityUserLike communityUserLike = communityUserLikeMapper.selectOne(new QueryWrapper<CommunityUserLike>()
                     .eq("user_id", SecurityUtils.getUserId())

+ 10 - 6
ruoyi-generator/src/main/java/com/ruoyi/generator/service/ICommunityArticleService.java

@@ -132,12 +132,14 @@ public interface ICommunityArticleService extends IService<CommunityArticle> {
     CommunityUserInfoVo selectCommunityUserInfoById(Long userId,boolean isToken);
 
     /**
-     * 根据搜索值,搜索用户
+     * 根据条件搜索用户列表信息(无权限卡控)
      *
-     * @param SearchValue 搜索值
+     * @param searchValue 搜索值
      * @return 用户
      */
-    List<CommunityUserInfoVo> selectUserBySearchValue(String SearchValue);
+    List<CommunityUserInfoVo> selectUserBySearchValue(@Param("searchValue") String searchValue,
+                                                      @Param("offset") int offset,
+                                                      @Param("limit") int limit);
 
 
     /**
@@ -152,11 +154,13 @@ public interface ICommunityArticleService extends IService<CommunityArticle> {
                                                            @Param("limit") int limit);
 
     /**
-     * 根据账户或者用户名称,搜索用户
-     * @param SearchValue
+     * 根据条件搜索用户列表信息(有权限卡控)
+     * @param searchValue
      * @return 用户
      */
-    List<CommunityUserInfoVo> selectUsersByAccountOrName(String SearchValue);
+    List<CommunityUserInfoVo> selectUsersByAccountOrName(@Param("searchValue") String searchValue,
+                                                         @Param("offset") int offset,
+                                                         @Param("limit") int limite);
 
     /**
      * 获取关注列表

+ 4 - 1
ruoyi-generator/src/main/resources/mapper/community/CommunityUserInfoMapper.xml

@@ -20,9 +20,10 @@
                 or b.user_id like concat('%', #{searchValue}, '%')
             </where>
         </if>
-
+        LIMIT #{offset}, #{limit}
     </select>
     <select id="selectUsersByAccountOrName" resultType="com.ruoyi.generator.vo.CommunityUserInfoVo">
+        select * from (
         select
         b.id as id,
         a.user_id as userId,
@@ -54,6 +55,8 @@
                 IFNULL(c.is_names,0)  = 0 and  a.nick_name like concat('%', #{searchValue}, '%')
             </where>
         </if>
+        )  as a
+        LIMIT #{offset}, #{limit}
     </select>
     <select id="selectBlockUserBySearchValue" resultType="com.ruoyi.generator.vo.CommunityUserInfoVo">
         SELECT