修bug,顺便修改接口名
This commit is contained in:
@@ -36,7 +36,7 @@ public class PostController {
|
|||||||
* @param postDTO 动态信息
|
* @param postDTO 动态信息
|
||||||
* @return 发布的动态对象
|
* @return 发布的动态对象
|
||||||
*/
|
*/
|
||||||
@PostMapping(consumes = "application/json")
|
@PostMapping( "/addPost")
|
||||||
public Result<Post> createPostJson(@RequestBody PostRequestDTO postDTO) {
|
public Result<Post> createPostJson(@RequestBody PostRequestDTO postDTO) {
|
||||||
// 调用 Service 层处理发布动态业务逻辑
|
// 调用 Service 层处理发布动态业务逻辑
|
||||||
Post result = postService.createPost(postDTO);
|
Post result = postService.createPost(postDTO);
|
||||||
@@ -49,7 +49,7 @@ public class PostController {
|
|||||||
* @param postIds 动态ID
|
* @param postIds 动态ID
|
||||||
* @return 删除结果
|
* @return 删除结果
|
||||||
*/
|
*/
|
||||||
@DeleteMapping
|
@PostMapping("/deletePost")
|
||||||
public Result<String> deleteById(@RequestParam List<Long> postIds){
|
public Result<String> deleteById(@RequestParam List<Long> postIds){
|
||||||
int deletedCount = postService.deletePostById(postIds);
|
int deletedCount = postService.deletePostById(postIds);
|
||||||
return Result.success(ResultCode.SUCCESS_DELETE, deletedCount > 0 ? "成功删除" : "删除失败,该动态不存在", null);
|
return Result.success(ResultCode.SUCCESS_DELETE, deletedCount > 0 ? "成功删除" : "删除失败,该动态不存在", null);
|
||||||
@@ -60,7 +60,7 @@ public class PostController {
|
|||||||
* @param postId 动态ID
|
* @param postId 动态ID
|
||||||
* @return 动态对象
|
* @return 动态对象
|
||||||
*/
|
*/
|
||||||
@GetMapping("/{postId}")
|
@PostMapping("/postById/{postId}")
|
||||||
public Result<PostEditVO> getPostById(@PathVariable Long postId) {
|
public Result<PostEditVO> getPostById(@PathVariable Long postId) {
|
||||||
PostEditVO postEditVO = postService.getPostForEdit(postId);
|
PostEditVO postEditVO = postService.getPostForEdit(postId);
|
||||||
return Result.success(ResultCode.SUCCESS,"查询成功", postEditVO);
|
return Result.success(ResultCode.SUCCESS,"查询成功", postEditVO);
|
||||||
@@ -72,7 +72,7 @@ public class PostController {
|
|||||||
* @param postRequestDTO 动态信息
|
* @param postRequestDTO 动态信息
|
||||||
* @return 更新后的动态对象
|
* @return 更新后的动态对象
|
||||||
*/
|
*/
|
||||||
@PutMapping("/{postId}")
|
@PostMapping("/updatePost/{postId}")
|
||||||
public Result<PostEditVO> updatePost(@PathVariable Long postId, @RequestBody PostRequestDTO postRequestDTO) {
|
public Result<PostEditVO> updatePost(@PathVariable Long postId, @RequestBody PostRequestDTO postRequestDTO) {
|
||||||
PostEditVO result = postService.updatePost(postId, postRequestDTO);
|
PostEditVO result = postService.updatePost(postId, postRequestDTO);
|
||||||
return Result.success(ResultCode.SUCCESS_REVIEW, "动态更新成功", result);
|
return Result.success(ResultCode.SUCCESS_REVIEW, "动态更新成功", result);
|
||||||
|
|||||||
@@ -225,9 +225,8 @@ public class PostServiceImpl implements PostService {
|
|||||||
throw new RuntimeException("无权限修改此动态");
|
throw new RuntimeException("无权限修改此动态");
|
||||||
}
|
}
|
||||||
post.setContent(postRequestDTO.getContent());
|
post.setContent(postRequestDTO.getContent());
|
||||||
if (postRequestDTO.getMediaOssKeys() != null && !postRequestDTO.getMediaOssKeys().isEmpty()) {
|
// 如果请求中的mediaOssKeys不为null(即使是空列表),则更新为新值
|
||||||
post.setMediaOssKeys(postRequestDTO.getMediaOssKeys());
|
post.setMediaOssKeys(postRequestDTO.getMediaOssKeys());
|
||||||
}
|
|
||||||
|
|
||||||
// 1. 文本内容审核
|
// 1. 文本内容审核
|
||||||
Map textResult;
|
Map textResult;
|
||||||
@@ -239,11 +238,11 @@ public class PostServiceImpl implements PostService {
|
|||||||
// 文本审核结果
|
// 文本审核结果
|
||||||
String textSuggestion = (String) textResult.get("suggestion");
|
String textSuggestion = (String) textResult.get("suggestion");
|
||||||
|
|
||||||
// 2. 图片审核(如果有)
|
// 2. 图片审核(如果有媒体文件)
|
||||||
if (postRequestDTO.getMediaOssKeys() != null && !postRequestDTO.getMediaOssKeys().isEmpty()) {
|
if (post.getMediaOssKeys() != null && !post.getMediaOssKeys().isEmpty()) {
|
||||||
Map imageResult;
|
Map imageResult;
|
||||||
try {
|
try {
|
||||||
imageResult = greenImageScan.imageScan(postRequestDTO.getMediaOssKeys());
|
imageResult = greenImageScan.imageScan(post.getMediaOssKeys());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user