Merge branch 'feature/community-center' into preview
commit
da620e00e3
|
@ -96,14 +96,17 @@ public class PublishController {
|
|||
*/
|
||||
@ApiOperation(value = "精选/取消精选")
|
||||
@GetMapping("elite")
|
||||
public R<Object> elitePublish(@NotNull(message = "社区id不能为空")
|
||||
public R<Object> elitePublish(@NotNull(message = "租户id不能为空")
|
||||
@ApiParam(value = "租户id")
|
||||
@Valid Long tenantId,
|
||||
@NotNull(message = "社区id不能为空")
|
||||
@ApiParam(value = "社区id")
|
||||
@Valid Long communityId,
|
||||
@NotNull(message = "发布文章id不能为空")
|
||||
@ApiParam(value = "发布文章id")
|
||||
@Valid Long publishId) {
|
||||
publishService.elitePublish(communityId, publishId);
|
||||
return R.ok();
|
||||
|
||||
return publishService.elitePublish(tenantId, communityId, publishId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,7 +44,7 @@ public interface PublishMapper extends BaseMapper<Publish> {
|
|||
@Param("communityId")
|
||||
Long communityId);
|
||||
|
||||
void elitePublish(@Param("communityId") Long communityId, @Param("publishId") Long publishId);
|
||||
void elitePublish(@Param("tenantId") Long tenantId, @Param("communityId") Long communityId, @Param("publishId") Long publishId);
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
List<PublishVo> publishList(Page<Publish> page, @Param("publishPageRes") PublishPageRes publishPageRes);
|
||||
|
@ -62,4 +62,7 @@ public interface PublishMapper extends BaseMapper<Publish> {
|
|||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
void removePublish(@Param("publishRemoveRes") PublishRemoveRes publishRemoveRes);
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
void updateLikeNum(@Param("publish") Publish publish);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public interface PublishService extends IService<Publish> {
|
|||
|
||||
TableDataInfo publishFile(@Valid PublishPageRes publishPageRes);
|
||||
|
||||
void elitePublish(Long communityId, Long publishId);
|
||||
R<Object> elitePublish(Long tenantId, Long communityId, Long publishId);
|
||||
|
||||
TableDataInfo publishList(PublishPageRes publishPageRes);
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ public class PublishCollectServiceImpl extends ServiceImpl<PublishCollectMapper,
|
|||
private final PublishLikeMapper publishLikeMapper;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public TableDataInfo myCollectList(MyPublishCollectPageRes myPublishCollectPageRes) {
|
||||
Page<PublishCollect> page = initPage(myPublishCollectPageRes);
|
||||
|
@ -45,6 +44,23 @@ public class PublishCollectServiceImpl extends ServiceImpl<PublishCollectMapper,
|
|||
for (PublishVo publishVo : publishVoList) {
|
||||
PersonHomeVo personHomeVo = BeanUtil.toBean(publishVo, PersonHomeVo.class);
|
||||
|
||||
PublishLikeRes publishLikeRes = new PublishLikeRes();
|
||||
publishLikeRes.setTenantId(myPublishCollectPageRes.getTenantId());
|
||||
publishLikeRes.setCommunityId(myPublishCollectPageRes.getCommunityId());
|
||||
publishLikeRes.setPublishId(publishVo.getId());
|
||||
PublishLike publishLike = publishLikeMapper.selectPublishLike(publishLikeRes, SecurityUtils.getUserId());
|
||||
if (Objects.nonNull(publishLike)) {
|
||||
String delFlag = publishLike.getDelFlag();
|
||||
if ("0".equals(delFlag)) {
|
||||
publishVo.setIsLike(1);
|
||||
} else {
|
||||
publishVo.setIsLike(0);
|
||||
}
|
||||
} else {
|
||||
publishVo.setIsLike(0);
|
||||
}
|
||||
|
||||
|
||||
CommentDetailRes commentDetailRes = new CommentDetailRes();
|
||||
commentDetailRes.setTenantId(myPublishCollectPageRes.getTenantId());
|
||||
commentDetailRes.setCommunityId(myPublishCollectPageRes.getCommunityId());
|
||||
|
|
|
@ -71,12 +71,12 @@ public class PublishLikeServiceImpl extends ServiceImpl<PublishLikeMapper, Publi
|
|||
baseMapper.insert(publishLike);
|
||||
|
||||
publish.setLikeNum(publish.getLikeNum() + 1);
|
||||
publishMapper.updateById(publish);
|
||||
publishMapper.updateLikeNum(publish);
|
||||
this.addLikeAdvice(publish);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Objects.equals(publishLike.getDelFlag(), "0")) {
|
||||
if ("0".equals(publishLike.getDelFlag())) {
|
||||
publishLike.setDelFlag("2");
|
||||
int likeNum = publish.getLikeNum() - 1;
|
||||
likeNum = Math.max(likeNum, 0);
|
||||
|
@ -88,7 +88,7 @@ public class PublishLikeServiceImpl extends ServiceImpl<PublishLikeMapper, Publi
|
|||
}
|
||||
|
||||
baseMapper.updateDelFlagById(publishLike);
|
||||
publishMapper.updateById(publish);
|
||||
publishMapper.updateLikeNum(publish);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -213,8 +213,20 @@ public class PublishServiceImpl extends ServiceImpl<PublishMapper, Publish> impl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void elitePublish(Long communityId, Long publishId) {
|
||||
baseMapper.elitePublish(communityId, publishId);
|
||||
public R<Object> elitePublish(Long tenantId, Long communityId, Long publishId) {
|
||||
|
||||
CommunityUser communityUser = communityUserMapper.selectCommunityUser(tenantId, communityId, SecurityUtils.getUserId());
|
||||
if (Objects.isNull(communityUser)) {
|
||||
return R.fail(HttpStatus.SHOW_ERROR_MSG, "您不是该社区成员");
|
||||
}
|
||||
if ("1".equals(communityUser.getIsBlack())) {
|
||||
return R.fail(HttpStatus.SHOW_ERROR_MSG, "您已被拉黑");
|
||||
}
|
||||
if (communityUser.getUserType() != 2) {
|
||||
return R.fail(HttpStatus.SHOW_ERROR_MSG, "您不是群主");
|
||||
}
|
||||
baseMapper.elitePublish(tenantId, communityId, publishId);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -331,7 +343,7 @@ public class PublishServiceImpl extends ServiceImpl<PublishMapper, Publish> impl
|
|||
return;
|
||||
}
|
||||
|
||||
if (publishCollect.getDelFlag().equals("0")) {
|
||||
if ("0".equals(publishCollect.getDelFlag())) {
|
||||
publishCollect.setDelFlag("2");
|
||||
} else {
|
||||
publishCollect.setDelFlag("0");
|
||||
|
|
|
@ -17,23 +17,22 @@
|
|||
</update>
|
||||
|
||||
<select id="myCollectList" resultType="com.mcwl.communityCenter.domain.vo.PublishVo">
|
||||
select p.*, 1 as is_collect,u.user_id, u.avatar, u.nick_name as user_name,
|
||||
IF(pl.del_flag = '0', 1, 0) as is_like
|
||||
from cc_publish p left join cc_publish_collect pc
|
||||
select p.*,
|
||||
1 as is_collect,
|
||||
u.user_id,
|
||||
u.avatar,
|
||||
u.nick_name as user_name
|
||||
from cc_publish p
|
||||
left join cc_publish_collect pc
|
||||
on p.id = pc.publish_id
|
||||
and p.tenant_id = pc.tenant_id
|
||||
and p.community_id = pc.community_id
|
||||
left join cc_publish_like pl
|
||||
on p.id = pl.publish_id
|
||||
and p.tenant_id = pl.tenant_id
|
||||
and p.community_id = pl.community_id
|
||||
left join sys_user u on p.user_id = u.user_id
|
||||
<where>
|
||||
and pc.tenant_id = #{myPublishCollectPageRes.tenantId}
|
||||
where pc.tenant_id = #{myPublishCollectPageRes.tenantId}
|
||||
and pc.community_id = #{myPublishCollectPageRes.communityId}
|
||||
and pc.user_id = #{userId}
|
||||
and pc.del_flag = '0'
|
||||
</where>
|
||||
and p.del_flag = '0'
|
||||
</select>
|
||||
<select id="getPublishCollect" resultType="com.mcwl.communityCenter.domain.PublishCollect">
|
||||
select *
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
set is_elite = !is_elite
|
||||
where community_id = #{communityId}
|
||||
and id = #{publishId}
|
||||
and tenant_id = #{tenantId}
|
||||
and del_flag = '0'
|
||||
</update>
|
||||
<update id="removePublish">
|
||||
update cc_publish
|
||||
|
@ -23,6 +25,14 @@
|
|||
and id = #{publishRemoveRes.publishId}
|
||||
and del_flag = '0'
|
||||
</update>
|
||||
<update id="updateLikeNum">
|
||||
update cc_publish
|
||||
set like_num = #{publish.likeNum}
|
||||
where tenant_id = #{publish.tenantId}
|
||||
and community_id = #{publish.communityId}
|
||||
and id = #{publish.id}
|
||||
and del_flag = '0'
|
||||
</update>
|
||||
<select id="selectByTenantIdAndCommunityIdPage" resultType="com.mcwl.communityCenter.domain.Publish">
|
||||
select id,
|
||||
tenant_id,
|
||||
|
@ -108,10 +118,6 @@
|
|||
select p.*, u.nick_name as user_name, u.avatar
|
||||
from cc_publish p
|
||||
left join sys_user u on p.user_id = u.user_id
|
||||
left join cc_publish_like pl on pl.tenant_id = p.tenant_id and pl.community_id = p.community_id and p.id =
|
||||
pl.publish_id
|
||||
left join cc_publish_collect pc on p.id = pc.publish_id and p.tenant_id = pc.tenant_id and
|
||||
p.community_id = pc.community_id
|
||||
<where>
|
||||
and p.tenant_id = #{publishPageRes.tenantId}
|
||||
and p.community_id = #{publishPageRes.communityId}
|
||||
|
|
Loading…
Reference in New Issue