feat(communityCenter): 调整删除发布
parent
e2dd7d81bd
commit
c951baedd5
|
@ -87,10 +87,8 @@ public class PublishController {
|
|||
@ApiOperation(value = "删除")
|
||||
@PostMapping("remove")
|
||||
public R<Object> deletePublish(@RequestBody @Valid PublishRemoveRes publishRemoveRes) {
|
||||
Long communityId = publishRemoveRes.getCommunityId();
|
||||
Long publishId = publishRemoveRes.getPublishId();
|
||||
publishService.remove(new LambdaQueryWrapper<Publish>().eq(Publish::getId, publishId).eq(Publish::getCommunityId, communityId));
|
||||
return R.ok();
|
||||
|
||||
return publishService.removePublish(publishRemoveRes);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,11 +7,17 @@ import lombok.Data;
|
|||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 点赞/取消点赞请求参数
|
||||
* 删除发布请求参数
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "点赞/取消点赞请求参数")
|
||||
@ApiModel(value = "删除发布请求参数")
|
||||
public class PublishRemoveRes {
|
||||
/**
|
||||
* 租户id
|
||||
*/
|
||||
@ApiModelProperty(value = "租户id", required = true)
|
||||
@NotNull(message = "租户id不能为空")
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 社区id
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.mcwl.communityCenter.domain.Publish;
|
||||
import com.mcwl.communityCenter.domain.dto.MyPublishPageRes;
|
||||
import com.mcwl.communityCenter.domain.dto.PublishPageRes;
|
||||
import com.mcwl.communityCenter.domain.dto.PublishRemoveRes;
|
||||
import com.mcwl.communityCenter.domain.vo.PublishVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
@ -58,4 +59,7 @@ public interface PublishMapper extends BaseMapper<Publish> {
|
|||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
Publish getLastPublish(@Param("tenantId") Long tenantId, @Param("communityId") Long communityId);
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
void removePublish(@Param("publishRemoveRes") PublishRemoveRes publishRemoveRes);
|
||||
}
|
||||
|
|
|
@ -44,4 +44,6 @@ public interface PublishService extends IService<Publish> {
|
|||
void reportPublish(@Valid PublishReportRes publishReportRes);
|
||||
|
||||
Publish getLastPublish(Long tenantId, Long communityId);
|
||||
|
||||
R<Object> removePublish(@Valid PublishRemoveRes publishRemoveRes);
|
||||
}
|
||||
|
|
|
@ -402,6 +402,31 @@ public class PublishServiceImpl extends ServiceImpl<PublishMapper, Publish> impl
|
|||
return baseMapper.getLastPublish(tenantId, communityId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<Object> removePublish(PublishRemoveRes publishRemoveRes) {
|
||||
Long tenantId = publishRemoveRes.getTenantId();
|
||||
Long communityId = publishRemoveRes.getCommunityId();
|
||||
Long publishId = publishRemoveRes.getPublishId();
|
||||
|
||||
Long currentUserId = SecurityUtils.getUserId();
|
||||
CommunityUser communityUser = communityUserMapper.selectCommunityUser(tenantId, communityId, currentUserId);
|
||||
if (Objects.isNull(communityUser)) {
|
||||
return R.fail(HttpStatus.SHOW_ERROR_MSG, "您不是该社区成员");
|
||||
}
|
||||
|
||||
Publish publish = publishMapper.selectByIdAndTenantIdAndCommunityId(publishId, tenantId, communityId);
|
||||
if (Objects.isNull(publish)) {
|
||||
return R.fail(HttpStatus.SHOW_ERROR_MSG, "该内容不存在");
|
||||
}
|
||||
|
||||
if (publish.getUserId().equals(currentUserId) || publish.getUserId().equals(tenantId)) {
|
||||
publishMapper.removePublish(publishRemoveRes);
|
||||
} else {
|
||||
return R.fail(HttpStatus.SHOW_ERROR_MSG, "您没有权限删除该内容");
|
||||
}
|
||||
return R.ok(HttpStatus.SHOW_ERROR_MSG, "删除成功");
|
||||
}
|
||||
|
||||
private Page<Publish> initPage(PageDomain pageDomain) {
|
||||
return new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
|
||||
}
|
||||
|
|
|
@ -15,6 +15,14 @@
|
|||
where community_id = #{communityId}
|
||||
and id = #{publishId}
|
||||
</update>
|
||||
<update id="removePublish">
|
||||
update cc_publish
|
||||
set del_flag = '2'
|
||||
where tenant_id = #{publishRemoveRes.tenantId}
|
||||
and community_id = #{publishRemoveRes.communityId}
|
||||
and id = #{publishRemoveRes.publishId}
|
||||
and del_flag = '0'
|
||||
</update>
|
||||
<select id="selectByTenantIdAndCommunityIdPage" resultType="com.mcwl.communityCenter.domain.Publish">
|
||||
select id,
|
||||
tenant_id,
|
||||
|
|
Loading…
Reference in New Issue