mirror of https://github.com/halo-dev/halo
Support journal search.
parent
c438d99d47
commit
6f35efe90f
|
@ -13,7 +13,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|||
* Halo run!
|
||||
* </pre>
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2017/11/14
|
||||
*/
|
||||
@SpringBootApplication
|
||||
|
|
|
@ -18,7 +18,7 @@ import javax.annotation.PostConstruct;
|
|||
/**
|
||||
* FreeMarker configuration.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2018/4/26
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -30,7 +30,7 @@ import java.util.List;
|
|||
/**
|
||||
* Mvc configuration.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2018/1/2
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -12,6 +12,7 @@ import run.halo.app.model.dto.JournalDTO;
|
|||
import run.halo.app.model.dto.JournalWithCmtCountDTO;
|
||||
import run.halo.app.model.entity.Journal;
|
||||
import run.halo.app.model.params.JournalParam;
|
||||
import run.halo.app.model.params.JournalQuery;
|
||||
import run.halo.app.model.vo.BaseCommentVO;
|
||||
import run.halo.app.model.vo.BaseCommentWithParentVO;
|
||||
import run.halo.app.service.JournalCommentService;
|
||||
|
@ -27,6 +28,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
|
|||
* Journal controller.
|
||||
*
|
||||
* @author johnniang
|
||||
* @author ryanwang
|
||||
* @date 19-4-25
|
||||
*/
|
||||
@RestController
|
||||
|
@ -49,8 +51,9 @@ public class JournalController {
|
|||
|
||||
@GetMapping
|
||||
@ApiOperation("Gets latest journals")
|
||||
public Page<JournalWithCmtCountDTO> pageBy(@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable) {
|
||||
Page<Journal> journalPage = journalService.listAll(pageable);
|
||||
public Page<JournalWithCmtCountDTO> pageBy(@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable,
|
||||
JournalQuery journalQuery) {
|
||||
Page<Journal> journalPage = journalService.pageBy(journalQuery,pageable);
|
||||
return journalService.convertToCmtCountDto(journalPage);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import java.util.List;
|
|||
/**
|
||||
* Link Controller
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019/3/21
|
||||
*/
|
||||
@RestController
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||
/**
|
||||
* Admin page.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-04-23
|
||||
*/
|
||||
@Controller
|
||||
|
|
|
@ -21,7 +21,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
|
|||
/**
|
||||
* Photo controller
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019/3/21
|
||||
*/
|
||||
@RestController
|
||||
|
|
|
@ -18,7 +18,7 @@ import java.util.Set;
|
|||
/**
|
||||
* Theme controller.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019/3/20
|
||||
*/
|
||||
@RestController
|
||||
|
|
|
@ -28,7 +28,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
|
|||
/**
|
||||
* Blog archive page controller
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-17
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -21,7 +21,7 @@ import run.halo.app.service.ThemeService;
|
|||
import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||
|
||||
/**
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019/3/20
|
||||
*/
|
||||
@Controller
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.List;
|
|||
import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||
|
||||
/**
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-21
|
||||
*/
|
||||
@Controller
|
||||
|
|
|
@ -24,7 +24,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
|
|||
/**
|
||||
* Blog index page controller
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-17
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -24,7 +24,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
|
|||
/**
|
||||
* Search Controller
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-04-21
|
||||
*/
|
||||
@Controller
|
||||
|
|
|
@ -12,7 +12,7 @@ import run.halo.app.service.SheetService;
|
|||
import run.halo.app.service.ThemeService;
|
||||
|
||||
/**
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-21
|
||||
*/
|
||||
@Controller
|
||||
|
|
|
@ -23,7 +23,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
|
|||
/**
|
||||
* Tag Controller
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-21
|
||||
*/
|
||||
@Controller
|
||||
|
|
|
@ -18,7 +18,7 @@ import java.io.FileNotFoundException;
|
|||
/**
|
||||
* Error page Controller
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2017/12/26
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -29,7 +29,7 @@ import static run.halo.app.model.support.HaloConst.DEFAULT_THEME_ID;
|
|||
/**
|
||||
* Installation controller.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-17
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.springframework.core.convert.converter.ConverterFactory;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019/3/14
|
||||
*/
|
||||
@Component
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.util.Objects;
|
|||
/**
|
||||
* Theme property.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-22
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.List;
|
|||
/**
|
||||
* The method executed after the application is started.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2018/12/5
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -7,7 +7,7 @@ import lombok.Data;
|
|||
/**
|
||||
* Link output dto.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019/3/21
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -7,7 +7,7 @@ import lombok.Data;
|
|||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019/3/21
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -12,7 +12,7 @@ import javax.persistence.*;
|
|||
/**
|
||||
* Attachment entity
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-12
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -11,7 +11,7 @@ import javax.persistence.*;
|
|||
/**
|
||||
* Link entity
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-12
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -11,7 +11,7 @@ import javax.persistence.*;
|
|||
/**
|
||||
* Menu entity
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-12
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Date;
|
|||
/**
|
||||
* Photo entity
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-12
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.util.Objects;
|
|||
/**
|
||||
* Post tag entity.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-12
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -11,7 +11,7 @@ import javax.persistence.*;
|
|||
/**
|
||||
* Tag entity
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-12
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.util.Date;
|
|||
/**
|
||||
* User entity
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-12
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -3,7 +3,7 @@ package run.halo.app.model.enums;
|
|||
/**
|
||||
* Attach origin.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-12
|
||||
*/
|
||||
public enum AttachmentType implements ValueEnum<Integer> {
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.springframework.stereotype.Component;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2018/12/21
|
||||
*/
|
||||
@Component
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.springframework.stereotype.Component;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2018/12/31
|
||||
*/
|
||||
@Component
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.springframework.stereotype.Component;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2018/12/31
|
||||
*/
|
||||
@Component
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Map;
|
|||
/**
|
||||
* Freemarker custom tag of category.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019/3/22
|
||||
*/
|
||||
@Component
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Map;
|
|||
/**
|
||||
* Freemarker custom tag of comment.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019/3/22
|
||||
*/
|
||||
@Component
|
||||
|
|
|
@ -15,7 +15,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
|
|||
/**
|
||||
* Freemarker custom tag of link.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019/3/22
|
||||
*/
|
||||
@Component
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Map;
|
|||
/**
|
||||
* Freemarker custom tag of menu.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019/3/22
|
||||
*/
|
||||
@Component
|
||||
|
|
|
@ -15,7 +15,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
|
|||
/**
|
||||
* Freemarker custom tag of photo.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019/4/21
|
||||
*/
|
||||
@Component
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Map;
|
|||
/**
|
||||
* Freemarker custom tag of post.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2018/4/26
|
||||
*/
|
||||
@Component
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Map;
|
|||
/**
|
||||
* Freemarker custom tag of tag.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019/3/22
|
||||
*/
|
||||
@Component
|
||||
|
|
|
@ -10,7 +10,7 @@ import javax.validation.constraints.Size;
|
|||
/**
|
||||
* Attachment params.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019/04/20
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -6,7 +6,7 @@ import run.halo.app.model.enums.AttachmentType;
|
|||
/**
|
||||
* Attachment query params.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019/04/18
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -6,7 +6,7 @@ import run.halo.app.model.enums.CommentStatus;
|
|||
/**
|
||||
* Comment query params.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019/04/18
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package run.halo.app.model.params;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Journal query params.
|
||||
*
|
||||
* @author ryanwang
|
||||
* @date : 2019/04/26
|
||||
*/
|
||||
@Data
|
||||
public class JournalQuery {
|
||||
|
||||
/**
|
||||
* Keyword.
|
||||
*/
|
||||
private String keyword;
|
||||
}
|
|
@ -10,7 +10,7 @@ import java.util.Date;
|
|||
/**
|
||||
* Post param.
|
||||
*
|
||||
* @author RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date 2019/04/25
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -5,7 +5,7 @@ import lombok.Data;
|
|||
/**
|
||||
* Photo query params.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019/04/25
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package run.halo.app.model.properties;
|
||||
|
||||
/**
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-17
|
||||
*/
|
||||
public enum BlogProperties implements PropertyEnum {
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.Date;
|
|||
* 备份信息
|
||||
* </pre>
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2018/6/4
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -5,7 +5,7 @@ package run.halo.app.model.support;
|
|||
* 公共常量
|
||||
* </pre>
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2017/12/29
|
||||
*/
|
||||
public class HaloConst {
|
||||
|
|
|
@ -5,7 +5,7 @@ package run.halo.app.model.support;
|
|||
* 日志常量
|
||||
* </pre>
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2018/1/19
|
||||
*/
|
||||
public interface LogsRecord {
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
/**
|
||||
* Theme file.
|
||||
*
|
||||
* @author RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date 2019/04/02
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
/**
|
||||
* Link team vo.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019/3/22
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -6,7 +6,7 @@ import run.halo.app.model.dto.MenuDTO;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-04-07
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
/**
|
||||
* Link team vo.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019/3/22
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package run.halo.app.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import run.halo.app.model.entity.Journal;
|
||||
import run.halo.app.repository.base.BaseRepository;
|
||||
|
||||
|
@ -9,6 +10,6 @@ import run.halo.app.repository.base.BaseRepository;
|
|||
* @author johnniang
|
||||
* @date 3/22/19
|
||||
*/
|
||||
public interface JournalRepository extends BaseRepository<Journal, Integer> {
|
||||
public interface JournalRepository extends BaseRepository<Journal, Integer>, JpaSpecificationExecutor<Journal> {
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import run.halo.app.repository.base.BasePostRepository;
|
|||
* Post repository.
|
||||
*
|
||||
* @author johnniang
|
||||
* @author RYAN0UP
|
||||
* @author ryanwang
|
||||
*/
|
||||
public interface PostRepository extends BasePostRepository<Post>, JpaSpecificationExecutor<Post> {
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import run.halo.app.model.dto.JournalDTO;
|
|||
import run.halo.app.model.dto.JournalWithCmtCountDTO;
|
||||
import run.halo.app.model.entity.Journal;
|
||||
import run.halo.app.model.params.JournalParam;
|
||||
import run.halo.app.model.params.JournalQuery;
|
||||
import run.halo.app.service.base.CrudService;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -16,6 +17,7 @@ import java.util.List;
|
|||
* Journal service interface.
|
||||
*
|
||||
* @author johnniang
|
||||
* @author ryanwang
|
||||
* @date 19-4-24
|
||||
*/
|
||||
public interface JournalService extends CrudService<Journal, Integer> {
|
||||
|
@ -37,6 +39,16 @@ public interface JournalService extends CrudService<Journal, Integer> {
|
|||
*/
|
||||
Page<Journal> pageLatest(int top);
|
||||
|
||||
/**
|
||||
* Pages journals.
|
||||
*
|
||||
* @param journalQuery journal query must not be null
|
||||
* @param pageable page info must not be null
|
||||
* @return a page of post
|
||||
*/
|
||||
@NonNull
|
||||
Page<Journal> pageBy(@NonNull JournalQuery journalQuery, @NonNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Converts to journal dto.
|
||||
*
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.Map;
|
|||
/**
|
||||
* Mail server
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-17
|
||||
*/
|
||||
public interface MailService {
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.util.List;
|
|||
* Menu service.
|
||||
*
|
||||
* @author johnniang
|
||||
* @author RYAN0UP
|
||||
* @author ryanwang
|
||||
*/
|
||||
public interface MenuService extends CrudService<Menu, Integer> {
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.util.Set;
|
|||
* Post service.
|
||||
*
|
||||
* @author johnniang
|
||||
* @author RYAN0UP
|
||||
* @author ryanwang
|
||||
*/
|
||||
public interface PostService extends BasePostService<Post> {
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.util.Optional;
|
|||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019/3/26
|
||||
*/
|
||||
public interface ThemeService {
|
||||
|
|
|
@ -30,7 +30,7 @@ import java.util.Objects;
|
|||
/**
|
||||
* AttachmentService implementation
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-14
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.stream.Collectors;
|
|||
/**
|
||||
* CategoryService implementation class
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-14
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
package run.halo.app.service.impl;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
@ -9,22 +13,22 @@ import run.halo.app.model.dto.JournalDTO;
|
|||
import run.halo.app.model.dto.JournalWithCmtCountDTO;
|
||||
import run.halo.app.model.entity.Journal;
|
||||
import run.halo.app.model.params.JournalParam;
|
||||
import run.halo.app.model.params.JournalQuery;
|
||||
import run.halo.app.repository.JournalRepository;
|
||||
import run.halo.app.service.JournalCommentService;
|
||||
import run.halo.app.service.JournalService;
|
||||
import run.halo.app.service.base.AbstractCrudService;
|
||||
import run.halo.app.utils.ServiceUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Journal service implementation.
|
||||
*
|
||||
* @author johnniang
|
||||
* @author ryanwang
|
||||
* @date 19-4-24
|
||||
*/
|
||||
@Service
|
||||
|
@ -53,6 +57,13 @@ public class JournalServiceImpl extends AbstractCrudService<Journal, Integer> im
|
|||
return listAll(ServiceUtils.buildLatestPageable(top));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Journal> pageBy(JournalQuery journalQuery, Pageable pageable) {
|
||||
Assert.notNull(journalQuery, "Journal query must not be null");
|
||||
Assert.notNull(pageable, "Page info must not be null");
|
||||
return journalRepository.findAll(buildSpecByQuery(journalQuery), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JournalDTO convertTo(Journal journal) {
|
||||
Assert.notNull(journal, "Journal must not be null");
|
||||
|
@ -94,4 +105,30 @@ public class JournalServiceImpl extends AbstractCrudService<Journal, Integer> im
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build specification by journal query.
|
||||
*
|
||||
* @param journalQuery query query must not be null
|
||||
* @return a query specification
|
||||
*/
|
||||
@NonNull
|
||||
private Specification<Journal> buildSpecByQuery(@NonNull JournalQuery journalQuery) {
|
||||
Assert.notNull(journalQuery, "Journal query must not be null");
|
||||
|
||||
return (Specification<Journal>) (root, query, criteriaBuilder) -> {
|
||||
List<Predicate> predicates = new LinkedList<>();
|
||||
|
||||
if (journalQuery.getKeyword() != null) {
|
||||
// Format like condition
|
||||
String likeCondition = String.format("%%%s%%", StringUtils.strip(journalQuery.getKeyword()));
|
||||
|
||||
// Build like predicate
|
||||
Predicate contentLike = criteriaBuilder.like(root.get("content"), likeCondition);
|
||||
|
||||
predicates.add(criteriaBuilder.or(contentLike));
|
||||
}
|
||||
|
||||
return query.where(predicates.toArray(new Predicate[0])).getRestriction();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.stream.Collectors;
|
|||
/**
|
||||
* LinkService implementation class
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-14
|
||||
*/
|
||||
@Service
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.springframework.util.Assert;
|
|||
/**
|
||||
* LogService implementation class
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-14
|
||||
*/
|
||||
@Service
|
||||
|
|
|
@ -19,7 +19,7 @@ import java.util.Properties;
|
|||
/**
|
||||
* Mail service implementation.
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-17
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.stream.Collectors;
|
|||
/**
|
||||
* MenuService implementation class
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-14
|
||||
*/
|
||||
@Service
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.util.stream.Collectors;
|
|||
/**
|
||||
* OptionService implementation class
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-14
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.util.stream.Collectors;
|
|||
/**
|
||||
* PhotoService implementation class
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-14
|
||||
*/
|
||||
@Service
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.stream.Collectors;
|
|||
/**
|
||||
* PostCommentService implementation class
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-14
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -41,7 +41,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
|
|||
* Post service implementation.
|
||||
*
|
||||
* @author johnniang
|
||||
* @author RYAN0UP
|
||||
* @author ryanwang
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
|
|
|
@ -19,7 +19,7 @@ import java.util.stream.Collectors;
|
|||
/**
|
||||
* TagService implementation class
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-14
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -51,7 +51,7 @@ import java.util.zip.ZipInputStream;
|
|||
import static run.halo.app.model.support.HaloConst.DEFAULT_THEME_ID;
|
||||
|
||||
/**
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019/3/26
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -32,7 +32,7 @@ import java.util.concurrent.TimeUnit;
|
|||
/**
|
||||
* UserService implementation class
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2019-03-14
|
||||
*/
|
||||
@Service
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.UUID;
|
|||
* 常用工具
|
||||
* </pre>
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2017/12/22
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -17,7 +17,7 @@ import java.util.Set;
|
|||
/**
|
||||
* Markdown utils
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2018/11/14
|
||||
*/
|
||||
public class MarkdownUtils {
|
||||
|
|
|
@ -3,7 +3,7 @@ package run.halo.app.utils;
|
|||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author : RYAN0UP
|
||||
* @author ryanwang
|
||||
* @date : 2017/12/26
|
||||
* @version : 1.0
|
||||
* description:
|
||||
|
|
Loading…
Reference in New Issue