Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
IEQEFCR
halo
提交
da524058
H
halo
项目概览
IEQEFCR
/
halo
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
halo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
da524058
编写于
4月 25, 2019
作者:
J
johnniang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove useless post dtos
上级
16476f5a
变更
16
显示空白变更内容
内联
并排
Showing
16 changed file
with
40 addition
and
188 deletion
+40
-188
src/main/java/run/halo/app/controller/content/api/TagController.java
...va/run/halo/app/controller/content/api/TagController.java
+18
-10
src/main/java/run/halo/app/model/dto/base/OutputConverter.java
...ain/java/run/halo/app/model/dto/base/OutputConverter.java
+1
-1
src/main/java/run/halo/app/model/dto/post/PostDetailDTO.java
src/main/java/run/halo/app/model/dto/post/PostDetailDTO.java
+0
-21
src/main/java/run/halo/app/model/dto/post/PostMinimalDTO.java
...main/java/run/halo/app/model/dto/post/PostMinimalDTO.java
+0
-39
src/main/java/run/halo/app/model/dto/post/PostSimpleDTO.java
src/main/java/run/halo/app/model/dto/post/PostSimpleDTO.java
+0
-37
src/main/java/run/halo/app/model/dto/post/SheetDetailDTO.java
...main/java/run/halo/app/model/dto/post/SheetDetailDTO.java
+0
-12
src/main/java/run/halo/app/model/dto/post/SheetMinimalDTO.java
...ain/java/run/halo/app/model/dto/post/SheetMinimalDTO.java
+0
-11
src/main/java/run/halo/app/model/dto/post/SheetSimpleDTO.java
...main/java/run/halo/app/model/dto/post/SheetSimpleDTO.java
+0
-11
src/main/java/run/halo/app/model/vo/ArchiveYearVO.java
src/main/java/run/halo/app/model/vo/ArchiveYearVO.java
+2
-2
src/main/java/run/halo/app/model/vo/PostCommentWithPostVO.java
...ain/java/run/halo/app/model/vo/PostCommentWithPostVO.java
+2
-2
src/main/java/run/halo/app/model/vo/PostDetailVO.java
src/main/java/run/halo/app/model/vo/PostDetailVO.java
+1
-2
src/main/java/run/halo/app/service/PostService.java
src/main/java/run/halo/app/service/PostService.java
+0
-2
src/main/java/run/halo/app/service/SheetService.java
src/main/java/run/halo/app/service/SheetService.java
+1
-2
src/main/java/run/halo/app/service/impl/PostCommentServiceImpl.java
...ava/run/halo/app/service/impl/PostCommentServiceImpl.java
+12
-10
src/main/java/run/halo/app/service/impl/PostServiceImpl.java
src/main/java/run/halo/app/service/impl/PostServiceImpl.java
+2
-24
src/main/java/run/halo/app/service/impl/SheetServiceImpl.java
...main/java/run/halo/app/service/impl/SheetServiceImpl.java
+1
-2
未找到文件。
src/main/java/run/halo/app/controller/content/api/TagController.java
浏览文件 @
da524058
package
run.halo.app.controller.content.api
;
import
run.halo.app.model.dto.TagDTO
;
import
run.halo.app.model.dto.post.PostSimpleDTO
;
import
run.halo.app.model.entity.Tag
;
import
run.halo.app.service.PostTagService
;
import
run.halo.app.service.TagService
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.data.domain.Page
;
...
...
@@ -13,6 +8,13 @@ import org.springframework.data.domain.Sort;
import
org.springframework.data.web.PageableDefault
;
import
org.springframework.data.web.SortDefault
;
import
org.springframework.web.bind.annotation.*
;
import
run.halo.app.model.dto.TagDTO
;
import
run.halo.app.model.dto.post.BasePostSimpleDTO
;
import
run.halo.app.model.entity.Post
;
import
run.halo.app.model.entity.Tag
;
import
run.halo.app.service.PostService
;
import
run.halo.app.service.PostTagService
;
import
run.halo.app.service.TagService
;
import
java.util.List
;
...
...
@@ -32,9 +34,14 @@ public class TagController {
private
final
PostTagService
postTagService
;
public
TagController
(
TagService
tagService
,
PostTagService
postTagService
)
{
private
final
PostService
postService
;
public
TagController
(
TagService
tagService
,
PostTagService
postTagService
,
PostService
postService
)
{
this
.
tagService
=
tagService
;
this
.
postTagService
=
postTagService
;
this
.
postService
=
postService
;
}
@GetMapping
...
...
@@ -50,12 +57,13 @@ public class TagController {
@GetMapping
(
"{slugName}/posts"
)
@ApiOperation
(
"Lists posts by tag slug name"
)
public
Page
<
PostSimpleDTO
>
listPostsBy
(
@PathVariable
(
"slugName"
)
String
slugName
,
public
Page
<
Base
PostSimpleDTO
>
listPostsBy
(
@PathVariable
(
"slugName"
)
String
slugName
,
@PageableDefault
(
sort
=
"updateTime"
,
direction
=
DESC
)
Pageable
pageable
)
{
// Get tag by slug name
Tag
tag
=
tagService
.
getBySlugNameOfNonNull
(
slugName
);
// Get posts, convert and return
return
postTagService
.
pagePostsBy
(
tag
.
getId
(),
pageable
).
map
(
post
->
new
PostSimpleDTO
().
convertFrom
(
post
));
Page
<
Post
>
postPage
=
postTagService
.
pagePostsBy
(
tag
.
getId
(),
pageable
);
return
postService
.
convertToSimple
(
postPage
);
}
}
src/main/java/run/halo/app/model/dto/base/OutputConverter.java
浏览文件 @
da524058
...
...
@@ -23,7 +23,7 @@ public interface OutputConverter<DTO extends OutputConverter<DTO, DOMAIN>, DOMAI
*/
@SuppressWarnings
(
"unchecked"
)
@NonNull
default
<
T
extends
DTO
>
T
convertFrom
(
DOMAIN
domain
)
{
default
<
T
extends
DTO
>
T
convertFrom
(
@NonNull
DOMAIN
domain
)
{
updateProperties
(
domain
,
this
);
...
...
src/main/java/run/halo/app/model/dto/post/PostDetailDTO.java
已删除
100644 → 0
浏览文件 @
16476f5a
package
run.halo.app.model.dto.post
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.ToString
;
/**
* Post detail output dto.
*
* @author johnniang
*/
@Data
@ToString
@EqualsAndHashCode
(
callSuper
=
true
)
@Deprecated
public
class
PostDetailDTO
extends
PostSimpleDTO
{
private
String
originalContent
;
private
String
formatContent
;
}
src/main/java/run/halo/app/model/dto/post/PostMinimalDTO.java
已删除
100644 → 0
浏览文件 @
16476f5a
package
run.halo.app.model.dto.post
;
import
run.halo.app.model.dto.base.OutputConverter
;
import
run.halo.app.model.entity.BasePost
;
import
run.halo.app.model.enums.PostStatus
;
import
run.halo.app.model.enums.PostType
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.ToString
;
import
java.util.Date
;
/**
* Post minimal output dto.
*
* @author johnniang
*/
@Data
@ToString
@EqualsAndHashCode
@Deprecated
public
class
PostMinimalDTO
implements
OutputConverter
<
PostMinimalDTO
,
BasePost
>
{
private
Integer
id
;
private
String
title
;
private
PostStatus
status
;
private
String
url
;
private
PostType
type
;
private
Date
updateTime
;
private
Date
createTime
;
private
Date
editTime
;
}
src/main/java/run/halo/app/model/dto/post/PostSimpleDTO.java
已删除
100644 → 0
浏览文件 @
16476f5a
package
run.halo.app.model.dto.post
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.ToString
;
import
run.halo.app.model.enums.PostCreateFrom
;
import
run.halo.app.model.enums.PostType
;
/**
* Page simple output dto.
*
* @author johnniang
*/
@Data
@ToString
@EqualsAndHashCode
(
callSuper
=
true
)
@Deprecated
public
class
PostSimpleDTO
extends
PostMinimalDTO
{
private
PostType
type
;
private
String
summary
;
private
String
thumbnail
;
private
Long
visits
=
0L
;
private
Boolean
disallowComment
;
private
String
template
;
private
Integer
topPriority
=
0
;
private
PostCreateFrom
createFrom
;
private
Long
likes
=
0L
;
}
src/main/java/run/halo/app/model/dto/post/SheetDetailDTO.java
已删除
100644 → 0
浏览文件 @
16476f5a
package
run.halo.app.model.dto.post
;
/**
* Simple detail dto.
*
* @author johnniang
* @date 19-4-24
*/
@Deprecated
public
class
SheetDetailDTO
extends
PostDetailDTO
{
}
src/main/java/run/halo/app/model/dto/post/SheetMinimalDTO.java
已删除
100644 → 0
浏览文件 @
16476f5a
package
run.halo.app.model.dto.post
;
/**
* Sheet minimal dto
*
* @author johnniang
* @date 19-4-24
*/
@Deprecated
public
class
SheetMinimalDTO
extends
PostMinimalDTO
{
}
src/main/java/run/halo/app/model/dto/post/SheetSimpleDTO.java
已删除
100644 → 0
浏览文件 @
16476f5a
package
run.halo.app.model.dto.post
;
/**
* Sheet simple dto.
*
* @author johnniang
* @date 19-4-24
*/
@Deprecated
public
class
SheetSimpleDTO
extends
PostSimpleDTO
{
}
src/main/java/run/halo/app/model/vo/ArchiveYearVO.java
浏览文件 @
da524058
package
run.halo.app.model.vo
;
import
run.halo.app.model.dto.post.PostMinimalDTO
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.ToString
;
import
run.halo.app.model.dto.post.BasePostMinimalDTO
;
import
java.util.Comparator
;
import
java.util.List
;
...
...
@@ -21,7 +21,7 @@ public class ArchiveYearVO {
private
Integer
year
;
private
List
<
PostMinimalDTO
>
posts
;
private
List
<
Base
PostMinimalDTO
>
posts
;
public
static
class
ArchiveComparator
implements
Comparator
<
ArchiveYearVO
>
{
...
...
src/main/java/run/halo/app/model/vo/PostCommentWithPostVO.java
浏览文件 @
da524058
...
...
@@ -4,7 +4,7 @@ import lombok.Data;
import
lombok.EqualsAndHashCode
;
import
lombok.ToString
;
import
run.halo.app.model.dto.BaseCommentDTO
;
import
run.halo.app.model.dto.post.PostMinimalDTO
;
import
run.halo.app.model.dto.post.
Base
PostMinimalDTO
;
/**
* PostComment list with post vo.
...
...
@@ -16,5 +16,5 @@ import run.halo.app.model.dto.post.PostMinimalDTO;
@EqualsAndHashCode
(
callSuper
=
true
)
public
class
PostCommentWithPostVO
extends
BaseCommentDTO
{
private
PostMinimalDTO
post
;
private
Base
PostMinimalDTO
post
;
}
src/main/java/run/halo/app/model/vo/PostDetailVO.java
浏览文件 @
da524058
package
run.halo.app.model.vo
;
import
run.halo.app.model.dto.post.BasePostDetailDTO
;
import
run.halo.app.model.dto.post.PostDetailDTO
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
run.halo.app.model.dto.post.BasePostDetailDTO
;
import
java.util.Set
;
...
...
src/main/java/run/halo/app/service/PostService.java
浏览文件 @
da524058
...
...
@@ -4,8 +4,6 @@ import org.springframework.data.domain.Page;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.lang.NonNull
;
import
org.springframework.transaction.annotation.Transactional
;
import
run.halo.app.model.dto.post.PostMinimalDTO
;
import
run.halo.app.model.dto.post.PostSimpleDTO
;
import
run.halo.app.model.entity.Post
;
import
run.halo.app.model.enums.PostStatus
;
import
run.halo.app.model.params.PostQuery
;
...
...
src/main/java/run/halo/app/service/SheetService.java
浏览文件 @
da524058
...
...
@@ -2,10 +2,9 @@ package run.halo.app.service;
import
org.springframework.data.domain.Page
;
import
org.springframework.lang.NonNull
;
import
run.halo.app.model.dto.post.SheetDetailDTO
;
import
run.halo.app.model.vo.SheetListVO
;
import
run.halo.app.model.entity.Sheet
;
import
run.halo.app.model.enums.PostStatus
;
import
run.halo.app.model.vo.SheetListVO
;
import
run.halo.app.service.base.BasePostService
;
/**
...
...
src/main/java/run/halo/app/service/impl/PostCommentServiceImpl.java
浏览文件 @
da524058
...
...
@@ -8,14 +8,14 @@ import org.springframework.stereotype.Service;
import
org.springframework.util.Assert
;
import
org.springframework.util.CollectionUtils
;
import
run.halo.app.exception.NotFoundException
;
import
run.halo.app.model.dto.post.PostMinimalDTO
;
import
run.halo.app.model.entity.PostComment
;
import
run.halo.app.model.dto.post.BasePostMinimalDTO
;
import
run.halo.app.model.entity.Post
;
import
run.halo.app.model.entity.PostComment
;
import
run.halo.app.model.vo.PostCommentWithPostVO
;
import
run.halo.app.repository.PostCommentRepository
;
import
run.halo.app.repository.PostRepository
;
import
run.halo.app.service.PostCommentService
;
import
run.halo.app.service.OptionService
;
import
run.halo.app.service.PostCommentService
;
import
run.halo.app.utils.ServiceUtils
;
import
java.util.Collections
;
...
...
@@ -67,12 +67,14 @@ public class PostCommentServiceImpl extends BaseCommentServiceImpl<PostComment>
// Get all posts
Map
<
Integer
,
Post
>
postMap
=
ServiceUtils
.
convertToMap
(
postRepository
.
findAllById
(
postIds
),
Post:
:
getId
);
return
postComments
.
stream
().
map
(
comment
->
{
return
postComments
.
stream
()
.
filter
(
comment
->
postMap
.
containsKey
(
comment
.
getPostId
()))
.
map
(
comment
->
{
// Convert to vo
PostCommentWithPostVO
postCommentWithPostVO
=
new
PostCommentWithPostVO
().
convertFrom
(
comment
);
// Get post and set to the vo
postCommentWithPostVO
.
setPost
(
new
PostMinimalDTO
().
convertFrom
(
postMap
.
get
(
comment
.
getPostId
())));
postCommentWithPostVO
.
setPost
(
new
Base
PostMinimalDTO
().
convertFrom
(
postMap
.
get
(
comment
.
getPostId
())));
return
postCommentWithPostVO
;
}).
collect
(
Collectors
.
toList
());
...
...
src/main/java/run/halo/app/service/impl/PostServiceImpl.java
浏览文件 @
da524058
...
...
@@ -11,13 +11,10 @@ import org.springframework.lang.NonNull;
import
org.springframework.lang.Nullable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.Assert
;
import
org.springframework.util.CollectionUtils
;
import
run.halo.app.event.logger.LogEvent
;
import
run.halo.app.event.post.PostVisitEvent
;
import
run.halo.app.model.dto.CategoryDTO
;
import
run.halo.app.model.dto.TagDTO
;
import
run.halo.app.model.dto.post.PostMinimalDTO
;
import
run.halo.app.model.dto.post.PostSimpleDTO
;
import
run.halo.app.model.entity.*
;
import
run.halo.app.model.enums.LogType
;
import
run.halo.app.model.enums.PostStatus
;
...
...
@@ -240,7 +237,7 @@ public class PostServiceImpl extends BasePostServiceImpl<Post> implements PostSe
// Build archive
ArchiveYearVO
archive
=
new
ArchiveYearVO
();
archive
.
setYear
(
year
);
archive
.
setPosts
(
convertTo
(
postList
));
archive
.
setPosts
(
convertTo
Minimal
(
postList
));
// Add archive
archives
.
add
(
archive
);
...
...
@@ -274,7 +271,7 @@ public class PostServiceImpl extends BasePostServiceImpl<Post> implements PostSe
ArchiveMonthVO
archive
=
new
ArchiveMonthVO
();
archive
.
setYear
(
year
);
archive
.
setMonth
(
month
);
archive
.
setPosts
(
convertTo
(
postList
));
archive
.
setPosts
(
convertTo
Minimal
(
postList
));
archives
.
add
(
archive
);
}));
...
...
@@ -333,7 +330,6 @@ public class PostServiceImpl extends BasePostServiceImpl<Post> implements PostSe
// Get comment count
Map
<
Integer
,
Long
>
commentCountMap
=
postCommentService
.
countByPostIds
(
postIds
);
return
postPage
.
map
(
post
->
{
PostListVO
postListVO
=
new
PostListVO
().
convertFrom
(
post
);
...
...
@@ -362,24 +358,6 @@ public class PostServiceImpl extends BasePostServiceImpl<Post> implements PostSe
});
}
/**
* Converts to post minimal output dto.
*
* @param posts a list of post
* @return a list of post minimal output dto
*/
@NonNull
private
List
<
PostMinimalDTO
>
convertTo
(
@NonNull
List
<
Post
>
posts
)
{
if
(
CollectionUtils
.
isEmpty
(
posts
))
{
return
Collections
.
emptyList
();
}
// Convert
return
posts
.
stream
()
.
map
(
post
->
new
PostMinimalDTO
().<
PostMinimalDTO
>
convertFrom
(
post
))
.
collect
(
Collectors
.
toList
());
}
/**
* Converts to post detail vo.
*
...
...
src/main/java/run/halo/app/service/impl/SheetServiceImpl.java
浏览文件 @
da524058
...
...
@@ -6,10 +6,9 @@ import org.springframework.data.domain.Pageable;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.Assert
;
import
run.halo.app.event.post.SheetVisitEvent
;
import
run.halo.app.model.dto.post.SheetDetailDTO
;
import
run.halo.app.model.vo.SheetListVO
;
import
run.halo.app.model.entity.Sheet
;
import
run.halo.app.model.enums.PostStatus
;
import
run.halo.app.model.vo.SheetListVO
;
import
run.halo.app.repository.SheetRepository
;
import
run.halo.app.service.SheetCommentService
;
import
run.halo.app.service.SheetService
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录