🎨 代码优化

pull/216/head
ruibaby 2019-01-31 23:20:21 +08:00
parent e0e3be00bb
commit 1e648ddc45
44 changed files with 56 additions and 182 deletions

View File

@ -1,8 +1,6 @@
package cc.ryanc.halo.repository;
import cc.ryanc.halo.model.domain.Attachment;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
/**

View File

@ -5,7 +5,6 @@ import cc.ryanc.halo.model.domain.Post;
import cc.ryanc.halo.model.domain.Tag;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

View File

@ -63,7 +63,6 @@ public class AttachmentServiceImpl implements AttachmentService {
*
*
* @param attachment attachment
*
* @return Attachment
*/
@Override
@ -87,7 +86,6 @@ public class AttachmentServiceImpl implements AttachmentService {
*
*
* @param pageable pageable
*
* @return Page
*/
@Override
@ -99,7 +97,6 @@ public class AttachmentServiceImpl implements AttachmentService {
* id
*
* @param attachId attachId
*
* @return Optional
*/
@Override
@ -111,7 +108,6 @@ public class AttachmentServiceImpl implements AttachmentService {
*
*
* @param attachId attachId
*
* @return Attachment
*/
@Override
@ -127,7 +123,6 @@ public class AttachmentServiceImpl implements AttachmentService {
*
* @param file file
* @param request request
*
* @return Map
*/
@Override
@ -159,7 +154,6 @@ public class AttachmentServiceImpl implements AttachmentService {
*
* @param file file
* @param request request
*
* @return Map
*/
@Override
@ -251,7 +245,6 @@ public class AttachmentServiceImpl implements AttachmentService {
*
* @param file file
* @param request request
*
* @return Map
*/
@Override
@ -312,7 +305,6 @@ public class AttachmentServiceImpl implements AttachmentService {
*
* @param file file
* @param request request
*
* @return Map
*/
@Override
@ -362,7 +354,6 @@ public class AttachmentServiceImpl implements AttachmentService {
*
*
* @param key key
*
* @return boolean
*/
@Override
@ -391,7 +382,6 @@ public class AttachmentServiceImpl implements AttachmentService {
*
*
* @param fileName fileName
*
* @return boolean
*/
@Override

View File

@ -10,7 +10,6 @@ import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
/**

View File

@ -23,11 +23,10 @@ import java.util.Map;
@Service
public class OptionsServiceImpl implements OptionsService {
private static final String POSTS_CACHE_NAME = "posts";
@Autowired
private OptionsRepository optionsRepository;
private static final String POSTS_CACHE_NAME = "posts";
/**
*
*

View File

@ -11,7 +11,6 @@ import cc.ryanc.halo.repository.PostRepository;
import cc.ryanc.halo.service.CategoryService;
import cc.ryanc.halo.service.PostService;
import cc.ryanc.halo.service.TagService;
import cc.ryanc.halo.utils.HaloUtils;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HtmlUtil;
import org.springframework.beans.factory.annotation.Autowired;
@ -21,20 +20,14 @@ import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.domain.Specifications;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.*;
import static org.springframework.data.jpa.domain.Specification.where;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import static cc.ryanc.halo.model.dto.HaloConst.OPTIONS;
import static cc.ryanc.halo.model.dto.HaloConst.POSTS_VIEWS;
@ -67,7 +60,6 @@ public class PostServiceImpl implements PostService {
*
*
* @param post Post
*
* @return Post
*/
@Override
@ -91,7 +83,6 @@ public class PostServiceImpl implements PostService {
*
*
* @param postId postId
*
* @return Post
*/
@Override
@ -107,7 +98,6 @@ public class PostServiceImpl implements PostService {
*
* @param postId postId
* @param status status
*
* @return Post
*/
@Override
@ -142,7 +132,6 @@ public class PostServiceImpl implements PostService {
*
*
* @param postType post or page
*
* @return List
*/
@Override
@ -158,7 +147,6 @@ public class PostServiceImpl implements PostService {
* @param postType
* @param postStatus
* @param pageable
*
* @return Page
*/
@Override
@ -196,7 +184,6 @@ public class PostServiceImpl implements PostService {
* @param status 012
* @param postType post or page
* @param pageable
*
* @return Page
*/
@Override
@ -213,7 +200,6 @@ public class PostServiceImpl implements PostService {
*
*
* @param pageable pageable
*
* @return Page
*/
@Override
@ -232,7 +218,6 @@ public class PostServiceImpl implements PostService {
*
* @param status 012
* @param postType post or page
*
* @return List
*/
@Override
@ -245,7 +230,6 @@ public class PostServiceImpl implements PostService {
*
*
* @param postId postId
*
* @return Optional
*/
@Override
@ -257,7 +241,6 @@ public class PostServiceImpl implements PostService {
*
*
* @param postId postId
*
* @return Post
*/
@Override
@ -270,7 +253,6 @@ public class PostServiceImpl implements PostService {
*
* @param postUrl
* @param postType post or page
*
* @return Post
*/
@Override
@ -294,7 +276,6 @@ public class PostServiceImpl implements PostService {
*
*
* @param postDate postDate
*
* @return Post
*/
@Override
@ -306,7 +287,6 @@ public class PostServiceImpl implements PostService {
*
*
* @param postDate postDate
*
* @return Post
*/
@Override
@ -359,7 +339,6 @@ public class PostServiceImpl implements PostService {
/**
* @return List
*
* @Author Aquan
* @Description
* @Date 2019.1.4 11:16
@ -386,7 +365,6 @@ public class PostServiceImpl implements PostService {
*
* @param year year
* @param month month
*
* @return List
*/
@Override
@ -399,7 +377,6 @@ public class PostServiceImpl implements PostService {
*
*
* @param year year
*
* @return List
*/
@Override
@ -414,7 +391,6 @@ public class PostServiceImpl implements PostService {
* @param year year year
* @param month month month
* @param pageable pageable pageable
*
* @return Page
*/
@Override
@ -432,7 +408,6 @@ public class PostServiceImpl implements PostService {
*
* @param category category
* @param pageable pageable
*
* @return Page
*/
@Override
@ -451,7 +426,6 @@ public class PostServiceImpl implements PostService {
*
* @param tag tag
* @param pageable pageable
*
* @return Page
*/
@Override
@ -480,7 +454,6 @@ public class PostServiceImpl implements PostService {
*
*
* @param post post
*
* @return List
*/
@Override
@ -518,7 +491,6 @@ public class PostServiceImpl implements PostService {
*
*
* @param status
*
* @return
*/
@Override
@ -546,7 +518,6 @@ public class PostServiceImpl implements PostService {
* @param post post
* @param cateList cateList
* @param tagList tagList
*
* @return Post Post
*/
@Override
@ -564,7 +535,6 @@ public class PostServiceImpl implements PostService {
*
*
* @param limit
*
* @return List
*/
@Override

View File

@ -39,7 +39,6 @@ public class HaloUtils {
*
*
* @param dir dir
*
* @return List
*/
public static List<BackupDto> getBackUps(String dir) {
@ -74,7 +73,6 @@ public class HaloUtils {
*
*
* @param size size
*
* @return String
*/
public static String parseSize(long size) {
@ -101,7 +99,6 @@ public class HaloUtils {
*
*
* @param srcPath
*
* @return
*/
public static Date getCreateTime(String srcPath) {
@ -124,7 +121,6 @@ public class HaloUtils {
*
*
* @param file file
*
* @return String
*/
public static String getImageWh(File file) {
@ -186,7 +182,6 @@ public class HaloUtils {
*
*
* @param theme theme
*
* @return List
*/
public static List<String> getTplName(String theme) {
@ -294,7 +289,6 @@ public class HaloUtils {
* @param blogUrl
* @param token token
* @param urls
*
* @return String
*/
public static String baiduPost(String blogUrl, String token, String urls) {

View File

@ -43,7 +43,6 @@ public class MarkdownUtils {
* Markdown
*
* @param content content
*
* @return String
*/
public static String renderMarkdown(String content) {
@ -55,7 +54,6 @@ public class MarkdownUtils {
*
*
* @param content content
*
* @return Map
*/
public static Map<String, List<String>> getFrontMatter(String content) {

View File

@ -20,9 +20,7 @@ public class Md5Util {
* MD5
*
* @param file file
*
* @return byte
*
* @throws Exception Exception
*/
private static byte[] createChecksum(MultipartFile file) throws Exception {
@ -47,9 +45,7 @@ public class Md5Util {
* hash
*
* @param file file
*
* @return String
*
* @throws Exception Exception
*/
public static String getMD5Checksum(MultipartFile file) throws Exception {

View File

@ -19,7 +19,6 @@ public class OwoUtil {
*
*
* @param mark
*
* @return
*/
public static String markToImg(String mark) {

View File

@ -20,7 +20,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
@ -118,7 +117,6 @@ public class AdminController extends BaseController {
*
*
* @param session session
*
* @return admin/admin_login
*/
@GetMapping(value = "/login")
@ -137,7 +135,6 @@ public class AdminController extends BaseController {
* @param loginName
* @param loginPwd loginPwd
* @param session session session
*
* @return JsonResult JsonResult
*/
@PostMapping(value = "/getLogin")
@ -189,7 +186,6 @@ public class AdminController extends BaseController {
* 退 session
*
* @param session session
*
* @return /admin/login
*/
@GetMapping(value = "/logOut")
@ -209,7 +205,6 @@ public class AdminController extends BaseController {
*/
@GetMapping(value = "/logs")
public String logs(Model model, @PageableDefault Pageable pageable) {
final Sort sort = new Sort(Sort.Direction.DESC, "logId");
final Page<Logs> logs = logsService.findAll(pageable);
model.addAttribute("logs", logs);
return "admin/widget/_logs-all";
@ -278,7 +273,6 @@ public class AdminController extends BaseController {
*
* @param file file
* @param request request
*
* @return JsonResult
*/
@PostMapping(value = "/tools/markdownImport")

View File

@ -62,7 +62,6 @@ public class BackupController {
*
*
* @param model model
*
* @return admin/admin_backup
*/
@GetMapping
@ -86,7 +85,6 @@ public class BackupController {
*
*
* @param type
*
* @return JsonResult
*/
@GetMapping(value = "doBackup")
@ -208,7 +206,6 @@ public class BackupController {
*
* @param fileName
* @param type
*
* @return JsonResult
*/
@GetMapping(value = "delBackup")
@ -229,7 +226,6 @@ public class BackupController {
*
* @param fileName
* @param type
*
* @return JsonResult
*/
@GetMapping(value = "sendToEmail")

View File

@ -49,7 +49,6 @@ public class CategoryController {
* /
*
* @param category category
*
* @return JsonResult
*/
@PostMapping(value = "/save")
@ -81,7 +80,6 @@ public class CategoryController {
*
*
* @param cateId cateId
*
* @return /admin/category
*/
@GetMapping(value = "/remove")
@ -99,7 +97,6 @@ public class CategoryController {
*
* @param cateId cateId
* @param model model
*
* @return admin/admin_category
*/
@GetMapping(value = "/edit")

View File

@ -19,7 +19,6 @@ import cn.hutool.http.HtmlUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;

View File

@ -52,7 +52,6 @@ public class OptionController {
*
*
* @param options options
*
* @return JsonResult
*/
@PostMapping(value = "/save")

View File

@ -23,7 +23,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;

View File

@ -68,7 +68,6 @@ public class PostController extends BaseController {
* htmlhtm-
*
* @param url url
*
* @return String
*/
private static String urlFilter(String url) {
@ -125,7 +124,6 @@ public class PostController extends BaseController {
*
* @param postId
* @param model model
*
* @return /themes/{theme}/post
*/
@GetMapping(value = "/view")
@ -150,7 +148,6 @@ public class PostController extends BaseController {
*
* @param postId
* @param model model
*
* @return admin/admin_editor
*/
@GetMapping(value = "/edit")
@ -238,7 +235,6 @@ public class PostController extends BaseController {
*
*
* @param postId
*
* @return /admin/posts
*/
@GetMapping(value = "/throw")
@ -256,7 +252,6 @@ public class PostController extends BaseController {
*
*
* @param postId
*
* @return /admin/posts
*/
@GetMapping(value = "/revert")
@ -275,7 +270,6 @@ public class PostController extends BaseController {
*
*
* @param postId
*
* @return /admin/posts
*/
@GetMapping(value = "/remove")
@ -297,7 +291,6 @@ public class PostController extends BaseController {
*
*
* @param postSummary
*
* @return JsonResult
*/
@GetMapping(value = "/updateSummary")
@ -317,7 +310,6 @@ public class PostController extends BaseController {
*
*
* @param postUrl
*
* @return JsonResult
*/
@GetMapping(value = "/checkUrl")
@ -335,7 +327,6 @@ public class PostController extends BaseController {
*
*
* @param baiduToken baiduToken
*
* @return JsonResult
*/
@GetMapping(value = "/pushAllToBaidu")

View File

@ -48,7 +48,6 @@ public class TagController {
* /
*
* @param tag tag
*
* @return JsonResult
*/
@PostMapping(value = "/save")
@ -80,7 +79,6 @@ public class TagController {
*
*
* @param tagId
*
* @return /admin/tag
*/
@GetMapping(value = "/remove")
@ -98,7 +96,6 @@ public class TagController {
*
* @param model model
* @param tagId
*
* @return admin/admin_tag
*/
@GetMapping(value = "/edit")

View File

@ -66,7 +66,6 @@ public class ThemeController extends BaseController {
*
*
* @param model model
*
* @return admin/admin_theme
*/
@GetMapping
@ -83,7 +82,6 @@ public class ThemeController extends BaseController {
*
* @param siteTheme
* @param request request
*
* @return JsonResult
*/
@GetMapping(value = "/set")
@ -113,7 +111,6 @@ public class ThemeController extends BaseController {
*
*
* @param file
*
* @return JsonResult
*/
@RequestMapping(value = "/upload", method = RequestMethod.POST)
@ -147,7 +144,6 @@ public class ThemeController extends BaseController {
*
*
* @param themeName
*
* @return string /admin/themes
*/
@GetMapping(value = "/remove")
@ -179,7 +175,6 @@ public class ThemeController extends BaseController {
*
* @param remoteAddr
* @param themeName
*
* @return JsonResult
*/
@PostMapping(value = "/clone")
@ -209,7 +204,6 @@ public class ThemeController extends BaseController {
*
*
* @param themeName
*
* @return JsonResult
*/
@GetMapping(value = "/pull")
@ -253,7 +247,6 @@ public class ThemeController extends BaseController {
*
*
* @param model model
*
* @return admin/admin_theme-editor
*/
@GetMapping(value = "/editor")
@ -267,7 +260,6 @@ public class ThemeController extends BaseController {
*
*
* @param tplName
*
* @return
*/
@GetMapping(value = "/getTpl", produces = "text/text;charset=UTF-8")
@ -296,7 +288,6 @@ public class ThemeController extends BaseController {
*
* @param tplName
* @param tplContent
*
* @return JsonResult
*/
@PostMapping(value = "/editor/save")

View File

@ -56,7 +56,6 @@ public class UserController {
*
* @param user user
* @param session session
*
* @return JsonResult
*/
@PostMapping(value = "save")
@ -85,7 +84,6 @@ public class UserController {
* @param newPass
* @param userId
* @param session session
*
* @return JsonResult
*/
@PostMapping(value = "changePass")

View File

@ -137,11 +137,11 @@ public class ApiArchivesController {
}
/**
* @return JsonResult
* @Author Aquan
* @Description
* @Date 2019.1.4 11:06
* @Param
* @return JsonResult
**/
@GetMapping(value = "/all")
public JsonResult archivesAllPost() {

View File

@ -51,7 +51,6 @@ public class ApiCommentController {
* @param result result
* @param postId postId
* @param request request
*
* @return JsonResult
*/
@PostMapping(value = "/save")

View File

@ -48,7 +48,6 @@ public class ApiMetaWeBlog {
/**
* @param request request
*
* @return String
*/
@PostMapping
@ -126,9 +125,7 @@ public class ApiMetaWeBlog {
/**
* @param methodCall
*
* @return
*
* @throws Exception
*/
private Post parsetPost(final JSONObject methodCall) throws Exception {
@ -165,7 +162,6 @@ public class ApiMetaWeBlog {
*
*
* @param postId
*
* @return xml
*/
private String getPost(Long postId) {
@ -180,7 +176,6 @@ public class ApiMetaWeBlog {
*
*
* @param postId
*
* @return xml
*/
private String buildPost(final Long postId) {
@ -248,7 +243,6 @@ public class ApiMetaWeBlog {
*
*
* @return xml
*
* @throws Exception Exception
*/
private String getCategories() throws Exception {
@ -265,7 +259,6 @@ public class ApiMetaWeBlog {
*
*
* @return xml
*
* @throws Exception Exception
*/
private String buildCategories() throws Exception {

View File

@ -82,7 +82,6 @@ public class ApiOptionController {
* </p>
*
* @param optionName
*
* @return JsonResult
*/
@GetMapping(value = "/one")

View File

@ -58,7 +58,6 @@ public class ApiPageController {
* </p>
*
* @param postId postId
*
* @return JsonResult
*/
@GetMapping(value = "/{postId}")

View File

@ -23,7 +23,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static cc.ryanc.halo.model.dto.HaloConst.*;
import static cc.ryanc.halo.model.dto.HaloConst.OPTIONS;
/**
* <pre>
@ -66,7 +66,6 @@ public class InstallController {
*
*
* @param model model
*
* @return
*/
@GetMapping
@ -92,7 +91,6 @@ public class InstallController {
* @param userEmail
* @param userPwd
* @param request request
*
* @return JsonResult
*/
@PostMapping(value = "/do")

View File

@ -33,8 +33,8 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import static org.springframework.data.domain.Sort.Direction.DESC;
import static cc.ryanc.halo.model.dto.HaloConst.OPTIONS;
import static org.springframework.data.domain.Sort.Direction.DESC;
/**
* <pre>
@ -61,7 +61,6 @@ public class FrontArchiveController extends BaseController {
*
*
* @param model model
*
* @return
*/
@GetMapping
@ -74,7 +73,6 @@ public class FrontArchiveController extends BaseController {
*
* @param model model
* @param page page
*
* @return /themes/{theme}/archives
*/
@GetMapping(value = "page/{page}")
@ -98,7 +96,6 @@ public class FrontArchiveController extends BaseController {
* @param model model
* @param year year
* @param month month
*
* @return /themes/{theme}/archives
*/
@GetMapping(value = "{year}/{month}")
@ -119,7 +116,6 @@ public class FrontArchiveController extends BaseController {
*
* @param postUrl
* @param model model
*
* @return /themes/{theme}/post
*/
@GetMapping(value = "{postUrl}")
@ -193,7 +189,6 @@ public class FrontArchiveController extends BaseController {
* @param postId postId
* @param postPassword postPassword
* @param response response
*
* @return String
*/
@PostMapping(value = "/verifyPostPassword")

View File

@ -22,8 +22,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
import static org.springframework.data.domain.Sort.Direction.DESC;
import static cc.ryanc.halo.model.dto.HaloConst.OPTIONS;
import static org.springframework.data.domain.Sort.Direction.DESC;
/**
* <pre>

View File

@ -65,7 +65,6 @@ public class FrontCommentController {
* @param comment comment
* @param post post
* @param request request
*
* @return JsonResult
*/
@PostMapping(value = "/newComment")

View File

@ -19,8 +19,8 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import static org.springframework.data.domain.Sort.Direction.DESC;
import static cc.ryanc.halo.model.dto.HaloConst.OPTIONS;
import static org.springframework.data.domain.Sort.Direction.DESC;
/**
* <pre>
@ -43,7 +43,6 @@ public class FrontIndexController extends BaseController {
*
*
* @param model model
*
* @return
*/
@GetMapping

View File

@ -45,9 +45,7 @@ public class FrontOthersController {
* rss
*
* @param model model
*
* @return String
*
* @throws IOException IOException
* @throws TemplateException TemplateException
*/
@ -77,9 +75,7 @@ public class FrontOthersController {
* XML
*
* @param model model
*
* @return String
*
* @throws IOException IOException
* @throws TemplateException TemplateException
*/
@ -103,7 +99,6 @@ public class FrontOthersController {
* HTML
*
* @param model model
*
* @return String
*/
@GetMapping(value = "sitemap.html", produces = {"text/html"})
@ -124,9 +119,7 @@ public class FrontOthersController {
* robots
*
* @param model model
*
* @return String
*
* @throws IOException IOException
* @throws TemplateException TemplateException
*/

View File

@ -70,7 +70,6 @@ public class FrontPageController extends BaseController {
*
* @param postUrl
* @param model model
*
* @return /themes/{theme}/post
*/
@GetMapping(value = "/p/{postUrl}")

View File

@ -23,8 +23,8 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import static org.springframework.data.domain.Sort.Direction.DESC;
import static cc.ryanc.halo.model.dto.HaloConst.OPTIONS;
import static org.springframework.data.domain.Sort.Direction.DESC;
/**
* <pre>
@ -47,7 +47,6 @@ public class FrontSearchController extends BaseController {
*
* @param model model
* @param keyword
*
* @return /themes/{theme}/search
*/
@GetMapping
@ -62,7 +61,6 @@ public class FrontSearchController extends BaseController {
* @param model model
* @param keyword
* @param page
*
* @return /themes/{theme}/search
*/
@GetMapping(value = "page/{page}")

View File

@ -20,8 +20,8 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import static org.springframework.data.domain.Sort.Direction.DESC;
import static cc.ryanc.halo.model.dto.HaloConst.OPTIONS;
import static org.springframework.data.domain.Sort.Direction.DESC;
/**
* <pre>