消息--添加--获取新关注人数,获取新关注列表

This commit is contained in:
haotianmingyue 2024-12-27 19:03:01 +08:00
parent 88e11b885d
commit d7dc35bc88
9 changed files with 117 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package com.ruoyi.web.controller.app;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.constant.ScheduleConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.redis.RedisCache;
@ -1393,7 +1394,7 @@ public class AppSystemController extends BaseController {
}
// 新增关注消息
// 新增关注
int back = userFollowService.insertSysUserFollow(sysUserFollow);
if(back == 0){
@ -1409,6 +1410,7 @@ public class AppSystemController extends BaseController {
sysUserNotification.setType("1");
sysUserNotification.setStatus("0");
// 发送消息
int back1 = userNotificationService.insertSysUserNotification(sysUserNotification);
if(back1 == 0){
return AjaxResult.error("新增关注消息失败");
@ -1422,6 +1424,45 @@ public class AppSystemController extends BaseController {
}
// 消息--查看新增关注数
@GetMapping("/addFollowerCount")
public AjaxResult addFollowerCount()
{
Long userId = getUserId();
Long count = userNotificationService.getAddFollowerCount(userId);
System.out.println("count : "+count);
return success(count);
}
// 消息--获取新增关注列表
@GetMapping("/addFollowerList")
public TableDataInfo addFollowerList()
{
Long userId = getUserId();
List<FollowerListDto> addFollowerList = userFollowService.getAddFollowerList(userId);
//------------------------------------消息已读-------------------------------------------
// // 把消息置为已读
// SysUserNotification sysUserNotification = new SysUserNotification();
//
// sysUserNotification.setUserId(userId);
// // 消息类型为新增关注
// sysUserNotification.setType("1");
// // 改变状态为已读
// sysUserNotification.setStatus("1");
// 更新数据库
userNotificationService.readNotifiaction(userId, "1", "1");
//-------------------------------------消息已读end-----------------------------------------
return getDataTable(addFollowerList);
}
// 测试 warning返回码
@GetMapping("/warning")
public AjaxResult warning()
@ -1490,4 +1531,6 @@ public class AppSystemController extends BaseController {
return AjaxResult.success(userMessageVo);
}
}

View File

@ -85,4 +85,9 @@ public interface SysUserFollowMapper
* 获取关注我的人数
* */
public Long getFollowedCount(Long userId);
/*
* 获取新增关注列表
* */
public List<FollowerListDto> getAddFollowerList(Long userId);
}

View File

@ -2,6 +2,7 @@ package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.SysUserNotification;
import org.apache.ibatis.annotations.Param;
/**
* 用户消息通知Mapper接口
@ -60,4 +61,14 @@ public interface SysUserNotificationMapper
public int deleteSysUserNotificationByIds(Long[] ids);
public List<SysUserNotification> unreadNotifiaction(Long userId);
/*
* 查看新增关注数
* */
public Long getAddFollowerCount(Long userId);
/*
* 读消息
* */
public Long readNotifiaction(@Param("userId") Long userId, @Param("type") String type, @Param("status") String status);
}

View File

@ -84,4 +84,9 @@ public interface ISysUserFollowService
* 获取关注我的人数
* */
public Long getFollowedCount(Long userId);
/*
* 获取新增关注列表
* */
public List<FollowerListDto> getAddFollowerList(Long userId);
}

View File

@ -64,4 +64,14 @@ public interface ISysUserNotificationService
public List<SysUserNotification> unreadNotifiaction(Long userId);
/*
* 查看新增关注数
* */
public Long getAddFollowerCount(Long userId);
/*
* 读消息
* */
public Long readNotifiaction(Long userId, String type, String status);
}

View File

@ -133,4 +133,12 @@ public class SysUserFollowServiceImpl implements ISysUserFollowService
public Long getFollowedCount(Long userId){
return sysUserFollowMapper.getFollowedCount(userId);
}
/*
* 获取新增关注列表
* */
@Override
public List<FollowerListDto> getAddFollowerList(Long userId){
return sysUserFollowMapper.getAddFollowerList(userId);
}
}

View File

@ -153,5 +153,21 @@ public class SysUserNotificationServiceImpl implements ISysUserNotificationServi
}
/*
* 查看新增关注数
* */
@Override
public Long getAddFollowerCount(Long userId){
return sysUserNotificationMapper.getAddFollowerCount(userId);
}
/*
* 读消息
* */
@Override
public Long readNotifiaction(Long userId, String type, String status){
return sysUserNotificationMapper.readNotifiaction(userId, type, status);
}
}

View File

@ -62,6 +62,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getFollowedCount" resultType="java.lang.Long">
select count(*) from sys_user_follow where followed_user_id = #{userId}
</select>
<select id="getAddFollowerList" resultMap="FollowerListDtoResult">
select u.user_id, u.nick_name, u.avatar, u.remark, f.create_time, f.follow_status
from sys_user_follow f
left join sys_user u on f.user_id = u.user_id
left join sys_user_notification n on n.user_id = u.user_id
where f.followed_user_id = #{userId} and n.status = '0'
</select>
<insert id="insertSysUserFollow" parameterType="SysUserFollow" useGeneratedKeys="true" keyProperty="id">
insert into sys_user_follow

View File

@ -41,6 +41,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from sys_user_notification
where user_id = #{userId} and status = '0'
</select>
<select id="getAddFollowerCount" resultType="java.lang.Long">
select count(*)
from sys_user_notification
where user_id = #{userId} and status = '0'
</select>
<insert id="insertSysUserNotification" parameterType="SysUserNotification" useGeneratedKeys="true" keyProperty="id">
insert into sys_user_notification
@ -80,6 +85,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
where id = #{id}
</update>
<update id="readNotifiaction">
update sys_user_notification
set status = #{status}
where user_id = #{userId} and type = #{type}
</update>
<delete id="deleteSysUserNotificationById" parameterType="Long">
delete from sys_user_notification where id = #{id}