新增用户端帖子管理
This commit is contained in:
parent
b21dfe710b
commit
591e9680ff
@ -55,5 +55,7 @@ public interface PostService extends IService<PostEntity> {
|
||||
Integer addPost(AddPostForm request, AppUserEntity user);
|
||||
|
||||
AppPageUtils queryPageList(PostListForm request, AppUserEntity user);
|
||||
|
||||
void deleteMyPost(DeletePostForm request, AppUserEntity user);
|
||||
}
|
||||
|
||||
|
@ -268,6 +268,19 @@ public class PostServiceImpl extends ServiceImpl<PostDao, PostEntity> implements
|
||||
return appPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMyPost(DeletePostForm request, AppUserEntity user) {
|
||||
PostEntity post = this.getById(request.getId());
|
||||
if(post==null){
|
||||
throw new LinfengException("帖子不存在");
|
||||
}
|
||||
if(!post.getUid().equals(user.getUid())){
|
||||
throw new LinfengException("不能删除别人帖子");
|
||||
}
|
||||
this.removeById(request.getId());
|
||||
//关联业务处理todo
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装帖子分页
|
||||
* 在一个循环里 尽量减少数据库查询操作 这种方式并不太好 应该全部查询出来后再set值
|
||||
|
@ -20,10 +20,7 @@ import io.linfeng.modules.admin.entity.AppUserEntity;
|
||||
import io.linfeng.modules.admin.service.PostService;
|
||||
import io.linfeng.modules.app.annotation.Login;
|
||||
import io.linfeng.modules.app.annotation.LoginUser;
|
||||
import io.linfeng.modules.app.param.AddCollectionForm;
|
||||
import io.linfeng.modules.app.param.AddCommentForm;
|
||||
import io.linfeng.modules.app.param.AddPostForm;
|
||||
import io.linfeng.modules.app.param.PostListForm;
|
||||
import io.linfeng.modules.app.param.*;
|
||||
import io.linfeng.modules.app.service.PostCollectionService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@ -104,6 +101,16 @@ public class AppPostController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@Login
|
||||
@PostMapping("/deleteMyPost")
|
||||
@ApiOperation("删除自己帖子")
|
||||
public R deleteMyPost(@RequestBody DeletePostForm request,
|
||||
@ApiIgnore @LoginUser AppUserEntity user){
|
||||
postService.deleteMyPost(request,user);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Login
|
||||
@GetMapping("/myPost")
|
||||
@ApiOperation("我的帖子")
|
||||
|
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* -----------------------------------
|
||||
* 林风社交论坛开源版本请务必保留此注释头信息
|
||||
* 开源地址: https://gitee.com/virus010101/linfeng-community
|
||||
* 演示站点:https://www.linfeng.tech
|
||||
* 可正常分享和学习源码,不得用于非法牟利!
|
||||
* 商业版购买联系技术客服 QQ: 3582996245
|
||||
* Copyright (c) 2021-2023 linfeng all rights reserved.
|
||||
* 版权所有,侵权必究!
|
||||
* -----------------------------------
|
||||
*/
|
||||
package io.linfeng.modules.app.param;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "帖子删除请求体")
|
||||
public class DeletePostForm {
|
||||
|
||||
@ApiModelProperty(value = "帖子id")
|
||||
private Integer id;
|
||||
|
||||
|
||||
}
|
@ -16,6 +16,7 @@ import io.linfeng.common.utils.PageUtils;
|
||||
import io.linfeng.modules.admin.entity.AppUserEntity;
|
||||
import io.linfeng.modules.app.entity.PostCollectionEntity;
|
||||
import io.linfeng.modules.app.param.AddCollectionForm;
|
||||
import io.linfeng.modules.app.param.DeletePostForm;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -38,6 +39,5 @@ public interface PostCollectionService extends IService<PostCollectionEntity> {
|
||||
void cancelCollection(AddCollectionForm request, AppUserEntity user);
|
||||
|
||||
List<Integer> getPostListByUid(Integer uid);
|
||||
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ package io.linfeng.modules.app.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import io.linfeng.modules.admin.entity.AppUserEntity;
|
||||
import io.linfeng.modules.app.param.AddCollectionForm;
|
||||
import io.linfeng.modules.app.param.DeletePostForm;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -8,10 +8,12 @@
|
||||
<text class="user-name">{{ postDetail.userInfo.username }}</text>
|
||||
<view class="userIntro">{{ postDetail.userInfo.intro }}</view>
|
||||
</view>
|
||||
<u-button v-show="postDetail.isFollow" size="mini" style="float:right;font-size: 14px;"
|
||||
<u-button v-show="!isAuthor&&postDetail.isFollow" size="mini" style="float:right;font-size: 14px;"
|
||||
@click="cancelFollow">已关注</u-button>
|
||||
<u-button v-show="!postDetail.isFollow" size="mini" style="float:right;font-size: 14px;"
|
||||
<u-button v-show="!isAuthor&&!postDetail.isFollow" size="mini" style="float:right;font-size: 14px;"
|
||||
@click="follow">关注</u-button>
|
||||
<u-button v-show="isAuthor" size="mini" type="error" style="float:right;font-size: 14px;"
|
||||
@click="deletePost">删除</u-button>
|
||||
</view>
|
||||
<view class="icon">
|
||||
<text>{{ postDetail.createTime }}</text>
|
||||
@ -187,6 +189,7 @@
|
||||
},
|
||||
page: 1,
|
||||
loadStatus: 'loadmore',
|
||||
isAuthor: false, //是否为作者本人
|
||||
|
||||
};
|
||||
},
|
||||
@ -235,6 +238,19 @@
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
deletePost(){
|
||||
this.$H
|
||||
.post('post/deleteMyPost', {
|
||||
id: this.postId
|
||||
})
|
||||
.then(res => {
|
||||
if(res.code==0){
|
||||
uni.switchTab({
|
||||
url:"/pages/index/index"
|
||||
})
|
||||
}
|
||||
});
|
||||
},
|
||||
messageRead(mid) {
|
||||
this.$H
|
||||
.post('message/readMessage', {
|
||||
@ -373,6 +389,13 @@
|
||||
}, 1500);
|
||||
}
|
||||
this.postDetail = res.result;
|
||||
if (uni.getStorageSync('hasLogin')) {
|
||||
this.$H.get('user/userInfo').then(res => {
|
||||
if (res.result.uid == this.postDetail.uid) {
|
||||
this.isAuthor = true
|
||||
}
|
||||
});
|
||||
}
|
||||
uni.hideLoading();
|
||||
});
|
||||
},
|
||||
@ -750,4 +773,4 @@
|
||||
.post-text {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
</style>
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user