mirror of https://github.com/halo-dev/halo
Fixed freemarker directive bugs.
parent
f7fb7c7542
commit
102fb0fee8
|
@ -158,7 +158,7 @@ public class InstallController {
|
|||
Set<Integer> categoryIds = new HashSet<>();
|
||||
categoryIds.add(category.getId());
|
||||
postParam.setCategoryIds(categoryIds);
|
||||
return postService.create(postParam.convertTo());
|
||||
return postService.createOrUpdateBy(postParam.convertTo());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
|
@ -35,12 +35,12 @@ public class CategoryTagDirective implements TemplateDirectiveModel {
|
|||
|
||||
if (params.containsKey(HaloConst.METHOD_KEY)) {
|
||||
String method = params.get(HaloConst.METHOD_KEY).toString();
|
||||
Integer postId = Integer.parseInt(params.get("postId").toString());
|
||||
switch (method) {
|
||||
case "list":
|
||||
env.setVariable("categories", builder.build().wrap(categoryService.listAll()));
|
||||
break;
|
||||
case "listByPostId":
|
||||
Integer postId = Integer.parseInt(params.get("postId").toString());
|
||||
env.setVariable("categories", builder.build().wrap(postCategoryService.listCategoryBy(postId)));
|
||||
case "count":
|
||||
env.setVariable("count", builder.build().wrap(categoryService.count()));
|
||||
|
|
|
@ -31,9 +31,9 @@ public class CommentTagDirective implements TemplateDirectiveModel {
|
|||
|
||||
if (params.containsKey(HaloConst.METHOD_KEY)) {
|
||||
String method = params.get(HaloConst.METHOD_KEY).toString();
|
||||
int top = Integer.parseInt(params.get("top").toString());
|
||||
switch (method) {
|
||||
case "latest":
|
||||
int top = Integer.parseInt(params.get("top").toString());
|
||||
env.setVariable("categories", builder.build().wrap(postCommentService.pageLatest(top)));
|
||||
break;
|
||||
case "count":
|
||||
|
|
|
@ -34,7 +34,6 @@ public class PhotoTagDirective implements TemplateDirectiveModel {
|
|||
|
||||
if (params.containsKey(HaloConst.METHOD_KEY)) {
|
||||
String method = params.get(HaloConst.METHOD_KEY).toString();
|
||||
String team = params.get("team").toString();
|
||||
switch (method) {
|
||||
case "list":
|
||||
env.setVariable("photos", builder.build().wrap(photoService.listAll()));
|
||||
|
@ -43,6 +42,7 @@ public class PhotoTagDirective implements TemplateDirectiveModel {
|
|||
env.setVariable("teams", builder.build().wrap(photoService.listDtos(Sort.by(DESC, "createTime"))));
|
||||
break;
|
||||
case "listByTeam":
|
||||
String team = params.get("team").toString();
|
||||
env.setVariable("photos", builder.build().wrap(photoService.listByTeam(team, Sort.by(DESC, "createTime"))));
|
||||
break;
|
||||
case "count":
|
||||
|
|
|
@ -41,11 +41,9 @@ public class PostTagDirective implements TemplateDirectiveModel {
|
|||
final DefaultObjectWrapperBuilder builder = new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_25);
|
||||
if (params.containsKey(HaloConst.METHOD_KEY)) {
|
||||
String method = params.get(HaloConst.METHOD_KEY).toString();
|
||||
Integer categoryId = Integer.parseInt(params.get("categoryId").toString());
|
||||
Integer tagId = Integer.parseInt(params.get("tagId").toString());
|
||||
int top = Integer.parseInt(params.get("top").toString());
|
||||
switch (method) {
|
||||
case "latest":
|
||||
int top = Integer.parseInt(params.get("top").toString());
|
||||
env.setVariable("posts", builder.build().wrap(postService.listLatest(top)));
|
||||
break;
|
||||
case "count":
|
||||
|
@ -58,9 +56,11 @@ public class PostTagDirective implements TemplateDirectiveModel {
|
|||
env.setVariable("archives", builder.build().wrap(postService.listMonthArchives()));
|
||||
break;
|
||||
case "listByCategoryId":
|
||||
Integer categoryId = Integer.parseInt(params.get("categoryId").toString());
|
||||
env.setVariable("posts", builder.build().wrap(postCategoryService.listPostBy(categoryId)));
|
||||
break;
|
||||
case "listByTagId":
|
||||
Integer tagId = Integer.parseInt(params.get("tagId").toString());
|
||||
env.setVariable("posts", builder.build().wrap(postTagService.listPostsBy(tagId)));
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -35,12 +35,12 @@ public class TagTagDirective implements TemplateDirectiveModel {
|
|||
|
||||
if (params.containsKey(HaloConst.METHOD_KEY)) {
|
||||
String method = params.get(HaloConst.METHOD_KEY).toString();
|
||||
Integer postId = Integer.parseInt(params.get("postId").toString());
|
||||
switch (method) {
|
||||
case "list":
|
||||
env.setVariable("tags", builder.build().wrap(tagService.listAll()));
|
||||
break;
|
||||
case "listByPostId":
|
||||
Integer postId = Integer.parseInt(params.get("postId").toString());
|
||||
env.setVariable("tags", builder.build().wrap(postTagService.listTagsBy(postId)));
|
||||
break;
|
||||
case "count":
|
||||
|
|
|
@ -112,7 +112,7 @@ ${options.native_css!}
|
|||
</#if>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/static/halo-common/jquery/jquery.min.js"></script>
|
||||
<script src="/static/halo-common/jquery.min.js"></script>
|
||||
<script src="/static/halo-content/plugins/md5/md5.min.js"></script>
|
||||
<script src="/static/halo-content/plugins/ua-parser/ua-parser.min.js"></script>
|
||||
<script>
|
||||
|
|
Loading…
Reference in New Issue