Browse Source

1.修复黑名单bug问题
2.优化获取关注列表bug问题

fangzhen 2 ngày trước cách đây
mục cha
commit
50bf0125a0

+ 12 - 14
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java

@@ -31,10 +31,8 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
-import java.util.concurrent.TimeUnit;
 
 /**
  * 个人信息 业务处理
@@ -162,8 +160,8 @@ public class SysProfileController extends BaseController {
     @ApiOperation("手机号获取用户信息")
     @GetMapping("/userPhoneNumber")
     @Anonymous
-    public AjaxResult userPhoneNumber(Long userId,Long phoneNumber,Long smsCode) {
-        if (phoneNumber == null || smsCode == null ){
+    public AjaxResult userPhoneNumber(Long userId, Long phoneNumber, Long smsCode) {
+        if (phoneNumber == null || smsCode == null) {
             return error("参数异常!");
         }
         smsVerifyCodeKey(phoneNumber.toString(), smsCode.toString());
@@ -176,8 +174,8 @@ public class SysProfileController extends BaseController {
     @GetMapping("/updateToolId")
     @Anonymous
     @Transactional
-    public AjaxResult updateChangeVxAplle(String type,Long phoneNumber,Long oldUserId,Long newUserId) {
-        if (type == null){
+    public AjaxResult updateChangeVxAplle(String type, Long phoneNumber, Long oldUserId, Long newUserId) {
+        if (type == null) {
             return error("参数异常!");
         }
 
@@ -196,7 +194,7 @@ public class SysProfileController extends BaseController {
         switch (type) {
             case "1":
                 //换绑微信登录
-                if (openId == null){
+                if (openId == null) {
                     return AjaxResult.error("微信账户异常");
                 }
                 //更新老用户
@@ -213,7 +211,7 @@ public class SysProfileController extends BaseController {
                 break;
             case "2":
                 //换绑苹果登录
-                if (appId == null){
+                if (appId == null) {
                     return AjaxResult.error("苹果账户异常");
                 }
                 //更新老用户
@@ -237,14 +235,10 @@ public class SysProfileController extends BaseController {
         }
 
 
-
-
-
         return AjaxResult.success("更新成功");
     }
 
 
-
     /**
      * 重置密码(验证码)
      */
@@ -316,6 +310,7 @@ public class SysProfileController extends BaseController {
     /**
      * 校验短信验证码
      * 校验操作不更新不登录 单纯校验手机号
+     *
      * @param username 用户名
      * @param code     验证码
      * @return 结果
@@ -351,6 +346,11 @@ public class SysProfileController extends BaseController {
         if (Objects.isNull(communityUserBlock.getUserId()) || Objects.isNull(communityUserBlock.getPeerId())) {
             return AjaxResult.error("参数异常!");
         }
+
+        if (communityUserBlock.getPeerId().equals(SecurityUtils.getUserId()) || communityUserBlock.getPeerId().equals(communityUserBlock.getUserId())) {
+            return AjaxResult.error("你在干嘛! 想拉黑自己?!");
+        }
+
         CommunityUserBlock communityTagBlock = null;
         try {
             communityTagBlock = communityUserBlockService.blockUser(communityUserBlock);
@@ -364,6 +364,4 @@ public class SysProfileController extends BaseController {
     }
 
 
-
-
 }

+ 1 - 1
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityUserBlock.java

@@ -34,7 +34,7 @@ public class CommunityUserBlock implements Serializable  {
     @ApiModelProperty("用户id")
     private Long userId;
     /**
-     * 标签id
+     * 对方用户id
      */
     @ApiModelProperty("对方用户id")
     @JsonSerialize(using = ToStringSerializer.class)

+ 6 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/community/CommunityUserLikeMapper.java

@@ -14,4 +14,10 @@ public interface CommunityUserLikeMapper extends BaseMapper<CommunityUserLike> {
                                     @Param("offset") int offset,
                                     @Param("limit") int limit,
                                     @Param("searchType") int searchType);
+
+    List<CommunityUserLike> selectUserLikeList(@Param("userId") Long userId,
+                                               @Param("offset") int offset,
+                                               @Param("limit") int limit,
+                                               @Param("userName") String userName,
+                                               @Param("searchType") int searchType);
 }

+ 31 - 28
ruoyi-generator/src/main/java/com/ruoyi/generator/service/CommunityArticleServiceImpl.java

@@ -302,7 +302,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
                             }));
             if (communityCommentRaffle != null) {
                 BeanUtils.copyProperties(communityCommentRaffle, communityCommentRaffleVo);
-                CommunityUserInfoVo communityUserInfoVo = communityArticleService.selectCommunityUserInfoById(communityCommentRaffle.getUserId(),false);
+                CommunityUserInfoVo communityUserInfoVo = communityArticleService.selectCommunityUserInfoById(communityCommentRaffle.getUserId(), false);
                 communityCommentRaffleVo.setUserName(communityUserInfoVo.getNickName());
                 communityCommentRaffleVo.setUserAvatar(communityUserInfoVo.getAvatar());
                 articleVo.setCommentRaffleVo(communityCommentRaffleVo);
@@ -593,7 +593,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
                     .findFirst()
                     .ifPresent(communityCommentRaffle -> {
                         BeanUtils.copyProperties(communityCommentRaffle, communityCommentRaffleVo);
-                        CommunityUserInfoVo communityUserInfoVo = communityArticleService.selectCommunityUserInfoById(communityCommentRaffle.getUserId(),true);
+                        CommunityUserInfoVo communityUserInfoVo = communityArticleService.selectCommunityUserInfoById(communityCommentRaffle.getUserId(), true);
                         communityCommentRaffleVo.setUserName(communityUserInfoVo.getNickName());
                         communityCommentRaffleVo.setUserAvatar(communityUserInfoVo.getAvatar());
                         articleVo.setCommentRaffleVo(communityCommentRaffleVo);
@@ -1195,7 +1195,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
      * @return 用户信息
      */
     @Override
-    public CommunityUserInfoVo selectCommunityUserInfoById(Long userId,boolean isToken) {
+    public CommunityUserInfoVo selectCommunityUserInfoById(Long userId, boolean isToken) {
         SysUser sysUser = sysUserMapper.selectUserById(userId);
 
         System.out.println(sysUser);
@@ -1262,15 +1262,15 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
     public List<CommunityUserInfoVo> selectUserBySearchValue(@Param("searchValue") String searchValue,
                                                              @Param("offset") int offset,
                                                              @Param("limit") int limit) {
-        return communityUserInfoMapper.selectUserBySearchValue(searchValue,offset,limit);
+        return communityUserInfoMapper.selectUserBySearchValue(searchValue, offset, limit);
     }
 
     @Override
-    public List<CommunityUserInfoVo> selectBlockUserBySearchValue( @Param("searchValue") String searchValue,
-                                                                   @Param("userId") Long userId,
-                                                                   @Param("offset") int offset,
-                                                                   @Param("limit") int limit) {
-        return communityUserInfoMapper.selectBlockUserBySearchValue(searchValue,userId,offset,limit);
+    public List<CommunityUserInfoVo> selectBlockUserBySearchValue(@Param("searchValue") String searchValue,
+                                                                  @Param("userId") Long userId,
+                                                                  @Param("offset") int offset,
+                                                                  @Param("limit") int limit) {
+        return communityUserInfoMapper.selectBlockUserBySearchValue(searchValue, userId, offset, limit);
     }
 
     /**
@@ -1305,16 +1305,19 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
      */
     @Override
     public List<CommunityUserLikeVo> selectCommunityUserLikeList(Long userId, String userName, int pageNum, int pageSize, int searchType) {
-        //int offset = (pageNum - 1) * pageSize;
-        Page<CommunityUserLike> page = new Page<>(pageNum, pageSize);
-        QueryWrapper<CommunityUserLike> queryWrapper = new QueryWrapper<CommunityUserLike>()
-                .eq("user_id", userId);
-        if (searchType == 1) {
-            queryWrapper.orderByDesc("create_time");
-        } else {
-            queryWrapper.orderByAsc("create_time");
-        }
-        List<CommunityUserLike> communityUserLikes = communityUserLikeMapper.selectPage(page, queryWrapper).getRecords();
+        int offset = (pageNum - 1) * pageSize;
+//        Page<CommunityUserLike> page = new Page<>(pageNum, pageSize);
+//        QueryWrapper<CommunityUserLike> queryWrapper = new QueryWrapper<CommunityUserLike>()
+//                .eq("user_id", userId);
+//        if (searchType == 1) {
+//            queryWrapper.orderByDesc("create_time");
+//        } else {
+//            queryWrapper.orderByAsc("create_time");
+//        }
+//
+//        List<CommunityUserLike> communityUserLikes = communityUserLikeMapper.selectPage(page, queryWrapper).getRecords();
+
+        List<CommunityUserLike> communityUserLikes = communityUserLikeMapper.selectUserLikeList(userId, offset, pageSize, userName, searchType);
 
         List<CommunityUserLikeVo> communityUserLikeVos = new ArrayList<>();
         CommunityUserLikeVo communityUserLikeVo = null;
@@ -1360,12 +1363,12 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
             }
 
             //如果不需要搜索名字直接添加
-            if (userName != null && communityUserLikeVo.getLikeUsername().matches("(?i).*" + Pattern.quote(userName) + ".*")) {
-                communityUserLikeVos.add(communityUserLikeVo);
-            } else if (userName == null) {
-                communityUserLikeVos.add(communityUserLikeVo);
-            }
-
+//            if (userName != null && communityUserLikeVo.getLikeUsername().matches("(?i).*" + Pattern.quote(userName) + ".*")) {
+//                communityUserLikeVos.add(communityUserLikeVo);
+//            } else if (userName == null) {
+//                communityUserLikeVos.add(communityUserLikeVo);
+//            }
+            communityUserLikeVos.add(communityUserLikeVo);
         }
         return communityUserLikeVos;
     }
@@ -1396,7 +1399,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
 
         for (CommunityUserLike communityUserLike : communityUserLikes) {
             Boolean isCare = false;
-           // System.out.println(communityUserLike.getUserId()  + "---" + userId);
+            // System.out.println(communityUserLike.getUserId()  + "---" + userId);
             //用户信息
             SysUser sysUserLike = sysUserMapper.selectUserById(communityUserLike.getLikeUserId());
             //用户自我介绍
@@ -1730,14 +1733,14 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
             commentRaffle.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
             communityCommentRaffleMapper.insert(commentRaffle);
             BeanUtils.copyProperties(commentRaffle, communityCommentRaffleVo);
-            communityUserInfoVo = communityArticleService.selectCommunityUserInfoById(commentRaffle.getUserId(),true);
+            communityUserInfoVo = communityArticleService.selectCommunityUserInfoById(commentRaffle.getUserId(), true);
             communityCommentRaffleVo.setUserName(communityUserInfoVo.getNickName());
             communityCommentRaffleVo.setUserAvatar(communityUserInfoVo.getAvatar());
             return communityCommentRaffleVo;
         }
 
         BeanUtils.copyProperties(communityCommentRaffle, communityCommentRaffleVo);
-        communityUserInfoVo = communityArticleService.selectCommunityUserInfoById(communityCommentRaffle.getUserId(),true);
+        communityUserInfoVo = communityArticleService.selectCommunityUserInfoById(communityCommentRaffle.getUserId(), true);
         communityCommentRaffleVo.setUserName(communityUserInfoVo.getNickName());
         communityCommentRaffleVo.setUserAvatar(communityUserInfoVo.getAvatar());
         return communityCommentRaffleVo;

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

@@ -60,7 +60,7 @@
         LEFT JOIN community_user_info b ON a.user_id = b.user_id
         WHERE a.user_id IN (
         SELECT peer_id
-        FROM `ruoyi-community`.community_user_block cub
+        FROM community_user_block cub
         WHERE user_id = #{userId} AND is_block = '1'
         )
         <if test="searchValue != null and searchValue != ''">

+ 30 - 8
ruoyi-generator/src/main/resources/mapper/community/CommunityUserLikeMapper.xml

@@ -5,14 +5,15 @@
 <mapper namespace="com.ruoyi.generator.mapper.community.CommunityUserLikeMapper">
     <select id="selectLikeByUserId" resultType="com.ruoyi.generator.vo.LikeVo">
         select cul.id,
-               cul.create_time,
-               cul.user_id,
-               cul.like_user_id,
-               (select nick_name from sys_user su where su.user_id = cul.user_id) as nick_name,
-               (select avatar from sys_user su where su.user_id = cul.user_id)    as avatar,
-               (select  id  from community_user_like cul2 where cul2.user_id = #{userId}  and cul2.like_user_id = cul.user_id) as isLike,
-               cul.is_read,
-               '4' as type
+        cul.create_time,
+        cul.user_id,
+        cul.like_user_id,
+        (select nick_name from sys_user su where su.user_id = cul.user_id) as nick_name,
+        (select avatar from sys_user su where su.user_id = cul.user_id) as avatar,
+        (select id from community_user_like cul2 where cul2.user_id = #{userId} and cul2.like_user_id = cul.user_id) as
+        isLike,
+        cul.is_read,
+        '4' as type
         from community_user_like cul
         where cul.like_user_id = #{userId} and (cul.is_notice != 1 or cul.is_notice is null)
         <if test="searchType == 1">
@@ -23,4 +24,25 @@
         </if>
         limit #{offset},#{limit}
     </select>
+
+
+    <select id="selectUserLikeList" resultType="com.ruoyi.generator.domain.Community.CommunityUserLike">
+        select
+        cul.id,cul.user_id,cul.like_user_id,cul.is_read,cul.create_by,cul.create_time,cul.update_by,cul.update_time,cul.is_notice
+        from community_user_like cul
+        left join sys_user su on cul.user_id = su.user_id
+        left join sys_user su1 on cul.like_user_id = su1.user_id
+        where cul.user_id = #{userId} and (cul.is_notice != 1 or cul.is_notice is null)
+        <if test="userName != null and userName != ''">
+            and su1.nick_name like CONCAT('%', #{userName}, '%')
+        </if>
+
+        <if test="searchType == 1">
+            order by cul.create_time desc
+        </if>
+        <if test="searchType == 2">
+            order by cul.create_time asc
+        </if>
+        limit #{offset},#{limit}
+    </select>
 </mapper>