feat(community): 增加社区发布数量统计并优化会员查询功能

master
yang 2025-03-28 13:43:42 +08:00
parent 14f6021416
commit 71b034673e
10 changed files with 82 additions and 8 deletions

View File

@ -51,8 +51,8 @@ public class Community extends BaseEntity {
/**
* id
*/
@ApiModelProperty(value = "社区标签id")
private Long communityTagId;
@ApiModelProperty(value = "社区标签")
private Integer communityTag;
/**
*

View File

@ -60,6 +60,11 @@ public class Publish extends BaseEntity {
*/
private Date publishTime;
/**
*
*/
private Integer isElite;
/**
*
*/

View File

@ -17,7 +17,7 @@ public class CommunityListPageRes extends PageDomain {
/**
* id
*/
@ApiModelProperty(value = "社区标签id")
private Long communityTagId;
@ApiModelProperty(value = "社区标签")
private Long communityTag;
}

View File

@ -0,0 +1,17 @@
package com.mcwl.communityCenter.domain.vo;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
*
*/
@Data
@ApiModel(value = "社区详情返回数据")
public class CommunityDetailVo {
}

View File

@ -12,7 +12,6 @@ import javax.validation.constraints.NotNull;
*
*/
@Data
@TableName("cc_community")
@ApiModel(value = "社区返回数据")
public class CommunityVo {
@ -46,6 +45,12 @@ public class CommunityVo {
@ApiModelProperty(value = "价格")
private Double price;
/**
* id
*/
@ApiModelProperty(value = "用户id")
private Long userId;
/**
*
*/
@ -64,5 +69,11 @@ public class CommunityVo {
@ApiModelProperty(value = "加入人数")
private Integer joinNum;
/**
*
*/
@ApiModelProperty(value = "发布数量")
private Integer publishNum;
}

View File

@ -25,4 +25,11 @@ public interface CommunityMapper extends BaseMapper<Community> {
*/
@InterceptorIgnore(tenantLine = "true")
Map<Long, Integer> selectCommunityJoinNum();
/**
* mapkeyidvalue
* @return map
*/
@InterceptorIgnore(tenantLine = "true")
Map<Long, Integer> selectCommunityPublishNum();
}

View File

@ -45,6 +45,9 @@ public class CommunityServiceImpl extends ServiceImpl<CommunityMapper, Community
// 查询社区加入人数以map形式返回key为社区idvalue为加入人数
Map<Long, Integer> communityJoinNumMap = baseMapper.selectCommunityJoinNum();
// 查询社区发布数以map形式返回key为社区idvalue为发布数
Map<Long, Integer> communityPublishNumMap = baseMapper.selectCommunityPublishNum();
Page<Community> page = new Page<>(communityListPageRes.getPageNum(), communityListPageRes.getPageSize());
@ -57,7 +60,7 @@ public class CommunityServiceImpl extends ServiceImpl<CommunityMapper, Community
page.addOrder(orderItem);
baseMapper.selectPage(page, new LambdaQueryWrapper<Community>()
.eq(communityListPageRes.getCommunityTagId() != null, Community::getCommunityTagId, communityListPageRes.getCommunityTagId()));
.eq(communityListPageRes.getCommunityTag() != null, Community::getCommunityTag, communityListPageRes.getCommunityTag()));
List<Community> communityList = page.getRecords();
List<CommunityVo> communityVoList = new ArrayList<>();
@ -72,8 +75,10 @@ public class CommunityServiceImpl extends ServiceImpl<CommunityMapper, Community
.atZone(ZoneId.systemDefault())
.toLocalDate();
long daysBetween = ChronoUnit.DAYS.between(createLocalDate, currentLocalDate);
communityVo.setUserId(community.getTenantId());
communityVo.setCreateDay(daysBetween);
communityVo.setJoinNum(communityJoinNumMap.getOrDefault(community.getId(), 0));
communityVo.setPublishNum(communityPublishNumMap.getOrDefault(community.getId(), 0));
communityVoList.add(communityVo);
}

View File

@ -25,4 +25,14 @@
and i.del_flag = '0'
group by i.community_id
</select>
<select id="selectCommunityPublishNum" resultType="java.util.Map">
select c.id, COALESCE(count(*), 0)
from cc_community c
join cc_publish p on c.id = p.community_id
join cc_question q on c.id = q.community_id
where c.del_flag = '0'
and p.del_flag = '0'
and q.del_flag = '0'
group by p.community_id
</select>
</mapper>

View File

@ -7,6 +7,7 @@ import com.mcwl.memberCenter.domain.Member;
import com.mcwl.memberCenter.domain.vo.MemberVo;
import com.mcwl.memberCenter.domain.vo.RechargeRecordVO;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;

View File

@ -259,14 +259,14 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
memberConsume.setConsumeTime(new Date());
memberConsumeService.save(memberConsume);
}
/**
*
* @return id
*/
@Override
public List<MemberVo> getValidMemberById(Long userId) {
List<Member> memberList = this.getUseUserMember(userId);
List<Member> memberList = this.getValidMember(userId);
List<MemberVo> memberVoList = new ArrayList<>();
for (Member member : memberList) {
MemberVo memberVo = BeanUtil.copyProperties(member, MemberVo.class);
@ -294,6 +294,24 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
return baseMapper.selectList(qw);
}
/**
*
* @param userId id
* @return
*/
private List<Member> getValidMember(Long userId) {
// startDate 小于等于当前时间、endDate 大于等于当前时间
// subscriptionStatus 不为 "过期" 或 "待支付"
// status 为 0 的
LambdaQueryWrapper<Member> qw = new LambdaQueryWrapper<>();
qw.ge(Member::getEndDate, new Date())
.ne(Member::getSubscriptionStatus, MemberEnum.MEMBER_CENTER_EXPIRED)
.ne(Member::getSubscriptionStatus, MemberEnum.MEMBER_CENTER_PENDING)
.eq(Member::getStatus, "0")
.eq(userId != null, Member::getUserId, userId);
return baseMapper.selectList(qw);
}
/**
*