mirror of https://github.com/halo-dev/halo
Refactor properties
parent
64d108d929
commit
2951fc5307
|
@ -2,8 +2,9 @@ package cc.ryanc.halo.listener;
|
||||||
|
|
||||||
import cc.ryanc.halo.config.properties.HaloProperties;
|
import cc.ryanc.halo.config.properties.HaloProperties;
|
||||||
import cc.ryanc.halo.model.entity.User;
|
import cc.ryanc.halo.model.entity.User;
|
||||||
import cc.ryanc.halo.model.properties.BlogProperties;
|
|
||||||
import cc.ryanc.halo.model.params.UserParam;
|
import cc.ryanc.halo.model.params.UserParam;
|
||||||
|
import cc.ryanc.halo.model.properties.BlogProperties;
|
||||||
|
import cc.ryanc.halo.model.properties.PrimaryProperties;
|
||||||
import cc.ryanc.halo.model.support.HaloConst;
|
import cc.ryanc.halo.model.support.HaloConst;
|
||||||
import cc.ryanc.halo.model.support.Theme;
|
import cc.ryanc.halo.model.support.Theme;
|
||||||
import cc.ryanc.halo.service.OptionService;
|
import cc.ryanc.halo.service.OptionService;
|
||||||
|
@ -112,7 +113,7 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
|
||||||
* Get active theme
|
* Get active theme
|
||||||
*/
|
*/
|
||||||
private void getActiveTheme() {
|
private void getActiveTheme() {
|
||||||
BaseContentController.THEME = optionService.getByProperty(BlogProperties.THEME).orElse(DEFAULT_THEME_NAME);
|
BaseContentController.THEME = optionService.getByProperty(PrimaryProperties.THEME).orElse(DEFAULT_THEME_NAME);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
configuration.setSharedVariable("themeName", BaseContentController.THEME);
|
configuration.setSharedVariable("themeName", BaseContentController.THEME);
|
||||||
|
@ -173,7 +174,7 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
|
||||||
*/
|
*/
|
||||||
private void initThemes() {
|
private void initThemes() {
|
||||||
// Whether the blog has initialized
|
// Whether the blog has initialized
|
||||||
Boolean isInstalled = optionService.getByPropertyOrDefault(BlogProperties.IS_INSTALL, Boolean.class, false);
|
Boolean isInstalled = optionService.getByPropertyOrDefault(PrimaryProperties.IS_INSTALLED, Boolean.class, false);
|
||||||
try {
|
try {
|
||||||
if (isInstalled) {
|
if (isInstalled) {
|
||||||
// Skip
|
// Skip
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
package cc.ryanc.halo.model.properties;
|
||||||
|
|
||||||
|
import cc.ryanc.halo.model.enums.AttachmentType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attachment properties.
|
||||||
|
*
|
||||||
|
* @author johnniang
|
||||||
|
* @date 4/1/19
|
||||||
|
*/
|
||||||
|
public enum AttachmentProperties implements PropertyEnum {
|
||||||
|
|
||||||
|
ATTACHMENT_TYPE("attachment_type", AttachmentType.class);
|
||||||
|
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
private final Class<?> type;
|
||||||
|
|
||||||
|
AttachmentProperties(String value, Class<?> type) {
|
||||||
|
this.value = value;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}}
|
|
@ -6,140 +6,36 @@ package cc.ryanc.halo.model.properties;
|
||||||
*/
|
*/
|
||||||
public enum BlogProperties implements PropertyEnum {
|
public enum BlogProperties implements PropertyEnum {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 博客语言
|
* Blog locale.
|
||||||
*/
|
*/
|
||||||
BLOG_LOCALE("blog_locale", String.class),
|
BLOG_LOCALE("blog_locale", String.class),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 博客标题
|
* Blog title.
|
||||||
*/
|
*/
|
||||||
BLOG_TITLE("blog_title", String.class),
|
BLOG_TITLE("blog_title", String.class),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 博客地址
|
* Blog logo.
|
||||||
|
*/
|
||||||
|
BLOG_LOGO("blog_logo", String.class),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Blog url.
|
||||||
*/
|
*/
|
||||||
BLOG_URL("blog_url", String.class),
|
BLOG_URL("blog_url", String.class),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文章摘要字数
|
* Blog favicon.
|
||||||
*/
|
*/
|
||||||
POST_SUMMARY("post_summary", Long.class),
|
BLOG_FAVICON("blog_favicon", String.class),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 首页文章条数
|
* Blog footer info.
|
||||||
*/
|
*/
|
||||||
INDEX_POSTS("index_posts", Integer.class),
|
BLOG_FOOTER_INFO("blog_footer_info", String.class);
|
||||||
|
|
||||||
/**
|
|
||||||
* 每页评论条数
|
|
||||||
*/
|
|
||||||
INDEX_COMMENTS("index_comments", Integer.class),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否已经安装
|
|
||||||
*/
|
|
||||||
IS_INSTALL("is_install", Boolean.class),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RSS显示文章条数
|
|
||||||
*/
|
|
||||||
RSS_POSTS("rss_posts", Integer.class),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* API状态
|
|
||||||
*/
|
|
||||||
API_STATUS("api_status", Boolean.class),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 邮箱服务器地址
|
|
||||||
*/
|
|
||||||
MAIL_SMTP_HOST("mail_smtp_host", String.class),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 邮箱地址
|
|
||||||
*/
|
|
||||||
MAIL_SMTP_USERNAME("mail_smtp_username", String.class),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 邮箱密码/授权码
|
|
||||||
*/
|
|
||||||
MAIL_SMTP_PASSWORD("mail_smtp_password", String.class),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 发送者名称
|
|
||||||
*/
|
|
||||||
MAIL_FROM_NAME("mail_from_name", String.class),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 启用邮件服务
|
|
||||||
*/
|
|
||||||
SMTP_EMAIL_ENABLE("smtp_email_enable", Boolean.class),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 邮件回复通知
|
|
||||||
*/
|
|
||||||
COMMENT_REPLY_NOTICE("comment_reply_notice", Boolean.class),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新评论是否需要审核
|
|
||||||
*/
|
|
||||||
NEW_COMMENT_NEED_CHECK("new_comment_need_check", Boolean.class),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新评论通知
|
|
||||||
*/
|
|
||||||
NEW_COMMENT_NOTICE("new_comment_notice", Boolean.class),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 邮件审核通过通知
|
|
||||||
*/
|
|
||||||
COMMENT_PASS_NOTICE("comment_pass_notice", Boolean.class),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 站点描述
|
|
||||||
*/
|
|
||||||
SEO_DESCRIPTION("seo_description", String.class),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 博客主题
|
|
||||||
*/
|
|
||||||
THEME("theme", String.class),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 博客搭建日期
|
|
||||||
*/
|
|
||||||
BLOG_START("blog_start", Long.class),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 仪表盘部件 文章总数
|
|
||||||
*/
|
|
||||||
WIDGET_POSTCOUNT("widget_postcount", Boolean.class),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 仪表盘部件 评论总数
|
|
||||||
*/
|
|
||||||
WIDGET_COMMENTCOUNT("widget_commentcount", Boolean.class),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 仪表盘部件 附件总数
|
|
||||||
*/
|
|
||||||
WIDGET_ATTACHMENTCOUNT("widget_attachmentcount", Boolean.class),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 仪表盘部件 成立天数
|
|
||||||
*/
|
|
||||||
WIDGET_DAYCOUNT("widget_daycount", Boolean.class),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* API Token
|
|
||||||
*/
|
|
||||||
API_TOKEN("api_token", String.class),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 附件存储位置
|
|
||||||
*/
|
|
||||||
ATTACHMENT_TYPE("attachment_type", String.class);
|
|
||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package cc.ryanc.halo.model.properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment properties.
|
||||||
|
*
|
||||||
|
* @author johnniang
|
||||||
|
* @date 4/1/19
|
||||||
|
*/
|
||||||
|
public enum CommentProperties implements PropertyEnum {
|
||||||
|
|
||||||
|
GAVATAR_DEFAULT("comment_gavatar_default", String.class),
|
||||||
|
|
||||||
|
NEW_NEED_CHECK("comment_new_need_check", Boolean.class),
|
||||||
|
|
||||||
|
NEW_NOTICE("comment_new_notice", Boolean.class),
|
||||||
|
|
||||||
|
PASS_NOTICE("comment_pass_notice", Boolean.class),
|
||||||
|
|
||||||
|
REPLY_NOTICE("comment_reply_notice", Boolean.class),
|
||||||
|
|
||||||
|
API_ENABLED("comment_api_enabled", Boolean.class),
|
||||||
|
|
||||||
|
PAGE_SIZE("comment_page_size", Integer.class),
|
||||||
|
|
||||||
|
CONTENT_PLACEHOLDER("comment_content_placeholder", String.class),
|
||||||
|
|
||||||
|
CUSTOM_STYLE("comment_custom_style", String.class);
|
||||||
|
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
private final Class<?> type;
|
||||||
|
|
||||||
|
CommentProperties(String value, Class<?> type) {
|
||||||
|
this.value = value;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}}
|
|
@ -8,14 +8,19 @@ package cc.ryanc.halo.model.properties;
|
||||||
*/
|
*/
|
||||||
public enum EmailProperties implements PropertyEnum {
|
public enum EmailProperties implements PropertyEnum {
|
||||||
|
|
||||||
SMTP_HOST("email_smtp_host", String.class),
|
HOST("email_host", String.class),
|
||||||
SMTP_USERNAME("email_smtp_username", String.class),
|
|
||||||
SMTP_PASSWORD("email_smtp_password", String.class),
|
PROTOCOL("email_protocol", String.class),
|
||||||
|
|
||||||
|
SSL_PORT("email_ssl_port", Integer.class),
|
||||||
|
|
||||||
|
USERNAME("email_username", String.class),
|
||||||
|
|
||||||
|
PASSWORD("email_password", String.class),
|
||||||
|
|
||||||
FROM_NAME("email_from_name", String.class),
|
FROM_NAME("email_from_name", String.class),
|
||||||
ENABLED("email_enabled", Boolean.class),
|
|
||||||
COMMENT_REPLY_NOTICE_ENABLED("email_comment_reply_notice_enabled", Boolean.class),
|
ENABLED("email_enabled", Boolean.class);
|
||||||
NEW_COMMENT_NOTICE_ENABLED("email_new_comment_notice_enabled", Boolean.class),
|
|
||||||
COMMENT_PASS_NOTICE_ENABLED("email_comment_pass_notice_enabled", Boolean.class);
|
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|
||||||
|
@ -32,10 +37,10 @@ public enum EmailProperties implements PropertyEnum {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getType() {
|
public Class<?> getType() {
|
||||||
return null;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return null;
|
return value;
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package cc.ryanc.halo.model.properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Other properties.
|
||||||
|
*
|
||||||
|
* @author johnniang
|
||||||
|
* @date 4/1/19
|
||||||
|
*/
|
||||||
|
public enum OtherProperties implements PropertyEnum {
|
||||||
|
|
||||||
|
API_ENABLED("api_enabled", Boolean.class),
|
||||||
|
|
||||||
|
API_TOKEN("api_token", String.class),
|
||||||
|
|
||||||
|
STATISTICS_CODE("statistics_code", String.class),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
private final Class<?> type;
|
||||||
|
|
||||||
|
OtherProperties(String value, Class<?> type) {
|
||||||
|
this.value = value;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package cc.ryanc.halo.model.properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author johnniang
|
||||||
|
* @date 4/1/19
|
||||||
|
*/
|
||||||
|
public enum PostProperties implements PropertyEnum {
|
||||||
|
|
||||||
|
SUMMARY_LENGTH("post_summary_length", Integer.class),
|
||||||
|
|
||||||
|
RSS_PAGE_SIZE("rss_page_size", Integer.class),
|
||||||
|
|
||||||
|
INDEX_PAGE_SIZE("post_index_page_size", Integer.class),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
private final Class<?> type;
|
||||||
|
|
||||||
|
PostProperties(String value, Class<?> type) {
|
||||||
|
this.value = value;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package cc.ryanc.halo.model.properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary properties.
|
||||||
|
*
|
||||||
|
* @author johnniang
|
||||||
|
* @date 4/2/19
|
||||||
|
*/
|
||||||
|
public enum PrimaryProperties implements PropertyEnum {
|
||||||
|
|
||||||
|
IS_INSTALLED("is_installed", Boolean.class),
|
||||||
|
|
||||||
|
THEME("theme", String.class),
|
||||||
|
|
||||||
|
BIRTHDAY("birthday", Long.class),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
private final Class<?> type;
|
||||||
|
|
||||||
|
PrimaryProperties(String value, Class<?> type) {
|
||||||
|
this.value = value;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
return null;
|
||||||
|
}}
|
|
@ -85,7 +85,7 @@ public interface PropertyEnum extends ValueEnum<String> {
|
||||||
Assert.hasText(value, "Property value must not be blank");
|
Assert.hasText(value, "Property value must not be blank");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return Enum.valueOf(type, value);
|
return Enum.valueOf(type, value.toUpperCase());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Ignore this exception
|
// Ignore this exception
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -8,16 +8,21 @@ package cc.ryanc.halo.model.properties;
|
||||||
*/
|
*/
|
||||||
public enum QnYunProperties implements PropertyEnum {
|
public enum QnYunProperties implements PropertyEnum {
|
||||||
|
|
||||||
ZONE("qiniu_zone", String.class),
|
ZONE("oss_qiniu_zone", String.class),
|
||||||
ACCESS_KEY("qiniu_access_key", String.class),
|
|
||||||
SECRET_KEY("qiniu_secret_key", String.class),
|
|
||||||
DOMAIN("qiniu_domain", String.class),
|
|
||||||
BUCKET("qiniu_bucket", String.class),
|
|
||||||
SMALL_URL("qiniu_small_url", String.class);
|
|
||||||
|
|
||||||
private String value;
|
ACCESS_KEY("oss_qiniu_access_key", String.class),
|
||||||
|
|
||||||
private Class<?> type;
|
SECRET_KEY("oss_qiniu_secret_key", String.class),
|
||||||
|
|
||||||
|
DOMAIN("oss_qiniu_domain", String.class),
|
||||||
|
|
||||||
|
BUCKET("oss_qiniu_bucket", String.class),
|
||||||
|
|
||||||
|
SMALL_URL("oss_qiniu_small_url", String.class);
|
||||||
|
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
private final Class<?> type;
|
||||||
|
|
||||||
QnYunProperties(String value, Class<?> type) {
|
QnYunProperties(String value, Class<?> type) {
|
||||||
if (!PropertyEnum.isSupportedType(type)) {
|
if (!PropertyEnum.isSupportedType(type)) {
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package cc.ryanc.halo.model.properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SEO properties.
|
||||||
|
*
|
||||||
|
* @author johnniang
|
||||||
|
* @date 4/1/19
|
||||||
|
*/
|
||||||
|
public enum SeoProperties implements PropertyEnum {
|
||||||
|
|
||||||
|
KEYWORDS("seo_keywords", String.class),
|
||||||
|
|
||||||
|
DESCRIPTION("seo_description", String.class),
|
||||||
|
|
||||||
|
BAIDU_TOKEN("seo_baidu_token", String.class),
|
||||||
|
|
||||||
|
VERIFICATION_BAIDU("seo_verification_baidu", String.class),
|
||||||
|
|
||||||
|
VERIFICATION_GOOGLE("seo_verification_google", String.class),
|
||||||
|
|
||||||
|
VERIFICATION_BING("seo_verification_bing", String.class),
|
||||||
|
|
||||||
|
VERIFICATION_QIHU("seo_verification_qihu", String.class);
|
||||||
|
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
private final Class<?> type;
|
||||||
|
|
||||||
|
SeoProperties(String value, Class<?> type) {
|
||||||
|
this.value = value;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}}
|
|
@ -8,12 +8,17 @@ package cc.ryanc.halo.model.properties;
|
||||||
*/
|
*/
|
||||||
public enum UpYunProperties implements PropertyEnum {
|
public enum UpYunProperties implements PropertyEnum {
|
||||||
|
|
||||||
OSS_SOURCE("upyun_oss_source", String.class),
|
OSS_SOURCE("oss_upyun_source", String.class),
|
||||||
OSS_PASSWORD("upyun_oss_password", String.class),
|
|
||||||
OSS_BUCKET("upyun_oss_bucket", String.class),
|
OSS_PASSWORD("oss_upyun_password", String.class),
|
||||||
OSS_DOMAIN("upyun_oss_domain", String.class),
|
|
||||||
OSS_OPERATOR("upyun_oss_operator", String.class),
|
OSS_BUCKET("oss_upyun_bucket", String.class),
|
||||||
OSS_SMALL_URL("ypyun_oss_small_url", String.class);
|
|
||||||
|
OSS_DOMAIN("oss_upyun_domain", String.class),
|
||||||
|
|
||||||
|
OSS_OPERATOR("oss_upyun_operator", String.class),
|
||||||
|
|
||||||
|
OSS_SMALL_URL("oss_upyun_small_url", String.class);
|
||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import cc.ryanc.halo.handler.file.FileHandlers;
|
||||||
import cc.ryanc.halo.model.dto.AttachmentOutputDTO;
|
import cc.ryanc.halo.model.dto.AttachmentOutputDTO;
|
||||||
import cc.ryanc.halo.model.entity.Attachment;
|
import cc.ryanc.halo.model.entity.Attachment;
|
||||||
import cc.ryanc.halo.model.enums.AttachmentType;
|
import cc.ryanc.halo.model.enums.AttachmentType;
|
||||||
import cc.ryanc.halo.model.properties.BlogProperties;
|
import cc.ryanc.halo.model.properties.AttachmentProperties;
|
||||||
import cc.ryanc.halo.model.support.UploadResult;
|
import cc.ryanc.halo.model.support.UploadResult;
|
||||||
import cc.ryanc.halo.repository.AttachmentRepository;
|
import cc.ryanc.halo.repository.AttachmentRepository;
|
||||||
import cc.ryanc.halo.service.AttachmentService;
|
import cc.ryanc.halo.service.AttachmentService;
|
||||||
|
@ -107,6 +107,6 @@ public class AttachmentServiceImpl extends AbstractCrudService<Attachment, Integ
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
private AttachmentType getAttachmentType() {
|
private AttachmentType getAttachmentType() {
|
||||||
return optionService.getValueEnumByPropertyOrDefault(BlogProperties.ATTACHMENT_TYPE, Integer.class, AttachmentType.class, AttachmentType.LOCAL);
|
return optionService.getEnumByPropertyOrDefault(AttachmentProperties.ATTACHMENT_TYPE, AttachmentType.class, AttachmentType.LOCAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package cc.ryanc.halo.service.impl;
|
||||||
import cc.ryanc.halo.model.dto.post.PostMinimalOutputDTO;
|
import cc.ryanc.halo.model.dto.post.PostMinimalOutputDTO;
|
||||||
import cc.ryanc.halo.model.entity.Comment;
|
import cc.ryanc.halo.model.entity.Comment;
|
||||||
import cc.ryanc.halo.model.entity.Post;
|
import cc.ryanc.halo.model.entity.Post;
|
||||||
import cc.ryanc.halo.model.properties.BlogProperties;
|
|
||||||
import cc.ryanc.halo.model.enums.CommentStatus;
|
import cc.ryanc.halo.model.enums.CommentStatus;
|
||||||
import cc.ryanc.halo.model.projection.CommentCountProjection;
|
import cc.ryanc.halo.model.projection.CommentCountProjection;
|
||||||
|
import cc.ryanc.halo.model.properties.CommentProperties;
|
||||||
import cc.ryanc.halo.model.support.CommentPage;
|
import cc.ryanc.halo.model.support.CommentPage;
|
||||||
import cc.ryanc.halo.model.vo.CommentVO;
|
import cc.ryanc.halo.model.vo.CommentVO;
|
||||||
import cc.ryanc.halo.model.vo.CommentWithParentVO;
|
import cc.ryanc.halo.model.vo.CommentWithParentVO;
|
||||||
|
@ -122,7 +122,7 @@ public class CommentServiceImpl extends AbstractCrudService<Comment, Long> imple
|
||||||
comment.setStatus(CommentStatus.PUBLISHED);
|
comment.setStatus(CommentStatus.PUBLISHED);
|
||||||
} else {
|
} else {
|
||||||
// Handle comment status
|
// Handle comment status
|
||||||
Boolean needAudit = optionService.getByPropertyOrDefault(BlogProperties.NEW_COMMENT_NEED_CHECK, Boolean.class, true);
|
Boolean needAudit = optionService.getByPropertyOrDefault(CommentProperties.NEW_NEED_CHECK, Boolean.class, true);
|
||||||
if (needAudit) {
|
if (needAudit) {
|
||||||
comment.setStatus(CommentStatus.AUDITING);
|
comment.setStatus(CommentStatus.AUDITING);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package cc.ryanc.halo.service.impl;
|
package cc.ryanc.halo.service.impl;
|
||||||
|
|
||||||
import cc.ryanc.halo.exception.ServiceException;
|
import cc.ryanc.halo.exception.ServiceException;
|
||||||
import cc.ryanc.halo.model.properties.BlogProperties;
|
|
||||||
import cc.ryanc.halo.model.properties.EmailProperties;
|
import cc.ryanc.halo.model.properties.EmailProperties;
|
||||||
import cc.ryanc.halo.service.MailService;
|
import cc.ryanc.halo.service.MailService;
|
||||||
import cc.ryanc.halo.service.OptionService;
|
import cc.ryanc.halo.service.OptionService;
|
||||||
|
@ -18,6 +17,8 @@ import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Mail service implementation.
|
||||||
|
*
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2019-03-17
|
* @date : 2019-03-17
|
||||||
*/
|
*/
|
||||||
|
@ -119,7 +120,7 @@ public class MailServiceImpl implements MailService {
|
||||||
public void sendAttachMail(String to, String subject, Map<String, Object> content, String templateName, String attachFilename) {
|
public void sendAttachMail(String to, String subject, Map<String, Object> content, String templateName, String attachFilename) {
|
||||||
loadConfig();
|
loadConfig();
|
||||||
|
|
||||||
String fromUsername = optionService.getByPropertyOfNonNull(BlogProperties.MAIL_FROM_NAME);
|
String fromUsername = optionService.getByPropertyOfNonNull(EmailProperties.FROM_NAME);
|
||||||
|
|
||||||
File file = new File(attachFilename);
|
File file = new File(attachFilename);
|
||||||
try {
|
try {
|
||||||
|
@ -148,11 +149,11 @@ public class MailServiceImpl implements MailService {
|
||||||
// Get default properties
|
// Get default properties
|
||||||
Properties defaultProperties = OhMyEmail.defaultConfig(log.isDebugEnabled());
|
Properties defaultProperties = OhMyEmail.defaultConfig(log.isDebugEnabled());
|
||||||
// Set smtp host
|
// Set smtp host
|
||||||
defaultProperties.setProperty("mail.smtp.host", optionService.getByPropertyOfNonNull(EmailProperties.SMTP_HOST));
|
defaultProperties.setProperty("mail.smtp.host", optionService.getByPropertyOfNonNull(EmailProperties.HOST));
|
||||||
// Config email
|
// Config email
|
||||||
OhMyEmail.config(defaultProperties,
|
OhMyEmail.config(defaultProperties,
|
||||||
optionService.getByPropertyOfNonNull(EmailProperties.SMTP_USERNAME),
|
optionService.getByPropertyOfNonNull(EmailProperties.USERNAME),
|
||||||
optionService.getByPropertyOfNonNull(EmailProperties.SMTP_PASSWORD));
|
optionService.getByPropertyOfNonNull(EmailProperties.PASSWORD));
|
||||||
|
|
||||||
// Set config loaded with true
|
// Set config loaded with true
|
||||||
loaded = true;
|
loaded = true;
|
||||||
|
|
|
@ -3,11 +3,10 @@ package cc.ryanc.halo.service.impl;
|
||||||
import cc.ryanc.halo.exception.MissingPropertyException;
|
import cc.ryanc.halo.exception.MissingPropertyException;
|
||||||
import cc.ryanc.halo.model.dto.OptionOutputDTO;
|
import cc.ryanc.halo.model.dto.OptionOutputDTO;
|
||||||
import cc.ryanc.halo.model.entity.Option;
|
import cc.ryanc.halo.model.entity.Option;
|
||||||
import cc.ryanc.halo.model.enums.*;
|
import cc.ryanc.halo.model.enums.OptionSource;
|
||||||
|
import cc.ryanc.halo.model.enums.ValueEnum;
|
||||||
import cc.ryanc.halo.model.params.OptionParam;
|
import cc.ryanc.halo.model.params.OptionParam;
|
||||||
import cc.ryanc.halo.model.properties.BlogProperties;
|
import cc.ryanc.halo.model.properties.*;
|
||||||
import cc.ryanc.halo.model.properties.PropertyEnum;
|
|
||||||
import cc.ryanc.halo.model.properties.QnYunProperties;
|
|
||||||
import cc.ryanc.halo.repository.OptionRepository;
|
import cc.ryanc.halo.repository.OptionRepository;
|
||||||
import cc.ryanc.halo.service.OptionService;
|
import cc.ryanc.halo.service.OptionService;
|
||||||
import cc.ryanc.halo.service.base.AbstractCrudService;
|
import cc.ryanc.halo.service.base.AbstractCrudService;
|
||||||
|
@ -212,9 +211,9 @@ public class OptionServiceImpl extends AbstractCrudService<Option, Integer> impl
|
||||||
@Override
|
@Override
|
||||||
public int getPostPageSize() {
|
public int getPostPageSize() {
|
||||||
try {
|
try {
|
||||||
return getByPropertyOrDefault(BlogProperties.INDEX_POSTS, Integer.class, DEFAULT_COMMENT_PAGE_SIZE);
|
return getByPropertyOrDefault(PostProperties.INDEX_PAGE_SIZE, Integer.class, DEFAULT_COMMENT_PAGE_SIZE);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
log.error(BlogProperties.INDEX_POSTS + " option is not a number format", e);
|
log.error(PostProperties.INDEX_PAGE_SIZE.getValue() + " option is not a number format", e);
|
||||||
return DEFAULT_POST_PAGE_SIZE;
|
return DEFAULT_POST_PAGE_SIZE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,9 +221,9 @@ public class OptionServiceImpl extends AbstractCrudService<Option, Integer> impl
|
||||||
@Override
|
@Override
|
||||||
public int getCommentPageSize() {
|
public int getCommentPageSize() {
|
||||||
try {
|
try {
|
||||||
return getByPropertyOrDefault(BlogProperties.INDEX_COMMENTS, Integer.class, DEFAULT_COMMENT_PAGE_SIZE);
|
return getByPropertyOrDefault(CommentProperties.PAGE_SIZE, Integer.class, DEFAULT_COMMENT_PAGE_SIZE);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
log.error(BlogProperties.INDEX_COMMENTS + " option is not a number format", e);
|
log.error(CommentProperties.PAGE_SIZE.getValue() + " option is not a number format", e);
|
||||||
return DEFAULT_COMMENT_PAGE_SIZE;
|
return DEFAULT_COMMENT_PAGE_SIZE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,9 +231,9 @@ public class OptionServiceImpl extends AbstractCrudService<Option, Integer> impl
|
||||||
@Override
|
@Override
|
||||||
public int getRssPageSize() {
|
public int getRssPageSize() {
|
||||||
try {
|
try {
|
||||||
return getByPropertyOrDefault(BlogProperties.RSS_POSTS, Integer.class, DEFAULT_COMMENT_PAGE_SIZE);
|
return getByPropertyOrDefault(PostProperties.RSS_PAGE_SIZE, Integer.class, DEFAULT_COMMENT_PAGE_SIZE);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
log.error(BlogProperties.RSS_POSTS + " setting is not a number format", e);
|
log.error(PostProperties.RSS_PAGE_SIZE.getValue() + " setting is not a number format", e);
|
||||||
return DEFAULT_RSS_PAGE_SIZE;
|
return DEFAULT_RSS_PAGE_SIZE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import cc.ryanc.halo.cache.lock.CacheLock;
|
||||||
import cc.ryanc.halo.exception.BadRequestException;
|
import cc.ryanc.halo.exception.BadRequestException;
|
||||||
import cc.ryanc.halo.model.dto.CountOutputDTO;
|
import cc.ryanc.halo.model.dto.CountOutputDTO;
|
||||||
import cc.ryanc.halo.model.dto.UserOutputDTO;
|
import cc.ryanc.halo.model.dto.UserOutputDTO;
|
||||||
import cc.ryanc.halo.model.properties.BlogProperties;
|
|
||||||
import cc.ryanc.halo.model.enums.PostStatus;
|
import cc.ryanc.halo.model.enums.PostStatus;
|
||||||
import cc.ryanc.halo.model.params.LoginParam;
|
import cc.ryanc.halo.model.params.LoginParam;
|
||||||
|
import cc.ryanc.halo.model.properties.PrimaryProperties;
|
||||||
import cc.ryanc.halo.security.context.SecurityContextHolder;
|
import cc.ryanc.halo.security.context.SecurityContextHolder;
|
||||||
import cc.ryanc.halo.security.filter.AdminAuthenticationFilter;
|
import cc.ryanc.halo.security.filter.AdminAuthenticationFilter;
|
||||||
import cc.ryanc.halo.service.*;
|
import cc.ryanc.halo.service.*;
|
||||||
|
@ -61,7 +61,15 @@ public class AdminController {
|
||||||
countOutputDTO.setPostCount(postService.countByStatus(PostStatus.PUBLISHED));
|
countOutputDTO.setPostCount(postService.countByStatus(PostStatus.PUBLISHED));
|
||||||
countOutputDTO.setAttachmentCount(attachmentService.count());
|
countOutputDTO.setAttachmentCount(attachmentService.count());
|
||||||
countOutputDTO.setCommentCount(commentService.count());
|
countOutputDTO.setCommentCount(commentService.count());
|
||||||
countOutputDTO.setEstablishDays(Long.valueOf(optionService.getByProperty(BlogProperties.WIDGET_DAYCOUNT).orElse("0")));
|
|
||||||
|
long currentTimeMillis = System.currentTimeMillis();
|
||||||
|
|
||||||
|
// Calculate birthday
|
||||||
|
// TODO Initialize the birthday if absent
|
||||||
|
Long birthday = optionService.getByPropertyOrDefault(PrimaryProperties.BIRTHDAY, Long.class, currentTimeMillis);
|
||||||
|
long days = (currentTimeMillis - birthday) / (1000 * 24 * 3600);
|
||||||
|
countOutputDTO.setEstablishDays(days);
|
||||||
|
|
||||||
countOutputDTO.setLinkCount(linkService.count());
|
countOutputDTO.setLinkCount(linkService.count());
|
||||||
countOutputDTO.setVisitCount(postService.countVisit());
|
countOutputDTO.setVisitCount(postService.countVisit());
|
||||||
countOutputDTO.setLikeCount(postService.countLike());
|
countOutputDTO.setLikeCount(postService.countLike());
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package cc.ryanc.halo.web.controller.admin.api;
|
package cc.ryanc.halo.web.controller.admin.api;
|
||||||
|
|
||||||
import cc.ryanc.halo.model.properties.BlogProperties;
|
|
||||||
import cc.ryanc.halo.model.enums.OptionSource;
|
import cc.ryanc.halo.model.enums.OptionSource;
|
||||||
|
import cc.ryanc.halo.model.properties.PrimaryProperties;
|
||||||
|
import cc.ryanc.halo.model.properties.PropertyEnum;
|
||||||
import cc.ryanc.halo.model.support.Theme;
|
import cc.ryanc.halo.model.support.Theme;
|
||||||
import cc.ryanc.halo.service.OptionService;
|
import cc.ryanc.halo.service.OptionService;
|
||||||
import cc.ryanc.halo.service.ThemeService;
|
import cc.ryanc.halo.service.ThemeService;
|
||||||
|
@ -60,8 +61,9 @@ public class ThemeController {
|
||||||
@GetMapping(value = "active")
|
@GetMapping(value = "active")
|
||||||
@ApiOperation("Active theme")
|
@ApiOperation("Active theme")
|
||||||
public void active(@RequestParam(name = "themeName", defaultValue = "anatole") String themeName) throws TemplateModelException {
|
public void active(@RequestParam(name = "themeName", defaultValue = "anatole") String themeName) throws TemplateModelException {
|
||||||
Map<BlogProperties, String> properties = new HashMap<>(1);
|
Map<PropertyEnum, String> properties = new HashMap<>(1);
|
||||||
properties.put(BlogProperties.THEME, themeName);
|
properties.put(PrimaryProperties.THEME, themeName);
|
||||||
|
// TODO Refactor: saveProperties => saveProperty
|
||||||
optionService.saveProperties(properties, OptionSource.SYSTEM);
|
optionService.saveProperties(properties, OptionSource.SYSTEM);
|
||||||
BaseContentController.THEME = themeName;
|
BaseContentController.THEME = themeName;
|
||||||
configuration.setSharedVariable("themeName", themeName);
|
configuration.setSharedVariable("themeName", themeName);
|
||||||
|
|
|
@ -3,9 +3,9 @@ package cc.ryanc.halo.web.controller.core;
|
||||||
import cc.ryanc.halo.exception.BadRequestException;
|
import cc.ryanc.halo.exception.BadRequestException;
|
||||||
import cc.ryanc.halo.model.entity.*;
|
import cc.ryanc.halo.model.entity.*;
|
||||||
import cc.ryanc.halo.model.enums.AttachmentType;
|
import cc.ryanc.halo.model.enums.AttachmentType;
|
||||||
import cc.ryanc.halo.model.properties.BlogProperties;
|
|
||||||
import cc.ryanc.halo.model.enums.OptionSource;
|
import cc.ryanc.halo.model.enums.OptionSource;
|
||||||
import cc.ryanc.halo.model.params.InstallParam;
|
import cc.ryanc.halo.model.params.InstallParam;
|
||||||
|
import cc.ryanc.halo.model.properties.*;
|
||||||
import cc.ryanc.halo.model.support.BaseResponse;
|
import cc.ryanc.halo.model.support.BaseResponse;
|
||||||
import cc.ryanc.halo.service.*;
|
import cc.ryanc.halo.service.*;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
@ -74,7 +74,7 @@ public class InstallController {
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public String install(Model model) {
|
public String install(Model model) {
|
||||||
try {
|
try {
|
||||||
if (StrUtil.equals(Boolean.TRUE.toString(), optionService.getByProperty(BlogProperties.IS_INSTALL).orElse(Boolean.FALSE.toString()))) {
|
if (StrUtil.equals(Boolean.TRUE.toString(), optionService.getByProperty(PrimaryProperties.IS_INSTALLED).orElse(Boolean.FALSE.toString()))) {
|
||||||
model.addAttribute("isInstall", true);
|
model.addAttribute("isInstall", true);
|
||||||
} else {
|
} else {
|
||||||
model.addAttribute("isInstall", false);
|
model.addAttribute("isInstall", false);
|
||||||
|
@ -90,7 +90,7 @@ public class InstallController {
|
||||||
public BaseResponse<?> installBlog(@Valid InstallParam installParam) {
|
public BaseResponse<?> installBlog(@Valid InstallParam installParam) {
|
||||||
// TODO Install blog.
|
// TODO Install blog.
|
||||||
// Check is installed
|
// Check is installed
|
||||||
boolean isInstalled = Boolean.parseBoolean(optionService.getByProperty(BlogProperties.IS_INSTALL).orElse(Boolean.FALSE.toString()));
|
boolean isInstalled = Boolean.parseBoolean(optionService.getByProperty(PrimaryProperties.IS_INSTALLED).orElse(Boolean.FALSE.toString()));
|
||||||
|
|
||||||
if (isInstalled) {
|
if (isInstalled) {
|
||||||
throw new BadRequestException("该博客已初始化,不能再次安装!");
|
throw new BadRequestException("该博客已初始化,不能再次安装!");
|
||||||
|
@ -161,131 +161,22 @@ public class InstallController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initSettings(InstallParam installParam) {
|
private void initSettings(InstallParam installParam) {
|
||||||
// Init properties
|
// Init default properties
|
||||||
Map<BlogProperties, String> properties = new HashMap<>(11);
|
Map<PropertyEnum, String> properties = new HashMap<>(11);
|
||||||
properties.put(BlogProperties.IS_INSTALL, Boolean.TRUE.toString());
|
properties.put(PrimaryProperties.IS_INSTALLED, Boolean.TRUE.toString());
|
||||||
properties.put(BlogProperties.BLOG_LOCALE, installParam.getLocale());
|
properties.put(BlogProperties.BLOG_LOCALE, installParam.getLocale());
|
||||||
properties.put(BlogProperties.BLOG_TITLE, installParam.getTitle());
|
properties.put(BlogProperties.BLOG_TITLE, installParam.getTitle());
|
||||||
properties.put(BlogProperties.BLOG_URL, installParam.getUrl());
|
properties.put(BlogProperties.BLOG_URL, installParam.getUrl());
|
||||||
properties.put(BlogProperties.THEME, DEFAULT_THEME_NAME);
|
properties.put(PrimaryProperties.THEME, DEFAULT_THEME_NAME);
|
||||||
properties.put(BlogProperties.BLOG_START, String.valueOf(System.currentTimeMillis()));
|
properties.put(PrimaryProperties.BIRTHDAY, String.valueOf(System.currentTimeMillis()));
|
||||||
properties.put(BlogProperties.SMTP_EMAIL_ENABLE, Boolean.FALSE.toString());
|
properties.put(EmailProperties.ENABLED, Boolean.FALSE.toString());
|
||||||
properties.put(BlogProperties.NEW_COMMENT_NOTICE, Boolean.FALSE.toString());
|
properties.put(CommentProperties.NEW_NOTICE, Boolean.FALSE.toString());
|
||||||
properties.put(BlogProperties.COMMENT_PASS_NOTICE, Boolean.FALSE.toString());
|
properties.put(CommentProperties.PASS_NOTICE, Boolean.FALSE.toString());
|
||||||
properties.put(BlogProperties.COMMENT_REPLY_NOTICE, Boolean.FALSE.toString());
|
properties.put(CommentProperties.REPLY_NOTICE, Boolean.FALSE.toString());
|
||||||
properties.put(BlogProperties.ATTACHMENT_TYPE, AttachmentType.LOCAL.getValue().toString());
|
properties.put(AttachmentProperties.ATTACHMENT_TYPE, AttachmentType.LOCAL.getValue().toString());
|
||||||
|
|
||||||
// Create properties
|
// Create properties
|
||||||
optionService.saveProperties(properties, OptionSource.SYSTEM);
|
optionService.saveProperties(properties, OptionSource.SYSTEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Do install
|
|
||||||
// *
|
|
||||||
// * @param blogLocale language
|
|
||||||
// * @param blogTitle blog title
|
|
||||||
// * @param blogUrl blog url
|
|
||||||
// * @param userName user name
|
|
||||||
// * @param nickName nick name
|
|
||||||
// * @param userEmail user email
|
|
||||||
// * @param userPwd user password
|
|
||||||
// * @param request request
|
|
||||||
// * @return JsonResult
|
|
||||||
// */
|
|
||||||
// @PostMapping(value = "/do")
|
|
||||||
// @ResponseBody
|
|
||||||
// @Deprecated
|
|
||||||
// public JsonResult doInstall(@RequestParam("blogLocale") String blogLocale,
|
|
||||||
// @RequestParam("blogTitle") String blogTitle,
|
|
||||||
// @RequestParam("blogUrl") String blogUrl,
|
|
||||||
// @RequestParam("userName") String userName,
|
|
||||||
// @RequestParam("userDisplayName") String nickName,
|
|
||||||
// @RequestParam("userEmail") String userEmail,
|
|
||||||
// @RequestParam("userPwd") String userPwd,
|
|
||||||
// HttpServletRequest request) {
|
|
||||||
// try {
|
|
||||||
// if (StrUtil.equals("true", OPTIONS.get("is_install"))) {
|
|
||||||
// return new JsonResult(0, "该博客已初始化,不能再次安装!");
|
|
||||||
// }
|
|
||||||
// // Create new user
|
|
||||||
// final User user = new User();
|
|
||||||
// user.setUsername(userName);
|
|
||||||
// user.setNickname(StrUtil.isBlank(nickName) ? userName : nickName);
|
|
||||||
// user.setEmail(userEmail);
|
|
||||||
// user.setPassword(SecureUtil.md5(userPwd));
|
|
||||||
// userService.create(user);
|
|
||||||
//
|
|
||||||
// //默认分类
|
|
||||||
// Category category = new Category();
|
|
||||||
// category.setName("未分类");
|
|
||||||
// category.setSlugName("default");
|
|
||||||
// category.setDescription("未分类");
|
|
||||||
// category = categoryService.create(category);
|
|
||||||
//
|
|
||||||
// //第一篇文章
|
|
||||||
// final Post post = new Post();
|
|
||||||
// final List<Category> categories = new ArrayList<>(1);
|
|
||||||
// categories.add(category);
|
|
||||||
// post.setTitle("Hello Halo!");
|
|
||||||
// post.setOriginalContent("# Hello Halo!\n" +
|
|
||||||
// "欢迎使用Halo进行创作,删除这篇文章后赶紧开始吧。");
|
|
||||||
// post.setFormatContent(MarkdownUtils.renderMarkdown(post.getOriginalContent()));
|
|
||||||
// post.setSummary("欢迎使用Halo进行创作,删除这篇文章后赶紧开始吧。");
|
|
||||||
// post.setStatus(PostStatus.PUBLISHED);
|
|
||||||
// post.setUrl("hello-halo");
|
|
||||||
// post.setDisallowComment(true);
|
|
||||||
// postService.create(post);
|
|
||||||
//
|
|
||||||
// //第一个评论
|
|
||||||
// final Comment comment = new Comment();
|
|
||||||
// comment.setAuthor("ruibaby");
|
|
||||||
// comment.setEmail("i@ryanc.cc");
|
|
||||||
// comment.setAuthorUrl("https://ryanc.cc");
|
|
||||||
// comment.setIpAddress("127.0.0.1");
|
|
||||||
// comment.setGavatarMd5(SecureUtil.md5("i@ryanc.cc"));
|
|
||||||
// comment.setContent("欢迎,欢迎!");
|
|
||||||
// comment.setStatus(CommentStatus.PUBLISHED);
|
|
||||||
// comment.setUserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.162 Safari/537.36");
|
|
||||||
// comment.setIsAdmin(false);
|
|
||||||
// commentService.create(comment);
|
|
||||||
//
|
|
||||||
// final Map<BlogProperties, Object> options = new HashMap<>();
|
|
||||||
//// options.put(BlogProperties.IS_INSTALL, TrueFalseEnum.TRUE.getDesc());
|
|
||||||
//// options.put(BlogProperties.BLOG_LOCALE, blogLocale);
|
|
||||||
//// options.put(BlogProperties.BLOG_TITLE, blogTitle);
|
|
||||||
//// options.put(BlogProperties.BLOG_URL, blogUrl);
|
|
||||||
//// options.put(BlogProperties.THEME, "anatole");
|
|
||||||
//// options.put(BlogProperties.BLOG_START, DateUtil.format(DateUtil.date(), "yyyy-MM-dd"));
|
|
||||||
//// options.put(BlogProperties.SMTP_EMAIL_ENABLE, TrueFalseEnum.FALSE.getDesc());
|
|
||||||
//// options.put(BlogProperties.NEW_COMMENT_NOTICE, TrueFalseEnum.FALSE.getDesc());
|
|
||||||
//// options.put(BlogProperties.COMMENT_PASS_NOTICE, TrueFalseEnum.FALSE.getDesc());
|
|
||||||
//// options.put(BlogProperties.COMMENT_REPLY_NOTICE, TrueFalseEnum.FALSE.getDesc());
|
|
||||||
//// options.put(BlogProperties.ATTACHMENT_TYPE, AttachLocationEnum.SERVER.getDesc());
|
|
||||||
//// optionService.saveOptions(options);
|
|
||||||
//
|
|
||||||
// //更新日志
|
|
||||||
//// logsService.save(LogsRecord.INSTALL, "安装成功,欢迎使用Halo。", request);
|
|
||||||
//
|
|
||||||
// final Menu menuIndex = new Menu();
|
|
||||||
// menuIndex.setName("首页");
|
|
||||||
// menuIndex.setUrl("/");
|
|
||||||
// menuIndex.setSort(1);
|
|
||||||
// menuService.create(menuIndex);
|
|
||||||
//
|
|
||||||
// final Menu menuArchive = new Menu();
|
|
||||||
// menuArchive.setName("归档");
|
|
||||||
// menuArchive.setUrl("/archives");
|
|
||||||
// menuArchive.setSort(2);
|
|
||||||
// menuService.create(menuArchive);
|
|
||||||
//
|
|
||||||
// OPTIONS.clear();
|
|
||||||
// OPTIONS.putAll(optionService.listOptions());
|
|
||||||
// configuration.setSharedVariable("options", OPTIONS);
|
|
||||||
//// configuration.setSharedVariable("user", userService.findUser());
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// log.error(e.getMessage());
|
|
||||||
// return new JsonResult(0, e.getMessage());
|
|
||||||
// }
|
|
||||||
// return new JsonResult(1, "安装成功!");
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue