Commit e6b32a19 authored by liwei's avatar liwei

查看他人动态,未关注的只能查看5条,已关注的查看近一个月的,数据字典控制

parent 29dc04b9
......@@ -62,6 +62,18 @@ public class AppOpmArticleController extends CyPaginationController<OpmArticle>
return getGridModelResponse();
}
/**
* 查询某个人的动态列表
*/
@CyOpeLogAnno(title = "system-动态管理-查询某人的动态列表", businessType = CyLogTypeEnum.QUERY)
@Operation(summary="分页查询某人的动态列表集合", description="分页查询某人的动态列表集合")
@GetMapping(value = "/open/opmArticle/queryUserArticleByPagination")
public CyGridModel userArticleListByPagination(OpmArticle opmArticle) {
opmArticleServiceImpl.findUserArticleByPagination(getPaginationUtility(), opmArticle);
return getGridModelResponse();
}
/**
* 动态-点赞
*/
......
......@@ -713,7 +713,6 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
*/
@Override
public CyPersistModel leaveMessage(UserLeaveMessageDTO dto) {
dto.setDelStatus("0");
dto.setUserId(Integer.valueOf(CyUserUtil.getAuthenBusinessId()));
int line = memInfoRepository.leaveMessage(dto);
return new CyPersistModel(line);
......
......@@ -67,5 +67,8 @@ public interface OpmArticleRepository extends CyBaseMapper<OpmArticle> {
//添加动态评论
int addComment(@Param("entity") ArticleCommentDTO dto);
//查询某个人的动态列表
IPage<OpmArticle> queryUserArticlePaged(CyPageInfo cyPageInfo, @Param("entity") OpmArticle opmArticle);
}
......@@ -211,6 +211,13 @@ public class OpmArticle extends CyIdIncreEntity<OpmArticle> {
/**
* 关注的数组
*/
@TableField(exist = false)
private List<Integer> followList;
/**
* 是否关注 isFollow 1:关注 0:未关注
*/
@TableField(exist = false)
private String isFollowed;
}
......@@ -101,4 +101,10 @@ public interface OpmArticleService {
*/
CyPersistModel addComment(ArticleCommentDTO dto);
/**
* 分页查询某个人的动态列表
* @param opmArticle
* @return
*/
IPage<OpmArticle> findUserArticleByPagination(CyPageInfo<OpmArticle> paginationUtility, OpmArticle opmArticle);
}
......@@ -184,10 +184,7 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm
result = baseMapper.queryOpmArticlePaged(paginationUtility,opmArticle);
}
} else {
if (StringUtils.isNotEmpty(opmArticle.getUserId())){
//设置查询用户 查询某个人的动态列表
opmArticle.setUserId(opmArticle.getUserId());
}
//话题 最近
if (StringUtils.isNotEmpty(CyUserUtil.getAuthenBusinessId())){
//设置当前登录人id 用来查询该用户对文章是否已点赞
opmArticle.setLoginUserId(CyUserUtil.getAuthenBusinessId());
......@@ -195,7 +192,78 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm
result = baseMapper.queryOpmArticlePaged(paginationUtility,opmArticle);
}
return result;
}
/**
* 分页查询某个人的动态列表
* @param paginationUtility
* @param opmArticle
* @return
*/
@Override
public IPage<OpmArticle> findUserArticleByPagination(CyPageInfo<OpmArticle> paginationUtility, OpmArticle opmArticle) {
//校验 未关注的只能查5条 已关注的只能查近一个月的
String isFollowed = opmArticle.getIsFollowed();
if (StringUtils.isNotEmpty(isFollowed) && isFollowed.equals("0")){
//1.未关注
List<DictData> articleConfig = dictionaryService.selectByTypes("article_config");
DictData dictData = articleConfig.stream().filter(item -> item.getDictLabel().equals("no_follow_article_limit")).findFirst().orElse(null);
Integer noFollowArticleLimit = Integer.valueOf(dictData.getDictValue());
String loginUserId = CyUserUtil.getAuthenBusinessId();
if (StringUtils.isNotEmpty(opmArticle.getUserId())){
//设置查询用户 查询某个人的动态列表
opmArticle.setUserId(opmArticle.getUserId());
}
if (StringUtils.isNotEmpty(loginUserId)){
//设置当前登录人id 用来查询该用户对文章是否已点赞
opmArticle.setLoginUserId(loginUserId);
}
//设置分页参数 防止前端下滑再次调分页 前端根据total 判断是否还有数据
paginationUtility.setPages(1);
paginationUtility.setSize(noFollowArticleLimit);
IPage<OpmArticle> opmArticleIPage = baseMapper.queryUserArticlePaged(paginationUtility, opmArticle);
opmArticleIPage.setTotal(noFollowArticleLimit);
return opmArticleIPage;
} else if(StringUtils.isNotEmpty(isFollowed) && isFollowed.equals("1")){
//2.已关注
List<DictData> articleConfig = dictionaryService.selectByTypes("article_config");
DictData dictData = articleConfig.stream().filter(item -> item.getDictLabel().equals("follow_article_limit")).findFirst().orElse(null);
Integer followArticleLimit = Integer.valueOf(dictData.getDictValue());
//获取当前日期时间
LocalDateTime currentDate = LocalDateTime.now();
// 获取30天前的日期
LocalDateTime dateBeforeDays = currentDate.minusDays(followArticleLimit);
// 如果需要特定格式的日期字符串,可以使用DateTimeFormatter
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String endTime = currentDate.format(formatter);
String beginTime = dateBeforeDays.format(formatter);
opmArticle.setBeginTime(beginTime);
opmArticle.setEndTime(endTime);
String loginUserId = CyUserUtil.getAuthenBusinessId();
if (StringUtils.isNotEmpty(opmArticle.getUserId())){
//设置查询用户 查询某个人的动态列表
opmArticle.setUserId(opmArticle.getUserId());
}
if (StringUtils.isNotEmpty(loginUserId)){
//设置当前登录人id 用来查询该用户对文章是否已点赞
opmArticle.setLoginUserId(loginUserId);
}
return baseMapper.queryUserArticlePaged(paginationUtility,opmArticle);
}
//3.当前登录人的动态
//如果登录人id和userId相同,证明查看的是自己的动态列表
String loginUserId = CyUserUtil.getAuthenBusinessId();
if (StringUtils.isNotEmpty(loginUserId)){
//查询当前登录人的动态
opmArticle.setUserId(loginUserId);
}
if (StringUtils.isNotEmpty(loginUserId)){
//设置当前登录人id 用来查询该用户对文章是否已点赞
opmArticle.setLoginUserId(loginUserId);
}
return baseMapper.queryUserArticlePaged(paginationUtility,opmArticle);
}
/**
......
......@@ -612,14 +612,13 @@
and user_id = #{entity.targetId}
</insert>
<insert id="leaveMessage">
insert into mem_user_leave_message (target_id,create_by,create_date,update_by,update_date,content,del_status)
values(#{targetId},#{userId},NOW(),#{userId},NOW(),#{content},#{delStatus})
insert into mem_user_leave_message (target_id,create_by,create_date,update_by,update_date,content)
values(#{targetId},#{userId},NOW(),#{userId},NOW(),#{content})
</insert>
<select id="leaveMessageByPagination" resultType="org.rcisoft.business.memInfo.entity.MemInfo">
SELECT
oulm.business_id,
oulm.content as leaveMessageContent,
oulm.del_status,
oulm.create_date,
oulm.create_by as userId,
oulm.target_id,
......@@ -640,7 +639,6 @@
select
oulm.business_id,
oulm.content as leaveMessageContent,
oulm.del_status,
oulm.create_date,
oulm.create_by as userId,
oulm.target_id,
......
......@@ -195,6 +195,67 @@
ORDER BY
opa.create_date DESC
</select>
<select id="queryUserArticlePaged" resultType="org.rcisoft.business.opmArticle.entity.OpmArticle">
SELECT
opa.business_id,
opa.flag,
opa.del_flag,
opa.comment_count,
opa.like_count,
opa.exam_status,
opa.is_article,
opa.create_date,
opa.content,
opa.create_by AS userId,
opa.picture_id,
opt.topic_name AS topic,
mi.mem_code,
mi.mem_nick_name,
mi.mem_sex,
mi.mem_birthday,
mi.mem_residence_province,
mi.mem_residence_city,
mi.mem_max_education,
mi.mem_career,
mi.business_id AS memberId,
mi.avatar AS avatarId,
CASE
WHEN oal.business_id IS NOT NULL THEN 1 ELSE 0
END AS isLike,
oi.url AS memAvatar,
GROUP_CONCAT(DISTINCT pic_urls.url ORDER BY pic_urls.url SEPARATOR ',') AS url
FROM
opm_article opa
LEFT JOIN opm_topic opt ON opa.topic_id = opt.business_id
LEFT JOIN mem_info mi ON opa.create_by = mi.user_id
LEFT JOIN oss_info oi ON mi.avatar = oi.business_id
LEFT JOIN opm_article_like oal on oal.article_id = opa.business_id and oal.user_id = #{entity.loginUserId}
LEFT JOIN (
SELECT
opm_article.business_id,
CAST(JSON_UNQUOTE(JSON_EXTRACT(picture_id, CONCAT('$.id[', jt_ids.idx - 1, ']'))) AS UNSIGNED) AS picture_id
FROM
opm_article,
JSON_TABLE(JSON_EXTRACT(opm_article.picture_id, '$.id'), '$[*]' COLUMNS (idx FOR ORDINALITY)) AS jt_ids
WHERE
opm_article.del_flag = '0'
) AS pic_ids ON opa.business_id = pic_ids.business_id
LEFT JOIN oss_info pic_urls ON pic_ids.picture_id = pic_urls.business_id
WHERE 1=1
and opa.del_flag = '0'
and opa.flag = '1'
and opa.create_by = #{entity.userId}
<if test="entity.beginTime !=null and entity.beginTime != '' ">
and opa.create_date &gt;= #{entity.beginTime}
</if>
<if test="entity.endTime !=null and entity.endTime != '' ">
and opa.create_date &lt;= #{entity.endTime}
</if>
GROUP BY
opa.business_id
ORDER BY
opa.create_date DESC
</select>
<select id="selectArticleDetail" resultType="org.rcisoft.business.opmArticle.entity.OpmArticle">
SELECT
opa.*,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment