mirror of
https://github.com/201206030/novel-plus.git
synced 2025-07-06 09:17:14 +00:00
feat: 后台网站信息管理
This commit is contained in:
@ -1,18 +0,0 @@
|
||||
package com.java2nb.novel.core.config;
|
||||
|
||||
import com.java2nb.novel.core.converter.DateConverter;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.format.FormatterRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
|
||||
|
||||
/**
|
||||
* @author xiongxiaoyang
|
||||
*/
|
||||
@Configuration
|
||||
public class WebMvcConfig extends WebMvcConfigurerAdapter {
|
||||
@Override
|
||||
public void addFormatters(FormatterRegistry registry) {
|
||||
registry.addConverter(new DateConverter());
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package com.java2nb.novel.core.listener;
|
||||
|
||||
import com.java2nb.novel.core.config.WebsiteProperties;
|
||||
import com.java2nb.novel.entity.WebsiteInfo;
|
||||
import com.java2nb.novel.mapper.WebsiteInfoMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@ -10,6 +12,7 @@ import javax.servlet.annotation.WebListener;
|
||||
|
||||
/**
|
||||
* 启动监听器
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
*/
|
||||
@WebListener
|
||||
@ -17,12 +20,21 @@ import javax.servlet.annotation.WebListener;
|
||||
@RequiredArgsConstructor
|
||||
public class StarterListener implements ServletContextListener {
|
||||
|
||||
private final WebsiteProperties websiteConfig;
|
||||
private final WebsiteProperties websiteProperties;
|
||||
|
||||
private final WebsiteInfoMapper websiteInfoMapper;
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
sce.getServletContext().setAttribute("website",websiteConfig);
|
||||
|
||||
sce.getServletContext()
|
||||
.setAttribute("website", websiteInfoMapper.selectByPrimaryKey(1L).orElse(new WebsiteInfo() {{
|
||||
setName(websiteProperties.getName());
|
||||
setDomain(websiteProperties.getDomain());
|
||||
setKeyword(websiteProperties.getKeyword());
|
||||
setDescription(websiteProperties.getDescription());
|
||||
setQq(websiteProperties.getQq());
|
||||
setLogo("/images/logo.png");
|
||||
setLogoDark("/images/logo_white.png");
|
||||
}}));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user