Compare commits
2 Commits
0d1a21d2ef
...
bdca737c99
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bdca737c99 | ||
|
|
84e8fe4ff6 |
@@ -3,6 +3,7 @@ package com.bao.dating.common;
|
||||
public enum ResultCode {
|
||||
SUCCESS(200, "成功"),
|
||||
SUCCESS_REVIEW(201, "请求已成功处理"),
|
||||
SUCCESS_DELETE(204, "删除成功"),
|
||||
PARAM_ERROR(400, "参数错误"),
|
||||
UNAUTHORIZED(401, "未登录或 Token 失效"),
|
||||
FORBIDDEN(403, "无权限"),
|
||||
|
||||
@@ -41,4 +41,16 @@ public class PostController {
|
||||
Post result = postService.createPost(postRequestDTO);
|
||||
return Result.success(ResultCode.SUCCESS_REVIEW, "动态发布成功,等待审核。", result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除动态
|
||||
*
|
||||
* @param postId 动态ID
|
||||
* @return 删除结果
|
||||
*/
|
||||
@DeleteMapping("/{postId}")
|
||||
public Result<String> deleteById(@PathVariable Integer postId){
|
||||
postService.deletePostById(postId);
|
||||
return Result.success(ResultCode.SUCCESS_DELETE, "动态删除成功", null);
|
||||
}
|
||||
}
|
||||
@@ -5,5 +5,16 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface PostMapper {
|
||||
/**
|
||||
* 插入动态
|
||||
* @param post
|
||||
* @return
|
||||
*/
|
||||
int insert(Post post);
|
||||
|
||||
/**
|
||||
* 根据动态ID删除动态
|
||||
* @param postId
|
||||
*/
|
||||
void deletePostById(Integer postId);
|
||||
}
|
||||
|
||||
@@ -20,4 +20,11 @@ public interface PostService {
|
||||
* @return 创建的动态对象
|
||||
*/
|
||||
Post createPost(PostRequestDTO postRequestDTO);
|
||||
|
||||
/**
|
||||
* 删除动态
|
||||
* @param postId 动态ID
|
||||
* @return 删除的动态对象
|
||||
*/
|
||||
void deletePostById(Integer postId);
|
||||
}
|
||||
@@ -92,4 +92,15 @@ public class PostServiceImpl implements PostService {
|
||||
postMapper.insert(post);
|
||||
return post;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除动态
|
||||
*
|
||||
* @param postId 动态ID
|
||||
* @return 删除的动态对象
|
||||
*/
|
||||
@Override
|
||||
public void deletePostById(Integer postId) {
|
||||
postMapper.deletePostById(postId);
|
||||
}
|
||||
}
|
||||
@@ -27,4 +27,8 @@
|
||||
#{isPublic}, 0, 0, #{createdAt}, #{updatedAt})
|
||||
</insert>
|
||||
|
||||
<delete id="deletePostById" parameterType="int">
|
||||
DELETE FROM post WHERE post_id = #{postId}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user