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