xiongzhu 5 years ago
parent
commit
10e24e0749

+ 4 - 0
src/main/java/com/izouma/jmrh/repo/CommentRepo.java

@@ -3,14 +3,18 @@ package com.izouma.jmrh.repo;
 import com.izouma.jmrh.domain.Comment;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 
 import javax.annotation.Nonnull;
+import javax.transaction.Transactional;
 import java.util.List;
 
 public interface CommentRepo extends JpaRepository<Comment, Long>, JpaSpecificationExecutor<Comment> {
 
     @Query("update Comment c set c.del = true where c.id = ?1")
+    @Transactional
+    @Modifying
     void deleteById(@Nonnull Long id);
 
     List<Comment> findByPostIdIn(Iterable<Long> postIds);

+ 5 - 1
src/main/java/com/izouma/jmrh/repo/PostRepo.java

@@ -8,17 +8,21 @@ import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 
 import javax.annotation.Nonnull;
+import javax.transaction.Transactional;
 import java.util.List;
 
 public interface PostRepo extends JpaRepository<Post, Long>, JpaSpecificationExecutor<Post> {
 
     @Query("update Post p set p.del = true where p.id = ?1")
+    @Transactional
+    @Modifying
     void deleteById(@Nonnull Long id);
 
-    @Query("select p, u.nickname, u.avatar from Post p left join User u on p.userId = u.id")
+    @Query("select p, u.nickname, u.avatar from Post p left join User u on p.userId = u.id where p.del = false")
     Page<PostDTO> allDTO(PostType type, Pageable pageable);
 
     @Query("select new com.izouma.jmrh.dto.MyPostAndComment(p, c, c.createdAt) from Comment c " +

+ 1 - 0
src/main/java/com/izouma/jmrh/service/PostService.java

@@ -72,6 +72,7 @@ public class PostService {
                 || SecurityUtils.hasRole(Authority.NAMES.ROLE_INTERACT)
                 || post.getUserId().equals(SecurityUtils.getAuthenticatedUser().getId())) {
             postRepo.deleteById(id);
+            return;
         }
         throw new BusinessException("无权限");
     }

+ 1 - 4
src/main/vue/src/views/PostList.vue

@@ -3,7 +3,6 @@
         <div class="filters-container">
             <el-input placeholder="输入关键字" v-model="search" clearable class="filter-item"></el-input>
             <el-button @click="getData" type="primary" icon="el-icon-search" class="filter-item">搜索 </el-button>
-            <el-button @click="addRow" type="primary" icon="el-icon-plus" class="filter-item">添加 </el-button>
             <el-button
                 @click="download"
                 type="primary"
@@ -118,9 +117,7 @@ export default {
             return '';
         },
         beforeGetData() {
-            if (this.search || this.query) {
-                return { search: this.search, query: this.query };
-            }
+            return { search: this.search, query: { del: false } };
         },
         toggleMultipleMode(multipleMode) {
             this.multipleMode = multipleMode;

+ 0 - 1
src/main/vue/src/views/ResourceSupplyAndDemandList.vue

@@ -7,7 +7,6 @@
                 </el-option>
             </el-select>
             <el-button @click="getData" type="primary" icon="el-icon-search" class="filter-item">搜索 </el-button>
-            <el-button @click="addRow" type="primary" icon="el-icon-plus" class="filter-item">添加 </el-button>
             <el-button
                 @click="download"
                 type="primary"