修bug(这git怎么这么难用啊😡😡😡)

This commit is contained in:
KilLze
2025-12-25 18:37:20 +08:00
parent 176e133a57
commit df463f2a52
4 changed files with 18 additions and 18 deletions

View File

@@ -52,8 +52,8 @@ public class PostController {
*/
@DeleteMapping
public Result<String> deleteById(@RequestParam List<Long> postIds){
postService.deletePostById(postIds);
return Result.success(ResultCode.SUCCESS_DELETE, "动态删除成功", null);
int deletedCount = postService.deletePostById(postIds);
return Result.success(ResultCode.SUCCESS_DELETE, deletedCount > 0 ? "成功删除" : "删除失败,该动态不存在", null);
}
/**

View File

@@ -20,7 +20,7 @@ public interface PostMapper {
*
* @param postIds 动态ID
*/
void deletePostByIds(@Param("postIds") List<Long> postIds);
int deletePostByIds(@Param("postIds") List<Long> postIds);
/**
* 根据ID查询动态

View File

@@ -24,13 +24,12 @@ public interface PostService {
Post createPost(Long userId, PostRequestDTO postRequestDTO);
/**
* 删除动态
* 批量删除动态
* @param postIds 动态ID
* @return 删除的动态对象
*/
void deletePostById(List<Long> postIds);
int deletePostById(List<Long> postIds);
void deletePostById(Integer postId);
/**
* 查询动态详情(用于编辑)

View File

@@ -12,6 +12,7 @@ import com.bao.dating.util.FileUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
@@ -111,9 +112,6 @@ public class PostServiceImpl implements PostService {
}
String textSuggestion = (String) textResult.get("suggestion");
if ("block".equals(textSuggestion)) {
throw new RuntimeException("动态内容违规,禁止发布");
}
// 2. 图片审核(如果有)
if (postRequestDTO.getMediaOssKeys() != null && !postRequestDTO.getMediaOssKeys().isEmpty()) {
@@ -158,22 +156,25 @@ public class PostServiceImpl implements PostService {
return post;
}
@Override
public void deletePostById(Long postId) {
postMapper.deletePostById(postId);
}
/**
* 删除动态
* 批量删除动态
*
* @param postId 动态ID
* @param postIds 动态ID
* @return 删除的动态对象
*/
@Override
public void deletePostById(Integer postId) {
postMapper.deletePostById(Long.valueOf(postId));
@Transactional(rollbackFor = Exception.class)
public int deletePostById(List<Long> postIds) {
// 批量删除动态
return postMapper.deletePostByIds(postIds);
}
/**
* 查询动态详情(用于编辑)
*
* @param postId 动态ID
* @return
*/
@Override
public PostEditVO getPostForEdit(Long postId) {