修复便签功能

This commit is contained in:
WangHao
2021-01-24 21:26:28 +08:00
parent 116204666b
commit db1fae1c4f
16 changed files with 2148 additions and 55 deletions

View File

@ -0,0 +1,83 @@
package com.ruoyi.system.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import javax.persistence.Column;
import java.util.Date;
/**
* 我的关注对象 sys_user_follow
*
* @author ruoyi
* @date 2021-01-24
*/
public class SysUserFollow
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 用户id */
@Excel(name = "用户id")
private Long userId;
/** 关注的用户id */
@Excel(name = "关注的用户id")
private Long followUserId;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "create_time")
private Date createTime;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setUserId(Long userId)
{
this.userId = userId;
}
public Long getUserId()
{
return userId;
}
public void setFollowUserId(Long followUserId)
{
this.followUserId = followUserId;
}
public Long getFollowUserId()
{
return followUserId;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
@Override
public String toString() {
return "SysUserFollow{" +
"id=" + id +
", userId=" + userId +
", followUserId=" + followUserId +
", createTime=" + createTime +
'}';
}
}

View File

@ -0,0 +1,87 @@
package com.ruoyi.system.mapper;
import java.util.List;
import java.util.Map;
import com.ruoyi.system.domain.SysUserFollow;
/**
* 我的关注Mapper接口
*
* @author ruoyi
* @date 2021-01-24
*/
public interface SysUserFollowMapper
{
/**
* 查询我的关注
*
* @param id 我的关注ID
* @return 我的关注
*/
public SysUserFollow selectSysUserFollowById(Long id);
/**
* 查询我的关注列表
*
* @param sysUserFollow 我的关注
* @return 我的关注集合
*/
public List<SysUserFollow> selectSysUserFollowList(SysUserFollow sysUserFollow);
/**
* 新增我的关注
*
* @param sysUserFollow 我的关注
* @return 结果
*/
public int insertSysUserFollow(SysUserFollow sysUserFollow);
/**
* 修改我的关注
*
* @param sysUserFollow 我的关注
* @return 结果
*/
public int updateSysUserFollow(SysUserFollow sysUserFollow);
/**
* 删除我的关注
*
* @param id 我的关注ID
* @return 结果
*/
public int deleteSysUserFollowById(Long id);
/**
* 批量删除我的关注
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteSysUserFollowByIds(Long[] ids);
/**
* 查看我的关注列表 删
*
* @param userId
* @return
*/
List<String> listFollwUser(Long userId);
/**
* 查看我的关注列表
*
* @param userId
* @return
*/
List<Map<String,Object>> listFollwUserByUid(Long userId);
/**
* 查看我的粉丝列表
*
* @param userId
* @return
*/
List<Map<String, Object>> listFansUserByUid(Long userId);
}

View File

@ -0,0 +1,81 @@
package com.ruoyi.system.service;
import java.util.List;
import java.util.Map;
import com.ruoyi.system.domain.SysUserFollow;
/**
* 我的关注Service接口
*
* @author ruoyi
* @date 2021-01-24
*/
public interface ISysUserFollowService
{
/**
* 查询我的关注
*
* @param id 我的关注ID
* @return 我的关注
*/
public SysUserFollow selectSysUserFollowById(Long id);
/**
* 查询我的关注列表
*
* @param sysUserFollow 我的关注
* @return 我的关注集合
*/
public List<SysUserFollow> selectSysUserFollowList(SysUserFollow sysUserFollow);
/**
* 新增我的关注
*
* @param sysUserFollow 我的关注
* @return 结果
*/
public int insertSysUserFollow(SysUserFollow sysUserFollow);
/**
* 修改我的关注
*
* @param sysUserFollow 我的关注
* @return 结果
*/
public int updateSysUserFollow(SysUserFollow sysUserFollow);
/**
* 批量删除我的关注
*
* @param ids 需要删除的我的关注ID
* @return 结果
*/
public int deleteSysUserFollowByIds(Long[] ids);
/**
* 删除我的关注信息
*
* @param id 我的关注ID
* @return 结果
*/
public int deleteSysUserFollowById(Long id);
/**
* 查看我的关注列表
*
* @param userId
* @return
*/
List<Map<String,Object>> listFollwUser(Long userId);
/**
* 查看我的粉丝列表
*
* @param userId
* @return
*/
List<Map<String,Object>> listFansUser(Long userId);
}

View File

@ -0,0 +1,167 @@
package com.ruoyi.system.service.impl;
import java.util.*;
import com.ruoyi.common.core.redis.RedisKey;
import com.ruoyi.common.core.redis.RedisUtil;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysUserFollowMapper;
import com.ruoyi.system.domain.SysUserFollow;
import com.ruoyi.system.service.ISysUserFollowService;
/**
* 我的关注Service业务层处理
*
* @author ruoyi
* @date 2021-01-24
*/
@Service
public class SysUserFollowServiceImpl implements ISysUserFollowService
{
@Autowired
private SysUserFollowMapper sysUserFollowMapper;
@Autowired
private RedisUtil redisUtil;
/**
* 查询我的关注
*
* @param id 我的关注ID
* @return 我的关注
*/
@Override
public SysUserFollow selectSysUserFollowById(Long id)
{
return sysUserFollowMapper.selectSysUserFollowById(id);
}
/**
* 查询我的关注列表
*
* @param sysUserFollow 我的关注
* @return 我的关注
*/
@Override
public List<SysUserFollow> selectSysUserFollowList(SysUserFollow sysUserFollow)
{
return sysUserFollowMapper.selectSysUserFollowList(sysUserFollow);
}
/**
* 新增我的关注
*
* @param sysUserFollow 我的关注
* @return 结果
*/
@Override
public int insertSysUserFollow(SysUserFollow sysUserFollow)
{
sysUserFollow.setCreateTime(DateUtils.getNowDate());
return sysUserFollowMapper.insertSysUserFollow(sysUserFollow);
}
/**
* 修改我的关注
*
* @param sysUserFollow 我的关注
* @return 结果
*/
@Override
public int updateSysUserFollow(SysUserFollow sysUserFollow)
{
return sysUserFollowMapper.updateSysUserFollow(sysUserFollow);
}
/**
* 批量删除我的关注
*
* @param ids 需要删除的我的关注ID
* @return 结果
*/
@Override
public int deleteSysUserFollowByIds(Long[] ids)
{
return sysUserFollowMapper.deleteSysUserFollowByIds(ids);
}
/**
* 删除我的关注信息
*
* @param id 我的关注ID
* @return 结果
*/
@Override
public int deleteSysUserFollowById(Long id)
{
return sysUserFollowMapper.deleteSysUserFollowById(id);
}
/**
* 查看我的关注列表
*
* @param userId
* @return
*/
@Override
public List<Map<String,Object>> listFollwUser(Long userId) {
return sysUserFollowMapper.listFollwUserByUid(userId);
}
/**
*
* redis 分页计算
* @param
* @return
*/
public static HashMap<String, Long> redisPage(Long pageNum, Long pageSize) {
HashMap<String, Long> map = new HashMap<String, Long>();
if (pageNum == 1L) {
pageNum = 0L;
pageSize = pageSize - 1;
} else {
pageNum = pageNum * pageSize;
pageSize = (pageNum + 1) * pageSize - 1;
}
map.put("pageNum", pageNum);
map.put("pageSize", pageSize);
return map;
}
// /**
// * 查看我的关注列表
// *
// * @param userId
// * @return
// */
// @Override
// public List<String> listFollwUser(Long userId, Long pageNum, Long pageSize) {
// // pageNum=5&pageSize=15 第几页 每页 15条 pageNum 起 &pageSize 结束
// HashMap<String, Long> map = redisPage(pageNum,pageSize);
// List<String> list = redisUtil.lRange(RedisKey.USER_FOLLOW + userId ,map.get("pageNum"), map.get("pageSize"));
// if (null == list || list.isEmpty()) {
// //查库 --> 无序
// list = sysUserFollowMapper.listFollwUser(userId);
// if (null != list && !list.isEmpty()) {
// //list<Long> 转 数组
// redisUtil.lRightPushAll(RedisKey.USER_FOLLOW + userId, list.stream().toArray(String[]::new));
// }
// }
// return list;
// }
// @Override
// public List<String> listFansUser(Long userId) {
// return null;
// }
@Override
public List<Map<String, Object>> listFansUser(Long userId) {
return sysUserFollowMapper.listFansUserByUid(userId);
}
}

View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.SysUserFollowMapper">
<resultMap type="SysUserFollow" id="SysUserFollowResult">
<result property="id" column="id" />
<result property="userId" column="user_id" />
<result property="followUserId" column="follow_user_id" />
<result property="createTime" column="create_time" />
</resultMap>
<sql id="selectSysUserFollowVo">
select id, user_id, follow_user_id, create_time from sys_user_follow
</sql>
<select id="selectSysUserFollowList" parameterType="SysUserFollow" resultMap="SysUserFollowResult">
<include refid="selectSysUserFollowVo"/>
<where>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="followUserId != null "> and follow_user_id = #{followUserId}</if>
</where>
</select>
<select id="selectSysUserFollowById" parameterType="Long" resultMap="SysUserFollowResult">
<include refid="selectSysUserFollowVo"/>
where id = #{id}
</select>
<select id="listFollwUser" parameterType="Long" resultType="String">
select follow_user_id from sys_user_follow where user_id = #{userId}
</select>
<select id="listFollwUserByUid" parameterType="Long" resultType="java.util.Map">
select f.follow_user_id as userId,u.user_name as userName,u.avatar from sys_user_follow as f,sys_user as u where u.user_id = f.follow_user_id and f.user_id = #{userId}
</select>
<select id="listFansUserByUid" parameterType="Long" resultType="java.util.Map">
select f.user_id as userId,u.user_name as userName,u.avatar from sys_user_follow as f,sys_user as u where u.user_id = f.user_id and f.follow_user_id = #{userId}
</select>
<insert id="insertSysUserFollow" parameterType="SysUserFollow" useGeneratedKeys="true" keyProperty="id">
insert into sys_user_follow
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">user_id,</if>
<if test="followUserId != null">follow_user_id,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">#{userId},</if>
<if test="followUserId != null">#{followUserId},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateSysUserFollow" parameterType="SysUserFollow">
update sys_user_follow
<trim prefix="SET" suffixOverrides=",">
<if test="userId != null">user_id = #{userId},</if>
<if test="followUserId != null">follow_user_id = #{followUserId},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteSysUserFollowById" parameterType="Long">
delete from sys_user_follow where id = #{id}
</delete>
<delete id="deleteSysUserFollowByIds" parameterType="String">
delete from sys_user_follow where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>