提交 65a05def authored 作者: Whispa's avatar Whispa

commit

上级 40a0e9c0
...@@ -10,6 +10,8 @@ import com.google.api.client.util.Base64; ...@@ -10,6 +10,8 @@ import com.google.api.client.util.Base64;
import com.google.api.client.util.StringUtils; import com.google.api.client.util.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes; import org.springframework.web.servlet.mvc.support.RedirectAttributes;
...@@ -60,7 +62,7 @@ public class PostController { ...@@ -60,7 +62,7 @@ public class PostController {
public List<Post> postList(@RequestParam(value = "userId", required = false) String id, @RequestParam(value = "pageNo") Integer pageNo, @RequestParam(value = "pageSize") Integer pageSize) { public List<Post> postList(@RequestParam(value = "userId", required = false) String id, @RequestParam(value = "pageNo") Integer pageNo, @RequestParam(value = "pageSize") Integer pageSize) {
//Optional<User> byId = userRepository.findById(id); //Optional<User> byId = userRepository.findById(id);
//if( !byId.isPresent() ) return new ArrayList<>(); //if( !byId.isPresent() ) return new ArrayList<>();
List<Post> postList = repository.findAllByOrderByIdDesc(PageRequest.of(pageNo, pageSize)).toList(); List<Post> postList = repository.findAllByOrderByCreateDateDesc(PageRequest.of(pageNo, pageSize)).toList();
return id == null ? postList : postList(postList, id); return id == null ? postList : postList(postList, id);
} }
...@@ -195,7 +197,7 @@ public class PostController { ...@@ -195,7 +197,7 @@ public class PostController {
return "deleted"; return "deleted";
} }
@Transactional(isolation = Isolation.READ_COMMITTED)
@PostMapping("/upload") @PostMapping("/upload")
public List<String> handleFileUpload(@RequestParam("files") MultipartFile[] files, @RequestParam("thumbs") MultipartFile[] thumbs, @ModelAttribute("Post") Post post, public List<String> handleFileUpload(@RequestParam("files") MultipartFile[] files, @RequestParam("thumbs") MultipartFile[] thumbs, @ModelAttribute("Post") Post post,
RedirectAttributes redirectAttributes) throws IOException { RedirectAttributes redirectAttributes) throws IOException {
......
...@@ -51,7 +51,7 @@ public class TbCfHomePageEntityController { ...@@ -51,7 +51,7 @@ public class TbCfHomePageEntityController {
public List<Post> postList2(@RequestParam(value = "userId",required = false) String id, @RequestParam(value = "pageNo") Integer pageNo, @RequestParam(value = "pageSize") Integer pageSize) { public List<Post> postList2(@RequestParam(value = "userId",required = false) String id, @RequestParam(value = "pageNo") Integer pageNo, @RequestParam(value = "pageSize") Integer pageSize) {
Optional<TbCfUserInfo> byId = userRepository.findById(id); Optional<TbCfUserInfo> byId = userRepository.findById(id);
//if( !byId.isPresent() ) return new ArrayList<>(); //if( !byId.isPresent() ) return new ArrayList<>();
return postRepository.findAllByOrderByIdDesc(PageRequest.of(pageNo, pageSize)).toList(); return postRepository.findAllByOrderByCreateDateDesc(PageRequest.of(pageNo, pageSize)).toList();
} }
......
...@@ -36,7 +36,7 @@ abstract class Model { ...@@ -36,7 +36,7 @@ abstract class Model {
@JsonIgnore @JsonIgnore
public String updatedBy; public String updatedBy;
@Version
private int version; private int version;
@JsonIgnore @JsonIgnore
......
...@@ -14,11 +14,11 @@ public interface PostRepository extends PagingAndSortingRepository<Post, String> ...@@ -14,11 +14,11 @@ public interface PostRepository extends PagingAndSortingRepository<Post, String>
Page<Post> findAllByDescriptionContainingOrTitleContainingOrUserInfoNickContaining(String query, String query1, String query2, Pageable pageable); Page<Post> findAllByDescriptionContainingOrTitleContainingOrUserInfoNickContaining(String query, String query1, String query2, Pageable pageable);
//@Query(value = "select a from #{#entityName} a WHERE EXISTS(SELECT f.follower FROM Following f WHERE f.follower=:me and f.followed=a.user)") //@Query(value = "select a from #{#entityName} a WHERE EXISTS(SELECT f.follower FROM Following f WHERE f.follower=:me and f.followed=a.user)")
//Page<Post> findAllByOrderByIdDesc(@Param("me") User user, Pageable pageable); //Page<Post> findAllByOrderByIdDesc(@Param("me") User user, Pageable pageable);
@Query(value = "select a from #{#entityName} a WHERE a IN (SELECT x.post FROM PostLike x WHERE x.userInfo=:me) order by a.id desc") @Query(value = "select a from #{#entityName} a WHERE a IN (SELECT x.post FROM PostLike x WHERE x.userInfo=:me) order by a.createDate desc")
Page<Post> findAllByOrderByIdDesc(@Param("me") TbCfUserInfo user, Pageable pageable); Page<Post> findAllByOrderByIdDesc(@Param("me") TbCfUserInfo user, Pageable pageable);
@Query(value = "select a from #{#entityName} a WHERE a IN (SELECT x.post FROM PostHashtag x WHERE x.hashtag=:tag) order by a.id desc") @Query(value = "select a from #{#entityName} a WHERE a IN (SELECT x.post FROM PostHashtag x WHERE x.hashtag=:tag) order by a.createDate desc")
Page<Post> findAllByOrderByIdDesc(@Param("tag") Hashtag hashtag, Pageable pageable); Page<Post> findAllByOrderByIdDesc(@Param("tag") Hashtag hashtag, Pageable pageable);
Page<Post> findAllByOrderByIdDesc(Pageable pageable); Page<Post> findAllByOrderByCreateDateDesc(Pageable pageable);
//@Query(value = "select a from #{#entityName} a WHERE NOT EXISTS(SELECT f.follower FROM Following f WHERE f.follower=:me and f.followed=a.user)") //@Query(value = "select a from #{#entityName} a WHERE NOT EXISTS(SELECT f.follower FROM Following f WHERE f.follower=:me and f.followed=a.user)")
//Page<Post> _findAllByOrderByIdDesc(@Param("me") User user,Pageable pageable); //Page<Post> _findAllByOrderByIdDesc(@Param("me") User user,Pageable pageable);
//Page<Post> _findAllByOrderByIdDesc(Pageable pageable); //Page<Post> _findAllByOrderByIdDesc(Pageable pageable);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论