👽 干掉部分bug

pull/18/head
ruibaby 2018-06-23 23:00:51 +08:00
parent a62b9f8df5
commit 3e262390ea
46 changed files with 233 additions and 180 deletions

2
.gitignore vendored
View File

@ -33,5 +33,3 @@ nbdist/
### VS Code ###
*.project
*.factorypath
~/

View File

@ -11,8 +11,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@Slf4j
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
log.info("Halo started at http://localhost:8090");
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
log.info("Halo started at http://localhost:8090");
}
}

View File

@ -19,7 +19,7 @@ public interface AttachmentRepository extends JpaRepository<Attachment, Long> {
*
*
* @param pageable pageable
* @return page
* @return Page
*/
@Override
Page<Attachment> findAll(Pageable pageable);

View File

@ -17,7 +17,7 @@ public interface CategoryRepository extends JpaRepository<Category, Long> {
*
*
* @param cateUrl cateUrl url
* @return category
* @return Category
*/
Category findCategoryByCateUrl(String cateUrl);
}

View File

@ -24,7 +24,7 @@ public interface CommentRepository extends JpaRepository<Comment, Long> {
*
* @param status
* @param pageable
* @return page
* @return Page
*/
Page<Comment> findCommentsByCommentStatus(Integer status, Pageable pageable);
@ -32,7 +32,7 @@ public interface CommentRepository extends JpaRepository<Comment, Long> {
*
*
* @param status
* @return list
* @return List
*/
List<Comment> findCommentsByCommentStatus(Integer status);
@ -41,7 +41,7 @@ public interface CommentRepository extends JpaRepository<Comment, Long> {
*
* @param post post
* @param pageable pageable
* @return page
* @return Page
*/
Page<Comment> findCommentsByPost(Post post, Pageable pageable);
@ -51,14 +51,14 @@ public interface CommentRepository extends JpaRepository<Comment, Long> {
* @param post post
* @param pageable pageable
* @param status status
* @return page
* @return Page
*/
Page<Comment> findCommentsByPostAndCommentStatus(Post post, Pageable pageable, Integer status);
/**
*
*
* @return list
* @return List
*/
@Query(value = "SELECT * FROM halo_comment ORDER BY comment_date DESC LIMIT 5", nativeQuery = true)
List<Comment> findTopFive();

View File

@ -19,7 +19,7 @@ public interface LogsRepository extends JpaRepository<Logs, Long> {
/**
*
*
* @return list
* @return List
*/
@Query(value = "SELECT * FROM halo_logs ORDER BY log_created DESC LIMIT 5", nativeQuery = true)
List<Logs> findTopFive();

View File

@ -17,7 +17,7 @@ public interface OptionsRepository extends JpaRepository<Options, Long> {
* keyoption
*
* @param key key
* @return String
* @return Options
*/
Options findOptionsByOptionName(String key);
}

View File

@ -25,7 +25,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
/**
*
*
* @return list
* @return List
*/
@Query(value = "SELECT * FROM halo_post where post_type='post' ORDER BY post_date DESC LIMIT 5", nativeQuery = true)
List<Post> findTopFive();
@ -34,7 +34,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
*
*
* @param postType post or page
* @return List<Post></>
* @return List
*/
List<Post> findPostsByPostType(String postType);
@ -43,7 +43,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
*
* @param postType post or page
* @param pageable
* @return Page<Post></>
* @return Page
*/
Page<Post> findPostsByPostType(String postType, Pageable pageable);
@ -52,7 +52,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
*
* @param keyWord keyword
* @param pageable pageable
* @return list
* @return List
*/
List<Post> findByPostTitleLike(String keyWord, Pageable pageable);
@ -62,7 +62,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
* @param status 012
* @param postType post or page
* @param pageable
* @return Page<Post></>
* @return Page
*/
Page<Post> findPostsByPostStatusAndPostType(Integer status, String postType, Pageable pageable);
@ -71,7 +71,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
*
* @param status 0,1,2
* @param postType post or page
* @return List<Post></>
* @return List
*/
List<Post> findPostsByPostStatusAndPostType(Integer status, String postType);
@ -90,7 +90,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
* @param postDate
* @param postStatus 012
* @param postType post or page
* @return List<Post></>
* @return List
*/
List<Post> findByPostDateAfterAndPostStatusAndPostTypeOrderByPostDateDesc(Date postDate, Integer postStatus, String postType);
@ -101,14 +101,14 @@ public interface PostRepository extends JpaRepository<Post, Long> {
* @param postDate
* @param postStatus 012
* @param postType post or page
* @return List<Post></>
* @return List
*/
List<Post> findByPostDateBeforeAndPostStatusAndPostTypeOrderByPostDateAsc(Date postDate, Integer postStatus, String postType);
/**
*
*
* @return List<Object [ ]></>
* @return List
*/
@Query(value = "select year(post_date) as year,month(post_date) as month,count(*) as count from halo_post where post_status=0 and post_type='post' group by year(post_date),month(post_date) order by year desc,month desc", nativeQuery = true)
List<Object[]> findPostGroupByYearAndMonth();
@ -116,7 +116,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
/**
*
*
* @return List<Object [ ]></>
* @return List
*/
@Query(value = "select year(post_date) as year,count(*) as count from halo_post where post_status=0 and post_type='post' group by year(post_date) order by year desc", nativeQuery = true)
List<Object[]> findPostGroupByYear();
@ -126,7 +126,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
*
* @param year year
* @param month month
* @return List<Post></>
* @return List
*/
@Query(value = "select *,year(post_date) as year,month(post_date) as month from halo_post where post_status=0 and post_type='post' and year(post_date)=:year and month(post_date)=:month order by post_date desc", nativeQuery = true)
List<Post> findPostByYearAndMonth(@Param("year") String year, @Param("month") String month);
@ -135,7 +135,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
*
*
* @param year year
* @return List<Post></>
* @return List
*/
@Query(value = "select *,year(post_date) as year from halo_post where post_status=0 and post_type='post' and year(post_date)=:year order by post_date desc", nativeQuery = true)
List<Post> findPostByYear(@Param("year") String year);
@ -146,7 +146,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
* @param year year
* @param month month
* @param pageable pageable
* @return Page<Post></>
* @return Page
*/
@Query(value = "select * from halo_post where post_status=0 and post_type='post' and year(post_date)=:year and month(post_date)=:month order by post_date desc", countQuery = "select count(*) from halo_post where post_status=0 and year(post_date)=:year and month(post_date)=:month", nativeQuery = true)
Page<Post> findPostByYearAndMonth(@Param("year") String year, @Param("month") String month, Pageable pageable);
@ -156,27 +156,33 @@ public interface PostRepository extends JpaRepository<Post, Long> {
*
* @param category category
* @param pageable pageable
* @return Page<Post></>
* @return Page
*/
Page<Post> findPostByCategories(Category category, Pageable pageable);
/**
*
*
*
* @param tag tag
* @param pageable pageable
* @return Page<Post></>
* @return Page
*/
Page<Post> findPostsByTags(Tag tag, Pageable pageable);
/**
*
*
* @param tag tag
* @return List
*/
List<Post> findPostsByTags(Tag tag);
/**
*
*
* @param postType post or page
* @param postStatus 012
* @param keyword
* @param pageable
* @return Page<Post></>
* @return Page
*/
@Query(value = "select * from halo_post where post_status = 0 and post_type='post' and post_title like '%=:keyword%' or post_content like '%=:keyword%'", nativeQuery = true)
Page<Post> findPostByPostTitleLikeOrPostContentLikeAndPostTypeAndPostStatus(String keyword, Pageable pageable);

View File

@ -17,7 +17,7 @@ public interface TagRepository extends JpaRepository<Tag, Long> {
*
*
* @param tagUrl tagUrl
* @return tag
* @return Tag
*/
Tag findTagByTagUrl(String tagUrl);
@ -25,7 +25,7 @@ public interface TagRepository extends JpaRepository<Tag, Long> {
*
*
* @param tagName
* @return tag
* @return Tag
*/
Tag findTagByTagName(String tagName);
}

View File

@ -18,7 +18,7 @@ public interface UserRepository extends JpaRepository<User, Long> {
*
* @param userName userName
* @param userPass userPass
* @return list
* @return User
*/
User findByUserNameAndUserPass(String userName, String userPass);
@ -27,7 +27,7 @@ public interface UserRepository extends JpaRepository<User, Long> {
*
* @param userEmail userEmail
* @param userPass userPass
* @return list
* @return User
*/
User findByUserEmailAndUserPass(String userEmail, String userPass);

View File

@ -24,7 +24,7 @@ public interface AttachmentService {
/**
*
*
* @return list
* @return List
*/
List<Attachment> findAllAttachments();
@ -32,7 +32,7 @@ public interface AttachmentService {
*
*
* @param pageable pageable
* @return page
* @return Page
*/
Page<Attachment> findAllAttachments(Pageable pageable);

View File

@ -25,7 +25,7 @@ public interface CommentService {
*
*
* @param commentId commentId
* @return comment
* @return Optional
*/
Optional<Comment> removeByCommentId(Long commentId);
@ -34,7 +34,7 @@ public interface CommentService {
*
* @param status status
* @param pageable pageable
* @return page
* @return Page
*/
Page<Comment> findAllComments(Integer status, Pageable pageable);
@ -42,14 +42,14 @@ public interface CommentService {
*
*
* @param status
* @return list
* @return List
*/
List<Comment> findAllComments(Integer status);
/**
*
*
* @return list
* @return List
*/
List<Comment> findAllComments();
@ -58,7 +58,7 @@ public interface CommentService {
*
* @param commentId commentId
* @param status status
* @return comment
* @return Comment
*/
Comment updateCommentStatus(Long commentId, Integer status);
@ -66,7 +66,7 @@ public interface CommentService {
*
*
* @param commentId commentId
* @return comment
* @return Optional
*/
Optional<Comment> findCommentById(Long commentId);
@ -75,7 +75,7 @@ public interface CommentService {
*
* @param post post
* @param pageable pageable
* @return page
* @return Page
*/
Page<Comment> findCommentsByPost(Post post, Pageable pageable);
@ -85,14 +85,14 @@ public interface CommentService {
* @param post post
* @param pageable pageable
* @param status status
* @return page
* @return Page
*/
Page<Comment> findCommentsByPostAndCommentStatus(Post post, Pageable pageable, Integer status);
/**
*
*
* @return list
* @return List
*/
List<Comment> findCommentsLatest();
}

View File

@ -25,6 +25,7 @@ public interface GalleryService {
*
*
* @param galleryId galleryId
* @return Gallery
*/
Gallery removeByGalleryId(Long galleryId);
@ -40,14 +41,14 @@ public interface GalleryService {
*
*
* @param pageable pageable
* @return page
* @return Page
*/
Page<Gallery> findAllGalleries(Pageable pageable);
/**
*
*
* @return list
* @return List
*/
List<Gallery> findAllGalleries();
@ -55,7 +56,7 @@ public interface GalleryService {
*
*
* @param galleryId galleryId
* @return gallery
* @return Optional
*/
Optional<Gallery> findByGalleryId(Long galleryId);
}

View File

@ -17,7 +17,7 @@ public interface LogsService {
*
*
* @param logs logs
* @return logs
* @return Logs
*/
Logs saveByLogs(Logs logs);
@ -37,14 +37,14 @@ public interface LogsService {
*
*
* @param pageable pageable
* @return page
* @return Page
*/
Page<Logs> findAllLogs(Pageable pageable);
/**
*
*
* @return list
* @return List
*/
List<Logs> findLogsLatest();
@ -52,7 +52,7 @@ public interface LogsService {
*
*
* @param logsId logsId
* @return logs
* @return Optional
*/
Optional<Logs> findLogsByLogsId(Long logsId);
}

View File

@ -22,7 +22,7 @@ public interface MenuService {
/**
*
*
* @return list
* @return List
*/
List<Menu> findAllMenus();
@ -30,7 +30,7 @@ public interface MenuService {
*
*
* @param menuId menuId
* @return menu
* @return Menu
*/
Menu removeByMenuId(Long menuId);
@ -38,7 +38,7 @@ public interface MenuService {
*
*
* @param menuId menuId
* @return Menu
* @return Optional
*/
Optional<Menu> findByMenuId(Long menuId);
}

View File

@ -35,7 +35,7 @@ public interface OptionsService {
/**
*
*
* @return map
* @return Map
*/
Map<String, String> findAllOptions();

View File

@ -54,7 +54,7 @@ public interface PostService {
*
* @param postType post or page
* @param pageable
* @return Page<Post></>
* @return Page
*/
Page<Post> findAllPosts(String postType, Pageable pageable);
@ -62,7 +62,7 @@ public interface PostService {
*
*
* @param postType post or page
* @return List<Post></>
* @return List
*/
List<Post> findAllPosts(String postType);
@ -71,7 +71,7 @@ public interface PostService {
*
* @param keyWord keyword
* @param pageable pageable
* @return list
* @return List
*/
List<Post> searchPosts(String keyWord, Pageable pageable);
@ -81,7 +81,7 @@ public interface PostService {
* @param status 012
* @param postType post or page
* @param pageable
* @return Page<Post></>
* @return Page
*/
Page<Post> findPostByStatus(Integer status, String postType, Pageable pageable);
@ -90,7 +90,7 @@ public interface PostService {
*
* @param status 012
* @param postType post or page
* @return List<Post></>
* @return List
*/
List<Post> findPostByStatus(Integer status, String postType);
@ -122,7 +122,7 @@ public interface PostService {
* Id
*
* @param postDate postDate
* @return post
* @return List
*/
List<Post> findByPostDateAfter(Date postDate);
@ -130,7 +130,7 @@ public interface PostService {
* Id
*
* @param postDate postDate
* @return list
* @return List
*/
List<Post> findByPostDateBefore(Date postDate);
@ -144,7 +144,7 @@ public interface PostService {
/**
*
*
* @return list
* @return List
*/
List<Archive> findPostGroupByYear();
@ -153,7 +153,7 @@ public interface PostService {
*
* @param year year
* @param month month
* @return list
* @return List
*/
List<Post> findPostByYearAndMonth(String year, String month);
@ -163,7 +163,7 @@ public interface PostService {
* @param year year
* @param month month
* @param pageable pageable
* @return page
* @return Page
*/
Page<Post> findPostByYearAndMonth(String year, String month, Pageable pageable);
@ -171,7 +171,7 @@ public interface PostService {
*
*
* @param year year
* @return list
* @return List
*/
List<Post> findPostByYear(String year);
@ -180,7 +180,7 @@ public interface PostService {
*
* @param category category
* @param pageable pageable
* @return Page<Post></>
* @return Page
*/
Page<Post> findPostByCategories(Category category,Pageable pageable);
@ -189,7 +189,7 @@ public interface PostService {
*
* @param tag tag
* @param pageable pageable
* @return page
* @return Page
*/
Page<Post> findPostsByTags(Tag tag, Pageable pageable);
@ -198,22 +198,30 @@ public interface PostService {
*
* @param keyword
* @param pageable
* @return Page<Post></>
* @return Page
*/
Page<Post> searchByKeywords(String keyword,Pageable pageable);
/**
*
*
* @return List<Post>
* @return List
*/
List<Post> hotPosts();
/**
*
*
* @param post post
* @return List
*/
List<Post> relatedPosts(Post post);
/**
* rss
*
* @param posts posts
* @return string
* @return String
*/
String buildRss(List<Post> posts);
@ -221,7 +229,7 @@ public interface PostService {
* sitemap
*
* @param posts posts
* @return string
* @return String
*/
String buildSiteMap(List<Post> posts);
}

View File

@ -30,7 +30,7 @@ public interface TagService {
/**
*
*
* @return list
* @return List
*/
List<Tag> findAllTags();
@ -38,7 +38,7 @@ public interface TagService {
*
*
* @param tagId tagId
* @return Link
* @return Optional
*/
Optional<Tag> findByTagId(Long tagId);
@ -46,7 +46,7 @@ public interface TagService {
*
*
* @param tagUrl tagUrl
* @return tag
* @return Tag
*/
Tag findByTagUrl(String tagUrl);
@ -54,7 +54,7 @@ public interface TagService {
*
*
* @param tagName tagName
* @return tag
* @return Tag
*/
Tag findTagByTagName(String tagName);
@ -62,7 +62,7 @@ public interface TagService {
*
*
* @param tagList tagList
* @return list
* @return List
*/
List<Tag> strListToTagList(String tagList);
}

View File

@ -31,14 +31,14 @@ public interface UserService {
*
* @param userEmail userEmail
* @param userPass userPass
* @return list
* @return User
*/
User userLoginByEmail(String userEmail, String userPass);
/**
*
*
* @return list
* @return User
*/
User findUser();
@ -47,7 +47,7 @@ public interface UserService {
*
* @param userId userid
* @param userPass userpass
* @return user
* @return User
*/
User findByUserIdAndUserPass(Long userId, String userPass);

View File

@ -35,7 +35,7 @@ public class AttachmentServiceImpl implements AttachmentService {
/**
*
*
* @return list
* @return List
*/
@Override
public List<Attachment> findAllAttachments() {
@ -46,7 +46,7 @@ public class AttachmentServiceImpl implements AttachmentService {
*
*
* @param pageable pageable
* @return page
* @return Page
*/
@Override
public Page<Attachment> findAllAttachments(Pageable pageable) {
@ -57,7 +57,7 @@ public class AttachmentServiceImpl implements AttachmentService {
* id
*
* @param attachId attachId
* @return attachment
* @return Optional
*/
@Override
public Optional<Attachment> findByAttachId(Long attachId) {
@ -68,7 +68,7 @@ public class AttachmentServiceImpl implements AttachmentService {
*
*
* @param attachId attachId
* @return attachment
* @return Attachment
*/
@Override
public Attachment removeByAttachId(Long attachId) {

View File

@ -47,7 +47,7 @@ public class CategoryServiceImpl implements CategoryService {
/**
*
*
* @return list
* @return List
*/
@Override
public List<Category> findAllCategories() {
@ -69,14 +69,13 @@ public class CategoryServiceImpl implements CategoryService {
*
*
* @param cateUrl cateUrl
* @return category
* @return Category
*/
@Override
public Category findByCateUrl(String cateUrl) {
return categoryRepository.findCategoryByCateUrl(cateUrl);
}
@Override
public List<Category> strListToCateList(List<String> strings) {
if (null == strings) {

View File

@ -35,7 +35,8 @@ public class CommentServiceImpl implements CommentService {
/**
*
*
* @param comment
* @param commentId commentId
* @return Optional
*/
@Override
public Optional<Comment> removeByCommentId(Long commentId) {
@ -48,7 +49,7 @@ public class CommentServiceImpl implements CommentService {
*
*
* @param pageable pageable
* @return page
* @return Page
*/
@Override
public Page<Comment> findAllComments(Integer status, Pageable pageable) {
@ -59,7 +60,7 @@ public class CommentServiceImpl implements CommentService {
*
*
* @param status
* @return list
* @return List
*/
@Override
public List<Comment> findAllComments(Integer status) {
@ -81,7 +82,7 @@ public class CommentServiceImpl implements CommentService {
*
* @param commentId commentId
* @param status status
* @return comment
* @return Comment
*/
@Override
public Comment updateCommentStatus(Long commentId, Integer status) {
@ -94,7 +95,7 @@ public class CommentServiceImpl implements CommentService {
*
*
* @param commentId commentId
* @return comment
* @return Optional
*/
@Override
public Optional<Comment> findCommentById(Long commentId) {
@ -106,7 +107,7 @@ public class CommentServiceImpl implements CommentService {
*
* @param post post
* @param pageable pageable
* @return page
* @return Page
*/
@Override
public Page<Comment> findCommentsByPost(Post post, Pageable pageable) {
@ -119,7 +120,7 @@ public class CommentServiceImpl implements CommentService {
* @param post post
* @param pageable pageable
* @param status status
* @return page
* @return Page
*/
@Override
public Page<Comment> findCommentsByPostAndCommentStatus(Post post, Pageable pageable, Integer status) {
@ -129,7 +130,7 @@ public class CommentServiceImpl implements CommentService {
/**
*
*
* @return list
* @return List
*/
@Override
public List<Comment> findCommentsLatest() {

View File

@ -36,6 +36,7 @@ public class GalleryServiceImpl implements GalleryService {
*
*
* @param galleryId galleryId
* @return Gallery
*/
@Override
public Gallery removeByGalleryId(Long galleryId) {
@ -59,7 +60,7 @@ public class GalleryServiceImpl implements GalleryService {
*
*
* @param pageable pageable
* @return page
* @return Page
*/
@Override
public Page<Gallery> findAllGalleries(Pageable pageable) {
@ -69,7 +70,7 @@ public class GalleryServiceImpl implements GalleryService {
/**
*
*
* @return list
* @return List
*/
@Override
public List<Gallery> findAllGalleries() {
@ -80,7 +81,7 @@ public class GalleryServiceImpl implements GalleryService {
*
*
* @param galleryId galleryId
* @return gallery
* @return Optional
*/
@Override
public Optional<Gallery> findByGalleryId(Long galleryId) {

View File

@ -34,7 +34,7 @@ public class LinkServiceImpl implements LinkService {
*
*
* @param linkId linkId
* @return link
* @return Link
*/
@Override
public Link removeByLinkId(Long linkId) {
@ -46,7 +46,7 @@ public class LinkServiceImpl implements LinkService {
/**
*
*
* @return list
* @return List
*/
@Override
public List<Link> findAllLinks() {
@ -57,7 +57,7 @@ public class LinkServiceImpl implements LinkService {
*
*
* @param linkId linkId
* @return Link
* @return Optional
*/
@Override
public Optional<Link> findByLinkId(Long linkId) {

View File

@ -25,7 +25,7 @@ public class LogsServiceImpl implements LogsService {
*
*
* @param logs logs
* @return logs
* @return Logs
*/
@Override
public Logs saveByLogs(Logs logs) {
@ -55,7 +55,7 @@ public class LogsServiceImpl implements LogsService {
*
*
* @param pageable pageable
* @return page
* @return Page
*/
@Override
public Page<Logs> findAllLogs(Pageable pageable) {
@ -65,7 +65,7 @@ public class LogsServiceImpl implements LogsService {
/**
*
*
* @return list
* @return List
*/
@Override
public List<Logs> findLogsLatest() {
@ -76,7 +76,7 @@ public class LogsServiceImpl implements LogsService {
*
*
* @param logsId logsId
* @return logs
* @return Optional
*/
@Override
public Optional<Logs> findLogsByLogsId(Long logsId) {

View File

@ -22,7 +22,7 @@ public class MenuServiceImpl implements MenuService {
/**
*
*
* @return list
* @return List
*/
@Override
public List<Menu> findAllMenus() {
@ -44,7 +44,7 @@ public class MenuServiceImpl implements MenuService {
*
*
* @param menuId menuId
* @return menu
* @return Menu
*/
@Override
public Menu removeByMenuId(Long menuId) {

View File

@ -76,7 +76,7 @@ public class OptionsServiceImpl implements OptionsService {
/**
*
*
* @return map
* @return Map
*/
@Override
public Map<String, String> findAllOptions() {

View File

@ -91,7 +91,7 @@ public class PostServiceImpl implements PostService {
*
* @param postType post or page
* @param pageable
* @return Page<Post></>
* @return Page
*/
@Override
public Page<Post> findAllPosts(String postType, Pageable pageable) {
@ -102,7 +102,7 @@ public class PostServiceImpl implements PostService {
*
*
* @param postType post or page
* @return List<Post></>
* @return List
*/
@Override
public List<Post> findAllPosts(String postType) {
@ -114,7 +114,7 @@ public class PostServiceImpl implements PostService {
*
* @param keyWord keyword
* @param pageable pageable
* @return list
* @return List
*/
@Override
public List<Post> searchPosts(String keyWord, Pageable pageable) {
@ -127,7 +127,7 @@ public class PostServiceImpl implements PostService {
* @param status 012
* @param postType post or page
* @param pageable
* @return Page<Post></>
* @return Page
*/
@Override
public Page<Post> findPostByStatus(Integer status, String postType, Pageable pageable) {
@ -139,7 +139,7 @@ public class PostServiceImpl implements PostService {
*
* @param status 012
* @param postType post or page
* @return List<Post></>
* @return List
*/
@Override
public List<Post> findPostByStatus(Integer status, String postType) {
@ -150,7 +150,7 @@ public class PostServiceImpl implements PostService {
*
*
* @param postId postId
* @return post
* @return Optional
*/
@Override
public Optional<Post> findByPostId(Long postId) {
@ -172,7 +172,7 @@ public class PostServiceImpl implements PostService {
/**
* 5
*
* @return list
* @return List
*/
@Override
public List<Post> findPostLatest() {
@ -194,7 +194,7 @@ public class PostServiceImpl implements PostService {
* Id
*
* @param postDate
* @return list
* @return List
*/
@Override
public List<Post> findByPostDateBefore(Date postDate) {
@ -226,7 +226,7 @@ public class PostServiceImpl implements PostService {
/**
*
*
* @return list
* @return List
*/
@Override
public List<Archive> findPostGroupByYear() {
@ -248,7 +248,7 @@ public class PostServiceImpl implements PostService {
*
* @param year year
* @param month month
* @return list
* @return List
*/
@Override
public List<Post> findPostByYearAndMonth(String year, String month) {
@ -259,7 +259,7 @@ public class PostServiceImpl implements PostService {
*
*
* @param year year
* @return list
* @return List
*/
@Override
public List<Post> findPostByYear(String year) {
@ -272,7 +272,7 @@ public class PostServiceImpl implements PostService {
* @param year year year
* @param month month month
* @param pageable pageable pageable
* @return page
* @return Page
*/
@Override
public Page<Post> findPostByYearAndMonth(String year, String month, Pageable pageable) {
@ -284,7 +284,7 @@ public class PostServiceImpl implements PostService {
*
* @param category category
* @param pageable pageable
* @return Page<Post></>
* @return Page
*/
@Override
public Page<Post> findPostByCategories(Category category, Pageable pageable) {
@ -296,7 +296,7 @@ public class PostServiceImpl implements PostService {
*
* @param tag tag
* @param pageable pageable
* @return page
* @return Page
*/
@Override
public Page<Post> findPostsByTags(Tag tag, Pageable pageable) {
@ -308,7 +308,7 @@ public class PostServiceImpl implements PostService {
*
* @param keyword
* @param pageable
* @return List<Post></>
* @return Page
*/
@Override
public Page<Post> searchByKeywords(String keyword,Pageable pageable) {
@ -318,18 +318,44 @@ public class PostServiceImpl implements PostService {
/**
*
*
* @return List<Post>
* @return List
*/
@Override
public List<Post> hotPosts() {
return postRepository.findPostsByPostTypeOrderByPostViewsDesc(HaloConst.POST_TYPE_POST);
}
/**
*
*
* @param post post
* @return List
*/
@Override
public List<Post> relatedPosts(Post post) {
//获取当前文章的所有标签
List<Tag> tags = post.getTags();
List<Post> tempPosts = new ArrayList<>();
for (Tag tag : tags) {
tempPosts.addAll(postRepository.findPostsByTags(tag));
}
//去掉当前的文章
tempPosts.remove(post);
//去掉重复的文章
List<Post> allPosts = new ArrayList<>();
for (int i = 0; i < tempPosts.size(); i++) {
if (!allPosts.contains(tempPosts.get(i))) {
allPosts.add(tempPosts.get(i));
}
}
return allPosts;
}
/**
* rss
*
* @param posts posts
* @return string
* @return String
*/
@Override
public String buildRss(List<Post> posts) {
@ -346,7 +372,7 @@ public class PostServiceImpl implements PostService {
* sitemap
*
* @param posts posts
* @return string
* @return String
*/
@Override
public String buildSiteMap(List<Post> posts) {

View File

@ -47,7 +47,7 @@ public class TagServiceImpl implements TagService {
/**
*
*
* @return list
* @return List
*/
@Override
public List<Tag> findAllTags() {
@ -58,7 +58,7 @@ public class TagServiceImpl implements TagService {
*
*
* @param tagId tagId
* @return Link
* @return Optional
*/
@Override
public Optional<Tag> findByTagId(Long tagId) {
@ -69,7 +69,7 @@ public class TagServiceImpl implements TagService {
*
*
* @param tagUrl tagUrl
* @return tag
* @return Tag
*/
@Override
public Tag findByTagUrl(String tagUrl) {
@ -80,7 +80,7 @@ public class TagServiceImpl implements TagService {
*
*
* @param tagName tagName
* @return tag
* @return Tag
*/
@Override
public Tag findTagByTagName(String tagName) {
@ -91,7 +91,7 @@ public class TagServiceImpl implements TagService {
*
*
* @param tagList tagList
* @return list
* @return List
*/
@Override
public List<Tag> strListToTagList(String tagList) {

View File

@ -34,7 +34,7 @@ public class UserServiceImpl implements UserService {
*
* @param userName userName
* @param userPass userPass
* @return user
* @return User
*/
@Override
public User userLoginByName(String userName, String userPass) {
@ -46,7 +46,7 @@ public class UserServiceImpl implements UserService {
*
* @param userEmail userEmail
* @param userPass userPass
* @return list
* @return User
*/
@Override
public User userLoginByEmail(String userEmail, String userPass) {
@ -56,7 +56,7 @@ public class UserServiceImpl implements UserService {
/**
*
*
* @return list
* @return User
*/
@Override
public User findUser() {

View File

@ -89,7 +89,7 @@ public class HaloUtils {
*
*
* @param filePath filePath
* @return Map
* @return ArrayList
*/
public static ArrayList<String> getFiles(String filePath) {
try {
@ -117,7 +117,7 @@ public class HaloUtils {
*
*
* @param dir dir
* @return List<BackupDto></>
* @return List
*/
public static List<BackupDto> getBackUps(String dir) {
String srcPathStr = System.getProperties().getProperty("user.home") + "/halo/backup/" + dir;
@ -149,7 +149,7 @@ public class HaloUtils {
*
*
* @param size size
* @return string
* @return String
*/
public static String parseSize(long size) {
if (size < 1024) {
@ -196,7 +196,7 @@ public class HaloUtils {
/**
*
*
* @return list
* @return List
*/
public static List<Theme> getThemes() {
List<Theme> themes = new ArrayList<>();
@ -235,7 +235,7 @@ public class HaloUtils {
*
*
* @param theme theme
* @return list
* @return List
*/
public static List<String> getTplName(String theme) {
List<String> tpls = new ArrayList<>();
@ -271,7 +271,7 @@ public class HaloUtils {
*
*
* @param filePath filePath
* @return string
* @return String
*/
public static String getFileContent(String filePath) {
File file = new File(filePath);
@ -384,7 +384,7 @@ public class HaloUtils {
* rss
*
* @param posts posts
* @return string
* @return String
* @throws FeedException
*/
public static String getRss(List<Post> posts) throws FeedException {
@ -435,7 +435,7 @@ public class HaloUtils {
* sitemap
*
* @param posts posts
* @return string
* @return String
*/
public static String getSiteMap(List<Post> posts) {
String head = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">";
@ -466,7 +466,7 @@ public class HaloUtils {
* 访json
*
* @param enterUrl
* @return string
* @return String
*/
public static String getHttpResponse(String enterUrl) {
BufferedReader in = null;
@ -507,7 +507,7 @@ public class HaloUtils {
* @param blogUrl
* @param token token
* @param urls
* @return string
* @return String
*/
public static String baiduPost(String blogUrl, String token, String urls) {
String url = "http://data.zz.baidu.com/urls?site=" + blogUrl + "&token=" + token;

View File

@ -11,7 +11,6 @@ import cc.ryanc.halo.service.CommentService;
import cc.ryanc.halo.service.LogsService;
import cc.ryanc.halo.service.PostService;
import cc.ryanc.halo.service.UserService;
import cc.ryanc.halo.utils.HaloUtils;
import cc.ryanc.halo.web.controller.core.BaseController;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;

View File

@ -31,7 +31,10 @@ import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Random;
/**
* @author : RYAN0UP
@ -101,7 +104,7 @@ public class AttachmentController {
*
* @param file file
* @param request request
* @return Map<String , Object></>
* @return Map
*/
@PostMapping(value = "/upload", produces = {"application/json;charset=UTF-8"})
@ResponseBody
@ -115,7 +118,7 @@ public class AttachmentController {
*
* @param file file
* @param request request
* @return Map<String , Object></>
* @return Map
*/
@PostMapping(value = "/upload/editor", produces = {"application/json;charset=UTF-8"})
@ResponseBody
@ -130,7 +133,7 @@ public class AttachmentController {
*
* @param file file
* @param request request
* @return Map<String , Object></>
* @return Map
*/
private Map<String, Object> uploadAttachment(MultipartFile file, HttpServletRequest request) {
Map<String, Object> result = new HashMap<String, Object>();

View File

@ -8,7 +8,6 @@ import cc.ryanc.halo.service.GalleryService;
import cc.ryanc.halo.service.LinkService;
import cc.ryanc.halo.service.LogsService;
import cc.ryanc.halo.service.PostService;
import cc.ryanc.halo.utils.HaloUtils;
import cn.hutool.core.date.DateUtil;
import cn.hutool.extra.servlet.ServletUtil;
import lombok.extern.slf4j.Slf4j;
@ -25,7 +24,6 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.websocket.server.PathParam;
import java.util.Date;
import java.util.List;
import java.util.Optional;

View File

@ -157,6 +157,10 @@ public class PostController extends BaseController {
public JsonResult pushPost(@ModelAttribute Post post, @RequestParam("cateList") List<String> cateList, @RequestParam("tagList") String tagList, HttpSession session) {
User user = (User) session.getAttribute(HaloConst.USER_SESSION_KEY);
String msg = "发表成功";
//判断文章路径是否已经存在
if (null != postService.findByPostUrl(post.getPostUrl(), HaloConst.POST_TYPE_POST)) {
return new JsonResult(0, "该文章路径已存在!");
}
try {
//提取摘要
int postSummary = 50;

View File

@ -26,7 +26,6 @@ import javax.websocket.server.PathParam;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Date;
import java.util.List;
/**
@ -64,7 +63,7 @@ public class ThemeController extends BaseController {
*
* @param siteTheme
* @param request request
* @return truefalse
* @return JsonResult
*/
@GetMapping(value = "/set")
@ResponseBody
@ -91,7 +90,7 @@ public class ThemeController extends BaseController {
*
*
* @param file
* @return boolean truefalse
* @return JsonResult
*/
@RequestMapping(value = "/upload", method = RequestMethod.POST)
@ResponseBody
@ -193,7 +192,7 @@ public class ThemeController extends BaseController {
*
* @param tplName
* @param tplContent
* @return boolean truefalse
* @return JsonResult
*/
@PostMapping(value = "/editor/save")
@ResponseBody

View File

@ -42,7 +42,7 @@ public class UserController {
*
* @param user user
* @param session session
* @return truefalse
* @return JsonResult
*/
@PostMapping(value = "save")
@ResponseBody
@ -69,7 +69,7 @@ public class UserController {
* @param newPass
* @param userId
* @param session session
* @return truefalse
* @return JsonResult
*/
@PostMapping(value = "changePass")
@ResponseBody

View File

@ -4,7 +4,10 @@ import cc.ryanc.halo.model.domain.Category;
import cc.ryanc.halo.model.dto.JsonResult;
import cc.ryanc.halo.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

View File

@ -23,7 +23,7 @@ public class CommonController implements ErrorController {
* 404500
*
* @param request request
* @return string
* @return String
*/
@GetMapping(value = ERROR_PATH)
public String handleError(HttpServletRequest request) {
@ -39,7 +39,7 @@ public class CommonController implements ErrorController {
* 404
*
* @param model model
* @return string
* @return String
*/
@GetMapping(value = "/404")
public String fourZeroFour(Model model) {
@ -52,7 +52,7 @@ public class CommonController implements ErrorController {
* 500
*
* @param model model
* @return string
* @return String
*/
@GetMapping(value = "/500")
public String fiveZeroZero(Model model) {

View File

@ -18,7 +18,6 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**

View File

@ -17,7 +17,6 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Date;
import java.util.List;

View File

@ -34,6 +34,12 @@ public class FrontCategoryController extends BaseController {
@Autowired
private PostService postService;
/**
*
*
* @param model model
* @return String
*/
public String categories(Model model) {
List<Category> categories = categoryService.findAllCategories();
model.addAttribute("categories", categories);
@ -59,7 +65,7 @@ public class FrontCategoryController extends BaseController {
* @param model model
* @param cateUrl
* @param page
* @return string
* @return String
*/
@GetMapping("{cateUrl}/page/{page}")
public String categories(Model model,

View File

@ -8,7 +8,6 @@ import cc.ryanc.halo.service.CommentService;
import cc.ryanc.halo.service.MailService;
import cc.ryanc.halo.service.PostService;
import cc.ryanc.halo.service.UserService;
import cc.ryanc.halo.utils.HaloUtils;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.URLUtil;
import cn.hutool.extra.servlet.ServletUtil;
@ -24,7 +23,10 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -52,7 +54,7 @@ public class FrontCommentController {
*
*
* @param postId postId
* @return List<Comment></>
* @return List
*/
@GetMapping(value = "/getComment/{postId}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
@ -72,7 +74,7 @@ public class FrontCommentController {
*
* @param page
* @param post
* @return List<Comment></>
* @return List
*/
@GetMapping(value = "/loadComment")
@ResponseBody
@ -90,7 +92,7 @@ public class FrontCommentController {
* @param comment comment
* @param post post
* @param request request
* @return truefalse
* @return JsonResult
*/
@PostMapping(value = "/newComment")
@ResponseBody

View File

@ -78,7 +78,7 @@ public class FrontIndexController extends BaseController {
* ajax
*
* @param page page
* @return List<Post></>
* @return List
*/
@GetMapping(value = "next")
@ResponseBody

View File

@ -47,7 +47,7 @@ public class FrontTagController extends BaseController {
*
* @param tagUrl
* @param model model
* @return string
* @return String
*/
@GetMapping(value = "{tagUrl}")
public String tags(Model model,
@ -61,7 +61,7 @@ public class FrontTagController extends BaseController {
* @param model model
* @param tagUrl
* @param page
* @return string
* @return String
*/
@GetMapping(value = "{tagUrl}/page/{page}")
public String tags(Model model,

View File

@ -202,7 +202,7 @@
scrollbar: false
});
}
function openAttachCopy() {
layer.open({
type: 2,
@ -281,7 +281,8 @@
});
}
$('#btn_input_postUrl').click(function () {
$('#postUrl').html("<input type='text' id='newPostUrl' onblur='urlOnBlurAuto()' value=''>");
var postUrl = $("#postUrl").html();
$('#postUrl').html("<input type='text' id='newPostUrl' onblur='urlOnBlurAuto()' value='"+postUrl+"'>");
$(this).hide();
$('#btn_change_postUrl').show();
});
@ -403,4 +404,4 @@
</div>
<#include "module/_footer.ftl">
</div>
<@footer></@footer>
<@footer></@footer>