Fixed freemarker directive bugs.

pull/146/head
ruibaby 2019-04-30 00:51:13 +08:00
parent f7fb7c7542
commit 102fb0fee8
7 changed files with 9 additions and 9 deletions

View File

@ -158,7 +158,7 @@ public class InstallController {
Set<Integer> categoryIds = new HashSet<>(); Set<Integer> categoryIds = new HashSet<>();
categoryIds.add(category.getId()); categoryIds.add(category.getId());
postParam.setCategoryIds(categoryIds); postParam.setCategoryIds(categoryIds);
return postService.create(postParam.convertTo()); return postService.createOrUpdateBy(postParam.convertTo());
} }
@NonNull @NonNull

View File

@ -35,12 +35,12 @@ public class CategoryTagDirective implements TemplateDirectiveModel {
if (params.containsKey(HaloConst.METHOD_KEY)) { if (params.containsKey(HaloConst.METHOD_KEY)) {
String method = params.get(HaloConst.METHOD_KEY).toString(); String method = params.get(HaloConst.METHOD_KEY).toString();
Integer postId = Integer.parseInt(params.get("postId").toString());
switch (method) { switch (method) {
case "list": case "list":
env.setVariable("categories", builder.build().wrap(categoryService.listAll())); env.setVariable("categories", builder.build().wrap(categoryService.listAll()));
break; break;
case "listByPostId": case "listByPostId":
Integer postId = Integer.parseInt(params.get("postId").toString());
env.setVariable("categories", builder.build().wrap(postCategoryService.listCategoryBy(postId))); env.setVariable("categories", builder.build().wrap(postCategoryService.listCategoryBy(postId)));
case "count": case "count":
env.setVariable("count", builder.build().wrap(categoryService.count())); env.setVariable("count", builder.build().wrap(categoryService.count()));

View File

@ -31,9 +31,9 @@ public class CommentTagDirective implements TemplateDirectiveModel {
if (params.containsKey(HaloConst.METHOD_KEY)) { if (params.containsKey(HaloConst.METHOD_KEY)) {
String method = params.get(HaloConst.METHOD_KEY).toString(); String method = params.get(HaloConst.METHOD_KEY).toString();
int top = Integer.parseInt(params.get("top").toString());
switch (method) { switch (method) {
case "latest": case "latest":
int top = Integer.parseInt(params.get("top").toString());
env.setVariable("categories", builder.build().wrap(postCommentService.pageLatest(top))); env.setVariable("categories", builder.build().wrap(postCommentService.pageLatest(top)));
break; break;
case "count": case "count":

View File

@ -34,7 +34,6 @@ public class PhotoTagDirective implements TemplateDirectiveModel {
if (params.containsKey(HaloConst.METHOD_KEY)) { if (params.containsKey(HaloConst.METHOD_KEY)) {
String method = params.get(HaloConst.METHOD_KEY).toString(); String method = params.get(HaloConst.METHOD_KEY).toString();
String team = params.get("team").toString();
switch (method) { switch (method) {
case "list": case "list":
env.setVariable("photos", builder.build().wrap(photoService.listAll())); 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")))); env.setVariable("teams", builder.build().wrap(photoService.listDtos(Sort.by(DESC, "createTime"))));
break; break;
case "listByTeam": case "listByTeam":
String team = params.get("team").toString();
env.setVariable("photos", builder.build().wrap(photoService.listByTeam(team, Sort.by(DESC, "createTime")))); env.setVariable("photos", builder.build().wrap(photoService.listByTeam(team, Sort.by(DESC, "createTime"))));
break; break;
case "count": case "count":

View File

@ -41,11 +41,9 @@ public class PostTagDirective implements TemplateDirectiveModel {
final DefaultObjectWrapperBuilder builder = new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_25); final DefaultObjectWrapperBuilder builder = new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_25);
if (params.containsKey(HaloConst.METHOD_KEY)) { if (params.containsKey(HaloConst.METHOD_KEY)) {
String method = params.get(HaloConst.METHOD_KEY).toString(); 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) { switch (method) {
case "latest": case "latest":
int top = Integer.parseInt(params.get("top").toString());
env.setVariable("posts", builder.build().wrap(postService.listLatest(top))); env.setVariable("posts", builder.build().wrap(postService.listLatest(top)));
break; break;
case "count": case "count":
@ -58,9 +56,11 @@ public class PostTagDirective implements TemplateDirectiveModel {
env.setVariable("archives", builder.build().wrap(postService.listMonthArchives())); env.setVariable("archives", builder.build().wrap(postService.listMonthArchives()));
break; break;
case "listByCategoryId": case "listByCategoryId":
Integer categoryId = Integer.parseInt(params.get("categoryId").toString());
env.setVariable("posts", builder.build().wrap(postCategoryService.listPostBy(categoryId))); env.setVariable("posts", builder.build().wrap(postCategoryService.listPostBy(categoryId)));
break; break;
case "listByTagId": case "listByTagId":
Integer tagId = Integer.parseInt(params.get("tagId").toString());
env.setVariable("posts", builder.build().wrap(postTagService.listPostsBy(tagId))); env.setVariable("posts", builder.build().wrap(postTagService.listPostsBy(tagId)));
break; break;
default: default:

View File

@ -35,12 +35,12 @@ public class TagTagDirective implements TemplateDirectiveModel {
if (params.containsKey(HaloConst.METHOD_KEY)) { if (params.containsKey(HaloConst.METHOD_KEY)) {
String method = params.get(HaloConst.METHOD_KEY).toString(); String method = params.get(HaloConst.METHOD_KEY).toString();
Integer postId = Integer.parseInt(params.get("postId").toString());
switch (method) { switch (method) {
case "list": case "list":
env.setVariable("tags", builder.build().wrap(tagService.listAll())); env.setVariable("tags", builder.build().wrap(tagService.listAll()));
break; break;
case "listByPostId": case "listByPostId":
Integer postId = Integer.parseInt(params.get("postId").toString());
env.setVariable("tags", builder.build().wrap(postTagService.listTagsBy(postId))); env.setVariable("tags", builder.build().wrap(postTagService.listTagsBy(postId)));
break; break;
case "count": case "count":

View File

@ -112,7 +112,7 @@ ${options.native_css!}
</#if> </#if>
</div> </div>
</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/md5/md5.min.js"></script>
<script src="/static/halo-content/plugins/ua-parser/ua-parser.min.js"></script> <script src="/static/halo-content/plugins/ua-parser/ua-parser.min.js"></script>
<script> <script>