feat(community): 增加社区发布数量统计并优化会员查询功能
parent
14f6021416
commit
71b034673e
|
@ -51,8 +51,8 @@ public class Community extends BaseEntity {
|
|||
/**
|
||||
* 社区标签id
|
||||
*/
|
||||
@ApiModelProperty(value = "社区标签id")
|
||||
private Long communityTagId;
|
||||
@ApiModelProperty(value = "社区标签")
|
||||
private Integer communityTag;
|
||||
|
||||
/**
|
||||
* 社区类型
|
||||
|
|
|
@ -60,6 +60,11 @@ public class Publish extends BaseEntity {
|
|||
*/
|
||||
private Date publishTime;
|
||||
|
||||
/**
|
||||
* 精选
|
||||
*/
|
||||
private Integer isElite;
|
||||
|
||||
/**
|
||||
* 点赞数
|
||||
*/
|
||||
|
|
|
@ -17,7 +17,7 @@ public class CommunityListPageRes extends PageDomain {
|
|||
/**
|
||||
* 社区标签id
|
||||
*/
|
||||
@ApiModelProperty(value = "社区标签id")
|
||||
private Long communityTagId;
|
||||
@ApiModelProperty(value = "社区标签")
|
||||
private Long communityTag;
|
||||
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -25,4 +25,11 @@ public interface CommunityMapper extends BaseMapper<Community> {
|
|||
*/
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
Map<Long, Integer> selectCommunityJoinNum();
|
||||
|
||||
/**
|
||||
* 查询所有社区发布数量,以map形式返回,key为社区id,value为发布数量
|
||||
* @return map
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
Map<Long, Integer> selectCommunityPublishNum();
|
||||
}
|
||||
|
|
|
@ -45,6 +45,9 @@ public class CommunityServiceImpl extends ServiceImpl<CommunityMapper, Community
|
|||
// 查询社区加入人数,以map形式返回,key为社区id,value为加入人数
|
||||
Map<Long, Integer> communityJoinNumMap = baseMapper.selectCommunityJoinNum();
|
||||
|
||||
// 查询社区发布数,以map形式返回,key为社区id,value为发布数
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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>
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据订阅周期和开始时间 计算结束时间
|
||||
|
|
Loading…
Reference in New Issue