mirror of https://github.com/halo-dev/halo
Fixed migrate from v0.4.4 api.
parent
ab069efefd
commit
ecdc38a19f
|
@ -85,7 +85,7 @@ public class ContentCategoryController {
|
||||||
@PathVariable("page") Integer page,
|
@PathVariable("page") Integer page,
|
||||||
@SortDefault(sort = "createTime", direction = DESC) Sort sort) {
|
@SortDefault(sort = "createTime", direction = DESC) Sort sort) {
|
||||||
// Get category by slug name
|
// Get category by slug name
|
||||||
final Category category = categoryService.getBySlugName(slugName);
|
final Category category = categoryService.getBySlugNameOfNonNull(slugName);
|
||||||
|
|
||||||
final Pageable pageable = PageRequest.of(page - 1, optionService.getPostPageSize(), sort);
|
final Pageable pageable = PageRequest.of(page - 1, optionService.getPostPageSize(), sort);
|
||||||
Page<Post> postPage = postCategoryService.pagePostBy(category.getId(), pageable);
|
Page<Post> postPage = postCategoryService.pagePostBy(category.getId(), pageable);
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class CategoryController {
|
||||||
public Page<BasePostSimpleDTO> listPostsBy(@PathVariable("slugName") String slugName,
|
public Page<BasePostSimpleDTO> listPostsBy(@PathVariable("slugName") String slugName,
|
||||||
@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable) {
|
@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable) {
|
||||||
// Get category by slug name
|
// Get category by slug name
|
||||||
Category category = categoryService.getBySlugName(slugName);
|
Category category = categoryService.getBySlugNameOfNonNull(slugName);
|
||||||
|
|
||||||
Page<Post> postPage = postCategoryService.pagePostBy(category.getId(), pageable);
|
Page<Post> postPage = postCategoryService.pagePostBy(category.getId(), pageable);
|
||||||
return postService.convertToSimple(postPage);
|
return postService.convertToSimple(postPage);
|
||||||
|
|
|
@ -7,11 +7,11 @@ import run.halo.app.model.params.LoginParam;
|
||||||
import run.halo.app.security.token.AuthToken;
|
import run.halo.app.security.token.AuthToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Admin service.
|
* Admin service interface.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date 19-4-29
|
* @date 2019-04-29
|
||||||
*/
|
*/
|
||||||
public interface AdminService {
|
public interface AdminService {
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.util.List;
|
||||||
* Attachment service.
|
* Attachment service.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
|
* @date : 2019-03-14
|
||||||
*/
|
*/
|
||||||
public interface AttachmentService extends CrudService<Attachment, Integer> {
|
public interface AttachmentService extends CrudService<Attachment, Integer> {
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.io.IOException;
|
||||||
* Backup service interface.
|
* Backup service interface.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @date 19-4-26
|
* @date 2019-04-26
|
||||||
*/
|
*/
|
||||||
public interface BackupService {
|
public interface BackupService {
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@ import java.util.List;
|
||||||
* Category service.
|
* Category service.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
|
* @author ryanwang
|
||||||
|
* @date : 2019-03-14
|
||||||
*/
|
*/
|
||||||
public interface CategoryService extends CrudService<Category, Integer> {
|
public interface CategoryService extends CrudService<Category, Integer> {
|
||||||
|
|
||||||
|
@ -36,6 +38,15 @@ public interface CategoryService extends CrudService<Category, Integer> {
|
||||||
@NonNull
|
@NonNull
|
||||||
Category getBySlugName(@NonNull String slugName);
|
Category getBySlugName(@NonNull String slugName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get category by slug name
|
||||||
|
*
|
||||||
|
* @param slugName slug name
|
||||||
|
* @return Category
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
Category getBySlugNameOfNonNull(String slugName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Category by name.
|
* Get Category by name.
|
||||||
*
|
*
|
||||||
|
|
|
@ -13,7 +13,7 @@ import java.util.List;
|
||||||
* Journal comment service interface.
|
* Journal comment service interface.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @date 19-4-25
|
* @date 2019-04-25
|
||||||
*/
|
*/
|
||||||
public interface JournalCommentService extends BaseCommentService<JournalComment> {
|
public interface JournalCommentService extends BaseCommentService<JournalComment> {
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import java.util.List;
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date 19-4-24
|
* @date 2019-04-24
|
||||||
*/
|
*/
|
||||||
public interface JournalService extends CrudService<Journal, Integer> {
|
public interface JournalService extends CrudService<Journal, Integer> {
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,10 @@ import run.halo.app.service.base.CrudService;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Link service.
|
* Link service interface.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
|
* @date 2019-03-14
|
||||||
*/
|
*/
|
||||||
public interface LinkService extends CrudService<Link, Integer> {
|
public interface LinkService extends CrudService<Link, Integer> {
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,10 @@ import run.halo.app.model.entity.Log;
|
||||||
import run.halo.app.service.base.CrudService;
|
import run.halo.app.service.base.CrudService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log service.
|
* Log service interface.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
|
* @date 2019-03-14
|
||||||
*/
|
*/
|
||||||
public interface LogService extends CrudService<Log, Long> {
|
public interface LogService extends CrudService<Log, Long> {
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,10 @@ package run.halo.app.service;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mail server
|
* Mail service interface.
|
||||||
*
|
*
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date : 2019-03-17
|
* @date 2019-03-17
|
||||||
*/
|
*/
|
||||||
public interface MailService {
|
public interface MailService {
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,11 @@ import run.halo.app.service.base.CrudService;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Menu service.
|
* Menu service interface.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
|
* @date 2019-03-14
|
||||||
*/
|
*/
|
||||||
public interface MenuService extends CrudService<Menu, Integer> {
|
public interface MenuService extends CrudService<Menu, Integer> {
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,10 @@ import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Option service.
|
* Option service interface.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
|
* @date 2019-03-14
|
||||||
*/
|
*/
|
||||||
public interface OptionService extends CrudService<Option, Integer> {
|
public interface OptionService extends CrudService<Option, Integer> {
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,10 @@ import run.halo.app.service.base.CrudService;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Photo service.
|
* Photo service interface.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
|
* @date 2019-03-14
|
||||||
*/
|
*/
|
||||||
public interface PhotoService extends CrudService<Photo, Integer> {
|
public interface PhotoService extends CrudService<Photo, Integer> {
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.util.Set;
|
||||||
* Post category service interface.
|
* Post category service interface.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @date 3/19/19
|
* @date 2019-03-19
|
||||||
*/
|
*/
|
||||||
public interface PostCategoryService extends CrudService<PostCategory, Integer> {
|
public interface PostCategoryService extends CrudService<PostCategory, Integer> {
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,10 @@ import run.halo.app.service.base.BaseCommentService;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PostComment service.
|
* Post comment service interface.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
|
* @date 2019-03-14
|
||||||
*/
|
*/
|
||||||
public interface PostCommentService extends BaseCommentService<PostComment> {
|
public interface PostCommentService extends BaseCommentService<PostComment> {
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,11 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Post service.
|
* Post service interface.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
|
* @date 2019-03-14
|
||||||
*/
|
*/
|
||||||
public interface PostService extends BasePostService<Post> {
|
public interface PostService extends BasePostService<Post> {
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.util.Set;
|
||||||
* Post tag service interface.
|
* Post tag service interface.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @date 3/19/19
|
* @date 2019-03-19
|
||||||
*/
|
*/
|
||||||
public interface PostTagService extends CrudService<PostTag, Integer> {
|
public interface PostTagService extends CrudService<PostTag, Integer> {
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||||
* Recovery service interface.
|
* Recovery service interface.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @date 19-4-26
|
* @date 2019-04-26
|
||||||
*/
|
*/
|
||||||
public interface RecoveryService {
|
public interface RecoveryService {
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import java.util.List;
|
||||||
* Sheet comment service interface.
|
* Sheet comment service interface.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @date 19-4-24
|
* @date 2019-04-24
|
||||||
*/
|
*/
|
||||||
public interface SheetCommentService extends BaseCommentService<SheetComment> {
|
public interface SheetCommentService extends BaseCommentService<SheetComment> {
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ import java.util.List;
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date 19-4-24
|
* @date 2019-04-24
|
||||||
*/
|
*/
|
||||||
public interface SheetService extends BasePostService<Sheet> {
|
public interface SheetService extends BasePostService<Sheet> {
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,12 @@ import run.halo.app.service.base.CrudService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tag service.
|
* Tag service interface.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
|
* @author ryanwang
|
||||||
|
* @date 2019-03-14
|
||||||
*/
|
*/
|
||||||
public interface TagService extends CrudService<Tag, Integer> {
|
public interface TagService extends CrudService<Tag, Integer> {
|
||||||
|
|
||||||
|
@ -25,6 +26,15 @@ public interface TagService extends CrudService<Tag, Integer> {
|
||||||
@NonNull
|
@NonNull
|
||||||
Tag getBySlugNameOfNonNull(@NonNull String slugName);
|
Tag getBySlugNameOfNonNull(@NonNull String slugName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get tag by slug name
|
||||||
|
*
|
||||||
|
* @param slugName slug name
|
||||||
|
* @return tag
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
Tag getBySlugName(@NonNull String slugName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get tag by tag name.
|
* Get tag by tag name.
|
||||||
*
|
*
|
||||||
|
|
|
@ -14,8 +14,10 @@ import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Theme service interface.
|
||||||
|
*
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date : 2019/3/26
|
* @date 2019-03-26
|
||||||
*/
|
*/
|
||||||
public interface ThemeService {
|
public interface ThemeService {
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Map;
|
||||||
* Theme setting service interface.
|
* Theme setting service interface.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @date 4/8/19
|
* @date 2019-04-08
|
||||||
*/
|
*/
|
||||||
public interface ThemeSettingService {
|
public interface ThemeSettingService {
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.util.List;
|
||||||
* Trace service interface.
|
* Trace service interface.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @date 19-6-18
|
* @date 2019-06-18
|
||||||
*/
|
*/
|
||||||
public interface TraceService {
|
public interface TraceService {
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,10 @@ import run.halo.app.service.base.CrudService;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User service.
|
* User service interface.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
|
* @date 2019-03-14
|
||||||
*/
|
*/
|
||||||
public interface UserService extends CrudService<User, Integer> {
|
public interface UserService extends CrudService<User, Integer> {
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ import static run.halo.app.model.support.HaloConst.*;
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date 19-4-29
|
* @date 2019-04-29
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
|
|
|
@ -32,6 +32,7 @@ import java.util.Objects;
|
||||||
* AttachmentService implementation
|
* AttachmentService implementation
|
||||||
*
|
*
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
|
* @author johnniang
|
||||||
* @date : 2019-03-14
|
* @date : 2019-03-14
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
|
|
@ -14,7 +14,7 @@ import java.nio.charset.StandardCharsets;
|
||||||
* Backup service implementation.
|
* Backup service implementation.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @date 19-4-26
|
* @date 2019-04-26
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class BackupServiceImpl implements BackupService {
|
public class BackupServiceImpl implements BackupService {
|
||||||
|
|
|
@ -51,7 +51,7 @@ import java.util.stream.Collectors;
|
||||||
* Base comment service implementation.
|
* Base comment service implementation.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @date 19-4-24
|
* @date 2019-04-24
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public abstract class BaseCommentServiceImpl<COMMENT extends BaseComment> extends AbstractCrudService<COMMENT, Long> implements BaseCommentService<COMMENT> {
|
public abstract class BaseCommentServiceImpl<COMMENT extends BaseComment> extends AbstractCrudService<COMMENT, Long> implements BaseCommentService<COMMENT> {
|
||||||
|
|
|
@ -40,7 +40,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||||
* Base post service implementation.
|
* Base post service implementation.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @date 19-4-24
|
* @date 2019-04-24
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public abstract class BasePostServiceImpl<POST extends BasePost> extends AbstractCrudService<POST, Integer> implements BasePostService<POST> {
|
public abstract class BasePostServiceImpl<POST extends BasePost> extends AbstractCrudService<POST, Integer> implements BasePostService<POST> {
|
||||||
|
|
|
@ -24,9 +24,10 @@ import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CategoryService implementation class
|
* CategoryService implementation class.
|
||||||
*
|
*
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
|
* @author johnniang
|
||||||
* @date : 2019-03-14
|
* @date : 2019-03-14
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@ -146,7 +147,12 @@ public class CategoryServiceImpl extends AbstractCrudService<Category, Integer>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Category getBySlugName(String slugName) {
|
public Category getBySlugName(String slugName) {
|
||||||
return categoryRepository.getBySlugName(slugName).orElseThrow(() -> new NotFoundException("该分类已存在").setErrorData(slugName));
|
return categoryRepository.getBySlugName(slugName).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Category getBySlugNameOfNonNull(String slugName) {
|
||||||
|
return categoryRepository.getBySlugName(slugName).orElseThrow(() -> new NotFoundException("该分类不存在").setErrorData(slugName));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,7 +28,7 @@ import java.util.stream.Collectors;
|
||||||
* Journal comment service implementation.
|
* Journal comment service implementation.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @date 19-4-25
|
* @date 2019-04-25
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class JournalCommentServiceImpl extends BaseCommentServiceImpl<JournalComment> implements JournalCommentService {
|
public class JournalCommentServiceImpl extends BaseCommentServiceImpl<JournalComment> implements JournalCommentService {
|
||||||
|
|
|
@ -29,7 +29,7 @@ import java.util.stream.Collectors;
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date 19-4-24
|
* @date 2019-04-24
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class JournalServiceImpl extends AbstractCrudService<Journal, Integer> implements JournalService {
|
public class JournalServiceImpl extends AbstractCrudService<Journal, Integer> implements JournalService {
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.stream.Collectors;
|
||||||
* LinkService implementation class
|
* LinkService implementation class
|
||||||
*
|
*
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date : 2019-03-14
|
* @date 2019-03-14
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class LinkServiceImpl extends AbstractCrudService<Link, Integer> implements LinkService {
|
public class LinkServiceImpl extends AbstractCrudService<Link, Integer> implements LinkService {
|
||||||
|
|
|
@ -15,7 +15,7 @@ import run.halo.app.service.base.AbstractCrudService;
|
||||||
* LogService implementation class
|
* LogService implementation class
|
||||||
*
|
*
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date : 2019-03-14
|
* @date 2019-03-14
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class LogServiceImpl extends AbstractCrudService<Log, Long> implements LogService {
|
public class LogServiceImpl extends AbstractCrudService<Log, Long> implements LogService {
|
||||||
|
|
|
@ -20,7 +20,7 @@ import java.util.Properties;
|
||||||
* Mail service implementation.
|
* Mail service implementation.
|
||||||
*
|
*
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date : 2019-03-17
|
* @date 2019-03-17
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
|
|
|
@ -21,10 +21,10 @@ import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MenuService implementation class
|
* MenuService implementation class.
|
||||||
*
|
*
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date : 2019-03-14
|
* @date 2019-03-14
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class MenuServiceImpl extends AbstractCrudService<Menu, Integer> implements MenuService {
|
public class MenuServiceImpl extends AbstractCrudService<Menu, Integer> implements MenuService {
|
||||||
|
|
|
@ -30,7 +30,7 @@ import java.util.*;
|
||||||
* OptionService implementation class
|
* OptionService implementation class
|
||||||
*
|
*
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date : 2019-03-14
|
* @date 2019-03-14
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
|
|
|
@ -29,7 +29,7 @@ import java.util.stream.Collectors;
|
||||||
* PhotoService implementation class
|
* PhotoService implementation class
|
||||||
*
|
*
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date : 2019-03-14
|
* @date 2019-03-14
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class PhotoServiceImpl extends AbstractCrudService<Photo, Integer> implements PhotoService {
|
public class PhotoServiceImpl extends AbstractCrudService<Photo, Integer> implements PhotoService {
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.stream.Collectors;
|
||||||
* Post category service implementation.
|
* Post category service implementation.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @date 3/19/19
|
* @date 2019-03-19
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class PostCategoryServiceImpl extends AbstractCrudService<PostCategory, Integer> implements PostCategoryService {
|
public class PostCategoryServiceImpl extends AbstractCrudService<PostCategory, Integer> implements PostCategoryService {
|
||||||
|
|
|
@ -32,7 +32,8 @@ import java.util.stream.Collectors;
|
||||||
* PostCommentService implementation class
|
* PostCommentService implementation class
|
||||||
*
|
*
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date : 2019-03-14
|
* @author johnniang
|
||||||
|
* @date 2019-03-14
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
|
|
|
@ -45,6 +45,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
|
* @date 2019-03-14
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.stream.Collectors;
|
||||||
* Post tag service implementation.
|
* Post tag service implementation.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @date 3/19/19
|
* @date 2019-03-19
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class PostTagServiceImpl extends AbstractCrudService<PostTag, Integer> implements PostTagService {
|
public class PostTagServiceImpl extends AbstractCrudService<PostTag, Integer> implements PostTagService {
|
||||||
|
|
|
@ -33,7 +33,8 @@ import java.util.stream.Collectors;
|
||||||
* Recovery service implementation.
|
* Recovery service implementation.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @date 19-4-26
|
* @author ryanwang
|
||||||
|
* @date 2019-04-26
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
|
@ -64,6 +65,10 @@ public class RecoveryServiceImpl implements RecoveryService {
|
||||||
|
|
||||||
private final PhotoService photoService;
|
private final PhotoService photoService;
|
||||||
|
|
||||||
|
private final PostCategoryService postCategoryService;
|
||||||
|
|
||||||
|
private final PostTagService postTagService;
|
||||||
|
|
||||||
public RecoveryServiceImpl(AttachmentService attachmentService,
|
public RecoveryServiceImpl(AttachmentService attachmentService,
|
||||||
PostService postService,
|
PostService postService,
|
||||||
LinkService linkService,
|
LinkService linkService,
|
||||||
|
@ -75,7 +80,9 @@ public class RecoveryServiceImpl implements RecoveryService {
|
||||||
SheetCommentService sheetCommentService,
|
SheetCommentService sheetCommentService,
|
||||||
SheetCommentRepository sheetCommentRepository,
|
SheetCommentRepository sheetCommentRepository,
|
||||||
SheetService sheetService,
|
SheetService sheetService,
|
||||||
PhotoService photoService) {
|
PhotoService photoService,
|
||||||
|
PostCategoryService postCategoryService,
|
||||||
|
PostTagService postTagService) {
|
||||||
this.attachmentService = attachmentService;
|
this.attachmentService = attachmentService;
|
||||||
this.postService = postService;
|
this.postService = postService;
|
||||||
this.linkService = linkService;
|
this.linkService = linkService;
|
||||||
|
@ -88,6 +95,8 @@ public class RecoveryServiceImpl implements RecoveryService {
|
||||||
this.sheetCommentRepository = sheetCommentRepository;
|
this.sheetCommentRepository = sheetCommentRepository;
|
||||||
this.sheetService = sheetService;
|
this.sheetService = sheetService;
|
||||||
this.photoService = photoService;
|
this.photoService = photoService;
|
||||||
|
this.postCategoryService = postCategoryService;
|
||||||
|
this.postTagService = postTagService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -215,12 +224,20 @@ public class RecoveryServiceImpl implements RecoveryService {
|
||||||
Post createdPost = postService.createOrUpdateBy(post);
|
Post createdPost = postService.createOrUpdateBy(post);
|
||||||
|
|
||||||
Object commentsObject = postMap.get("comments");
|
Object commentsObject = postMap.get("comments");
|
||||||
|
Object categoriesObject = postMap.get("categories");
|
||||||
|
Object tagsObject = postMap.get("tags");
|
||||||
// Handle comments
|
// Handle comments
|
||||||
List<BaseComment> baseComments = handleComment(commentsObject, createdPost.getId());
|
List<BaseComment> baseComments = handleComment(commentsObject, createdPost.getId());
|
||||||
|
|
||||||
// TODO Handle categories
|
// Handle categories
|
||||||
|
List<Category> categories = handleCategories(categoriesObject, createdPost.getId());
|
||||||
|
|
||||||
// TODO Handle tags
|
log.debug("Migrated categories of post [{}]: [{}]", categories, createdPost.getId());
|
||||||
|
|
||||||
|
// Handle tags
|
||||||
|
List<Tag> tags = handleTags(tagsObject, createdPost.getId());
|
||||||
|
|
||||||
|
log.debug("Migrated tags of post [{}]: [{}]", tags, createdPost.getId());
|
||||||
|
|
||||||
List<PostComment> postComments = baseComments.stream()
|
List<PostComment> postComments = baseComments.stream()
|
||||||
.map(baseComment -> BeanUtils.transformFrom(baseComment, PostComment.class))
|
.map(baseComment -> BeanUtils.transformFrom(baseComment, PostComment.class))
|
||||||
|
@ -376,6 +393,96 @@ public class RecoveryServiceImpl implements RecoveryService {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private List<Category> handleCategories(@Nullable Object categoriesObject, @NonNull Integer postId) {
|
||||||
|
Assert.notNull(postId, "Post id must not be null");
|
||||||
|
|
||||||
|
if (!(categoriesObject instanceof List)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Object> categoryObjectList = (List<Object>) categoriesObject;
|
||||||
|
|
||||||
|
List<Category> result = new LinkedList<>();
|
||||||
|
|
||||||
|
categoryObjectList.forEach(categoryObject -> {
|
||||||
|
if (!(categoryObject instanceof Map)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> categoryMap = (Map<String, Object>) categoryObject;
|
||||||
|
|
||||||
|
String slugName = categoryMap.getOrDefault("cateUrl", "").toString();
|
||||||
|
|
||||||
|
Category category = categoryService.getBySlugName(slugName);
|
||||||
|
|
||||||
|
if (null == category) {
|
||||||
|
category = new Category();
|
||||||
|
category.setName(categoryMap.getOrDefault("cateName", "").toString());
|
||||||
|
category.setSlugName(slugName);
|
||||||
|
category.setDescription(categoryMap.getOrDefault("cateDesc", "").toString());
|
||||||
|
category = categoryService.create(category);
|
||||||
|
}
|
||||||
|
|
||||||
|
PostCategory postCategory = new PostCategory();
|
||||||
|
postCategory.setCategoryId(category.getId());
|
||||||
|
postCategory.setPostId(postId);
|
||||||
|
postCategoryService.create(postCategory);
|
||||||
|
|
||||||
|
try {
|
||||||
|
result.add(category);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Failed to migrate a category", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private List<Tag> handleTags(@Nullable Object tagsObject, @NonNull Integer postId) {
|
||||||
|
Assert.notNull(postId, "Post id must not be null");
|
||||||
|
|
||||||
|
if (!(tagsObject instanceof List)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Object> tagObjectList = (List<Object>) tagsObject;
|
||||||
|
|
||||||
|
List<Tag> result = new LinkedList<>();
|
||||||
|
|
||||||
|
tagObjectList.forEach(tagObject -> {
|
||||||
|
if (!(tagObject instanceof Map)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> tagMap = (Map<String, Object>) tagObject;
|
||||||
|
|
||||||
|
String slugName = tagMap.getOrDefault("tagUrl", "").toString();
|
||||||
|
|
||||||
|
Tag tag = tagService.getBySlugName(slugName);
|
||||||
|
|
||||||
|
if (null == tag) {
|
||||||
|
tag = new Tag();
|
||||||
|
tag.setName(tagMap.getOrDefault("tagName", "").toString());
|
||||||
|
tag.setSlugName(slugName);
|
||||||
|
tag = tagService.create(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
PostTag postTag = new PostTag();
|
||||||
|
postTag.setTagId(tag.getId());
|
||||||
|
postTag.setPostId(postId);
|
||||||
|
postTagService.create(postTag);
|
||||||
|
|
||||||
|
try {
|
||||||
|
result.add(tag);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Failed to migrate a tag", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private List<Menu> handleMenus(@Nullable Object menusObject) {
|
private List<Menu> handleMenus(@Nullable Object menusObject) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ import java.util.stream.Collectors;
|
||||||
* Sheet comment service implementation.
|
* Sheet comment service implementation.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @date 19-4-24
|
* @date 2019-04-24
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class SheetCommentServiceImpl extends BaseCommentServiceImpl<SheetComment> implements SheetCommentService {
|
public class SheetCommentServiceImpl extends BaseCommentServiceImpl<SheetComment> implements SheetCommentService {
|
||||||
|
|
|
@ -31,7 +31,7 @@ import java.util.Set;
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date 19-4-24
|
* @date 2019-04-24
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class SheetServiceImpl extends BasePostServiceImpl<Sheet> implements SheetService {
|
public class SheetServiceImpl extends BasePostServiceImpl<Sheet> implements SheetService {
|
||||||
|
|
|
@ -17,10 +17,11 @@ import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TagService implementation class
|
* TagService implementation class.
|
||||||
*
|
*
|
||||||
|
* @author johnniang
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date : 2019-03-14
|
* @date 2019-03-14
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
|
@ -51,9 +52,13 @@ public class TagServiceImpl extends AbstractCrudService<Tag, Integer> implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Tag getBySlugNameOfNonNull(String slugName) {
|
public Tag getBySlugNameOfNonNull(String slugName) {
|
||||||
return tagRepository.getBySlugName(slugName).orElseThrow(() -> new NotFoundException("该标签已存在").setErrorData(slugName));
|
return tagRepository.getBySlugName(slugName).orElseThrow(() -> new NotFoundException("该标签不存在").setErrorData(slugName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Tag getBySlugName(String slugName) {
|
||||||
|
return tagRepository.getBySlugName(slugName).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Tag getByName(String name) {
|
public Tag getByName(String name) {
|
||||||
|
|
|
@ -53,7 +53,7 @@ import static run.halo.app.model.support.HaloConst.DEFAULT_THEME_ID;
|
||||||
* Theme service implementation.
|
* Theme service implementation.
|
||||||
*
|
*
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date : 2019/3/26
|
* @date 2019-03-26
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.*;
|
||||||
* Theme setting service implementation.
|
* Theme setting service implementation.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @date 4/8/19
|
* @date 2019-04-08
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
|
|
|
@ -2,18 +2,16 @@ package run.halo.app.service.impl;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.trace.http.HttpTrace;
|
import org.springframework.boot.actuate.trace.http.HttpTrace;
|
||||||
import org.springframework.boot.actuate.trace.http.HttpTraceRepository;
|
import org.springframework.boot.actuate.trace.http.HttpTraceRepository;
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.PageImpl;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.Assert;
|
|
||||||
import run.halo.app.service.TraceService;
|
import run.halo.app.service.TraceService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* TraceService implementation class.
|
||||||
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @date 19-6-18
|
* @date 2019-06-18
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class TraceServiceImpl implements TraceService {
|
public class TraceServiceImpl implements TraceService {
|
||||||
|
|
|
@ -31,10 +31,11 @@ import java.util.Optional;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UserService implementation class
|
* UserService implementation class.
|
||||||
*
|
*
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date : 2019-03-14
|
* @author johnniang
|
||||||
|
* @date 2019-03-14
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class UserServiceImpl extends AbstractCrudService<User, Integer> implements UserService {
|
public class UserServiceImpl extends AbstractCrudService<User, Integer> implements UserService {
|
||||||
|
|
Loading…
Reference in New Issue