🔖 修改sys_config表结构,升级时请注意备份本地sys_config表数据

上级 fcf61316
package com.zyd.blog.controller; package com.zyd.blog.controller;
import com.zyd.blog.business.annotation.BussinessLog; import com.zyd.blog.business.annotation.BussinessLog;
import com.zyd.blog.business.entity.Config; import com.zyd.blog.business.entity.BaseConfig;
import com.zyd.blog.business.enums.QiniuUploadType; import com.zyd.blog.business.enums.QiniuUploadType;
import com.zyd.blog.business.service.BizArticleService; import com.zyd.blog.business.service.BizArticleService;
import com.zyd.blog.business.service.SysConfigService; import com.zyd.blog.business.service.SysConfigService;
...@@ -59,7 +59,7 @@ public class RestApiController { ...@@ -59,7 +59,7 @@ public class RestApiController {
@PostMapping("/upload2QiniuForMd") @PostMapping("/upload2QiniuForMd")
public Object upload2QiniuForMd(@RequestParam("file") MultipartFile file) { public Object upload2QiniuForMd(@RequestParam("file") MultipartFile file) {
String filePath = FileUtil.uploadToQiniu(file, QiniuUploadType.SIMPLE, false); String filePath = FileUtil.uploadToQiniu(file, QiniuUploadType.SIMPLE, false);
Config config = configService.get(); BaseConfig config = configService.getBaseConfig();
Map<String, Object> resultMap = new HashMap<>(3); Map<String, Object> resultMap = new HashMap<>(3);
resultMap.put("success", 1); resultMap.put("success", 1);
resultMap.put("message", "上传成功"); resultMap.put("message", "上传成功");
......
...@@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.zyd.blog.business.annotation.BussinessLog; import com.zyd.blog.business.annotation.BussinessLog;
import com.zyd.blog.business.entity.Article; import com.zyd.blog.business.entity.Article;
import com.zyd.blog.business.entity.Config; import com.zyd.blog.business.entity.BaseConfig;
import com.zyd.blog.business.enums.BaiduPushTypeEnum; import com.zyd.blog.business.enums.BaiduPushTypeEnum;
import com.zyd.blog.business.enums.ResponseStatus; import com.zyd.blog.business.enums.ResponseStatus;
import com.zyd.blog.business.service.BizArticleService; import com.zyd.blog.business.service.BizArticleService;
...@@ -93,7 +93,7 @@ public class RestArticleController { ...@@ -93,7 +93,7 @@ public class RestArticleController {
if (null == ids) { if (null == ids) {
return ResultUtil.error(500, "请至少选择一条记录"); return ResultUtil.error(500, "请至少选择一条记录");
} }
Config config = configService.get(); BaseConfig config = configService.getBaseConfig();
String siteUrl = config.getSiteUrl(); String siteUrl = config.getSiteUrl();
StringBuilder params = new StringBuilder(); StringBuilder params = new StringBuilder();
for (Long id : ids) { for (Long id : ids) {
......
package com.zyd.blog.controller; package com.zyd.blog.controller;
import com.zyd.blog.business.annotation.BussinessLog; import com.zyd.blog.business.annotation.BussinessLog;
import com.zyd.blog.business.entity.Config;
import com.zyd.blog.business.enums.QiniuUploadType;
import com.zyd.blog.business.service.SysConfigService; import com.zyd.blog.business.service.SysConfigService;
import com.zyd.blog.framework.object.ResponseVO; import com.zyd.blog.framework.object.ResponseVO;
import com.zyd.blog.util.FileUtil;
import com.zyd.blog.util.ResultUtil; import com.zyd.blog.util.ResultUtil;
import org.apache.shiro.authz.annotation.RequiresRoles; import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -15,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -15,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.Map;
/** /**
* 系统配置 * 系统配置
* *
...@@ -33,23 +32,19 @@ public class RestConfigController { ...@@ -33,23 +32,19 @@ public class RestConfigController {
@RequiresRoles("role:root") @RequiresRoles("role:root")
@PostMapping("/get") @PostMapping("/get")
public ResponseVO get() { public ResponseVO get() {
return ResultUtil.success(null, sysConfigService.get()); return ResultUtil.success(null, sysConfigService.getBaseConfig());
} }
@RequiresRoles("role:root") @RequiresRoles("role:root")
@PostMapping("/edit") @PostMapping("/save")
@BussinessLog("修改系统配置") @BussinessLog("修改系统配置")
public ResponseVO edit(Config config, public ResponseVO save(@RequestParam Map<String, String> configs,
@RequestParam(required = false) MultipartFile wxPraiseCodeFile, @RequestParam(required = false) MultipartFile wxPraiseCodeFile,
@RequestParam(required = false) MultipartFile zfbPraiseCodeFile) { @RequestParam(required = false) MultipartFile zfbPraiseCodeFile) {
config.setWxPraiseCode(FileUtil.uploadToQiniu(wxPraiseCodeFile, QiniuUploadType.QRCODE, true));
config.setZfbPraiseCode(FileUtil.uploadToQiniu(zfbPraiseCodeFile, QiniuUploadType.QRCODE, true));
if(null != wxPraiseCodeFile || null != zfbPraiseCodeFile){
Config configDB = sysConfigService.get();
FileUtil.removeQiniu(configDB.getWxPraiseCode(), configDB.getZfbPraiseCode());
}
try { try {
sysConfigService.update(config); sysConfigService.saveConfig(configs);
sysConfigService.saveFile("wx_praise_code", wxPraiseCodeFile);
sysConfigService.saveFile("zfb_praise_code", zfbPraiseCodeFile);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return ResultUtil.error("系统配置修改失败"); return ResultUtil.error("系统配置修改失败");
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
<dependency> <dependency>
<groupId>org.mybatis.spring.boot</groupId> <groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId> <artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.1</version> <version>1.3.2</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.apache.tomcat</groupId> <groupId>org.apache.tomcat</groupId>
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
<dependency> <dependency>
<groupId>tk.mybatis</groupId> <groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId> <artifactId>mapper-spring-boot-starter</artifactId>
<version>1.1.4</version> <version>2.1.0</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<artifactId>mybatis-spring-boot-starter</artifactId> <artifactId>mybatis-spring-boot-starter</artifactId>
...@@ -90,6 +90,12 @@ ...@@ -90,6 +90,12 @@
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<!--druid依赖添加-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.10</version>
</dependency>
<!--springboot 集成Mybatis所需jar配置 end --> <!--springboot 集成Mybatis所需jar配置 end -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
...@@ -100,12 +106,6 @@ ...@@ -100,12 +106,6 @@
<artifactId>fastjson</artifactId> <artifactId>fastjson</artifactId>
<version>1.2.44</version> <version>1.2.44</version>
</dependency> </dependency>
<!--druid依赖添加-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.10</version>
</dependency>
<!--shiro依赖添加--> <!--shiro依赖添加-->
<dependency> <dependency>
<groupId>org.apache.shiro</groupId> <groupId>org.apache.shiro</groupId>
......
...@@ -63,8 +63,6 @@ public class BussinessLogAspect { ...@@ -63,8 +63,6 @@ public class BussinessLogAspect {
} }
private void handle(ProceedingJoinPoint point) throws Exception { private void handle(ProceedingJoinPoint point) throws Exception {
//获取拦截方法的参数
String className = AspectUtil.getClassName(point);
Method currentMethod = AspectUtil.getMethod(point); Method currentMethod = AspectUtil.getMethod(point);
//获取操作名称 //获取操作名称
BussinessLog annotation = currentMethod.getAnnotation(BussinessLog.class); BussinessLog annotation = currentMethod.getAnnotation(BussinessLog.class);
...@@ -73,9 +71,7 @@ public class BussinessLogAspect { ...@@ -73,9 +71,7 @@ public class BussinessLogAspect {
String bussinessName = parseContent(point.getArgs(), annotation.value()); String bussinessName = parseContent(point.getArgs(), annotation.value());
String ua = RequestUtil.getUa(); String ua = RequestUtil.getUa();
log.info("{}-{}.{}", bussinessName, className, currentMethod.getName()); log.info("{} | {} - {} {} - {}", bussinessName, RequestUtil.getIp(), RequestUtil.getMethod(), RequestUtil.getRequestUrl(), ua);
log.info("IP: {}, Method: {}, Request URL: {}", RequestUtil.getIp(), RequestUtil.getMethod(), RequestUtil.getRequestUrl());
log.info("User-Agent: " + ua);
if (!save) { if (!save) {
return; return;
} }
...@@ -89,7 +85,7 @@ public class BussinessLogAspect { ...@@ -89,7 +85,7 @@ public class BussinessLogAspect {
sysLog.setSpiderType(WebSpiderUtils.parseUa(ua)); sysLog.setSpiderType(WebSpiderUtils.parseUa(ua));
sysLog.setParams(JSONObject.toJSONString(RequestUtil.getParametersMap())); sysLog.setParams(JSONObject.toJSONString(RequestUtil.getParametersMap()));
User user = SessionUtil.getUser(); User user = SessionUtil.getUser();
if(user != null) { if (user != null) {
sysLog.setUserId(user.getId()); sysLog.setUserId(user.getId());
sysLog.setContent(String.format("用户: [%s] | 操作: %s", user.getUsername(), bussinessName)); sysLog.setContent(String.format("用户: [%s] | 操作: %s", user.getUsername(), bussinessName));
} else { } else {
......
package com.zyd.blog.business.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2019/01/16 12:26
* @since 1.0
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class BaseConfig {
private String homeDesc;
private String homeKeywords;
private String domain;
private String cmsUrl;
private String siteUrl;
private String siteName;
private String siteDesc;
private String siteFavicon;
private String staticWebSite;
private String authorName;
private String authorEmail;
private String wxCode;
private String qq;
private String weibo;
private String github;
private Boolean maintenance;
private Date maintenanceDate;
private Boolean comment;
private String qiniuBasePath;
private String qiniuAccessKey;
private String qiniuSecretKey;
private String qiniuBucketName;
private String baiduPushToken;
/**
* 赞赏码
*/
private String wxPraiseCode;
private String zfbPraiseCode;
/**
* 百度api授权AK(获取地址:http://lbsyun.baidu.com/apiconsole/key)
* 调用百度的api时必须
*/
private String baiduApiAk;
private Date updateTime;
}
package com.zyd.blog.business.entity; package com.zyd.blog.business.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.zyd.blog.business.consts.DateConst;
import com.zyd.blog.persistence.beans.SysConfig; import com.zyd.blog.persistence.beans.SysConfig;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date; import java.util.Date;
...@@ -39,152 +36,28 @@ public class Config { ...@@ -39,152 +36,28 @@ public class Config {
this.sysConfig.setId(id); this.sysConfig.setId(id);
} }
public String getHomeDesc() { public String getConfigKey() {
return this.sysConfig.getHomeDesc(); return this.sysConfig.getConfigKey();
} }
public void setHomeDesc(String homeDesc) { public void setConfigKey(String key) {
this.sysConfig.setHomeDesc(homeDesc); this.sysConfig.setConfigKey(key);
} }
public String getHomeKeywords() { public String getConfigValue() {
return this.sysConfig.getHomeKeywords(); return this.sysConfig.getConfigValue();
} }
public void setHomeKeywords(String homeKeywords) { public void setConfigValue(String value) {
this.sysConfig.setHomeKeywords(homeKeywords); this.sysConfig.setConfigValue(value);
} }
public String getDomain() { public String getConfigDesc() {
return this.sysConfig.getDomain(); return this.sysConfig.getConfigDesc();
} }
public void setDomain(String domain) { public void setConfigDesc(String desc) {
this.sysConfig.setDomain(domain); this.sysConfig.setConfigDesc(desc);
}
public String getCmsUrl() {
return this.sysConfig.getCmsUrl();
}
public void setCmsUrl(String cmsUrl) {
this.sysConfig.setCmsUrl(cmsUrl);
}
public String getSiteUrl() {
return this.sysConfig.getSiteUrl();
}
public void setSiteUrl(String siteUrl) {
this.sysConfig.setSiteUrl(siteUrl);
}
public String getSiteName() {
return this.sysConfig.getSiteName();
}
public void setSiteName(String siteName) {
this.sysConfig.setSiteName(siteName);
}
public String getSiteDesc() {
return this.sysConfig.getSiteDesc();
}
public void setSiteDesc(String siteDesc) {
this.sysConfig.setSiteDesc(siteDesc);
}
public String getSiteFavicon() {
return this.sysConfig.getSiteFavicon();
}
public void setSiteFavicon(String siteFavicon) {
this.sysConfig.setSiteFavicon(siteFavicon);
}
public String getStaticWebSite() {
return this.sysConfig.getStaticWebSite();
}
public void setStaticWebSite(String staticWebSite) {
this.sysConfig.setStaticWebSite(staticWebSite);
}
public String getAuthorName() {
return this.sysConfig.getAuthorName();
}
public void setAuthorName(String authorName) {
this.sysConfig.setAuthorName(authorName);
}
public String getAuthorEmail() {
return this.sysConfig.getAuthorEmail();
}
public void setAuthorEmail(String authorEmail) {
this.sysConfig.setAuthorEmail(authorEmail);
}
public String getWxCode() {
return this.sysConfig.getWxCode();
}
public void setWxCode(String wxCode) {
this.sysConfig.setWxCode(wxCode);
}
public String getQq() {
return this.sysConfig.getQq();
}
public void setQq(String qq) {
this.sysConfig.setQq(qq);
}
public String getWeibo() {
return this.sysConfig.getWeibo();
}
public void setWeibo(String weibo) {
this.sysConfig.setWeibo(weibo);
}
public String getGithub() {
return this.sysConfig.getGithub();
}
public void setGithub(String github) {
this.sysConfig.setGithub(github);
}
public boolean isMaintenance() {
Boolean value = this.sysConfig.getMaintenance();
return value != null ? value : false;
}
public void setMaintenance(boolean maintenance) {
this.sysConfig.setMaintenance(maintenance);
}
@JsonFormat(timezone = "GMT+8", pattern = DateConst.YYYY_MM_DD_HH_MM_SS_EN)
public Date getMaintenanceDate() {
return this.sysConfig.getMaintenanceDate();
}
@DateTimeFormat(pattern = DateConst.YYYY_MM_DD_HH_MM_SS_EN)
public void setMaintenanceDate(Date maintenanceDate) {
this.sysConfig.setMaintenanceDate(maintenanceDate);
}
public boolean isComment() {
Boolean value = this.sysConfig.getComment();
return value != null ? value : false;
}
public void setComment(boolean comment) {
this.sysConfig.setComment(comment);
} }
public Date getCreateTime() { public Date getCreateTime() {
...@@ -203,69 +76,5 @@ public class Config { ...@@ -203,69 +76,5 @@ public class Config {
this.sysConfig.setUpdateTime(updateTime); this.sysConfig.setUpdateTime(updateTime);
} }
public String getQiniuBasePath() {
return this.sysConfig.getQiniuBasePath();
}
public void setQiniuBasePath(String qiniuBasePath) {
this.sysConfig.setQiniuBasePath(qiniuBasePath);
}
public String getQiniuAccessKey() {
return this.sysConfig.getQiniuAccessKey();
}
public void setQiniuAccessKey(String qiniuAccessKey) {
this.sysConfig.setQiniuAccessKey(qiniuAccessKey);
}
public String getQiniuSecretKey() {
return this.sysConfig.getQiniuSecretKey();
}
public void setQiniuSecretKey(String qiniuSecretKey) {
this.sysConfig.setQiniuSecretKey(qiniuSecretKey);
}
public String getQiniuBucketName() {
return this.sysConfig.getQiniuBucketName();
}
public void setQiniuBucketName(String qiniuBucketName) {
this.sysConfig.setQiniuBucketName(qiniuBucketName);
}
public String getBaiduPushToken(){
return this.sysConfig.getBaiduPushToken();
}
public void setBaiduPushToken(String baiduPushToken){
this.sysConfig.setBaiduPushToken(baiduPushToken);
}
public String getWxPraiseCode(){
return this.sysConfig.getWxPraiseCode();
}
public void setWxPraiseCode(String wxPraiseCode){
this.sysConfig.setWxPraiseCode(wxPraiseCode);
}
public String getZfbPraiseCode(){
return this.sysConfig.getZfbPraiseCode();
}
public void setZfbPraiseCode(String zfbPraiseCode){
this.sysConfig.setZfbPraiseCode(zfbPraiseCode);
}
public String getBaiduApiAk(){
return this.sysConfig.getBaiduApiAk();
}
public void setBaiduApiAk(String baiduApiAk){
this.sysConfig.setBaiduApiAk(baiduApiAk);
}
} }
package com.zyd.blog.business.service; package com.zyd.blog.business.service;
import com.zyd.blog.business.entity.Config; import com.zyd.blog.business.entity.BaseConfig;
import com.zyd.blog.persistence.beans.SysConfig;
import org.springframework.web.multipart.MultipartFile;
import java.util.Map; import java.util.Map;
...@@ -21,34 +23,40 @@ public interface SysConfigService { ...@@ -21,34 +23,40 @@ public interface SysConfigService {
* *
* @return * @return
*/ */
Config get(); BaseConfig getBaseConfig();
/** /**
* 添加系统配置 * 添加/修改系统配置
* *
* @param config * @param configs 所有的配置项
* @return
*/ */
Config insert(Config config); void saveConfig(Map<String, String> configs);
/** /**
* 删除系统配置记录 * 添加/修改文件的配置项
* *
* @param id * @param key key
* @param file 微信收款码
*/ */
void remove(Long id); void saveFile(String key, MultipartFile file);
/** /**
* 修改系统配置记录 * 添加/修改单个
* *
* @param config * @param key key
* @param value value
*/ */
void update(Config config); void saveConfig(String key, String value);
/** /**
* 获取网站详情 * 获取单个配置
* *
* @return * @param key key
*/
SysConfig getByKey(String key);
/**
* 获取网站详情
*/ */
Map<String, Object> getSiteInfo(); Map<String, Object> getSiteInfo();
} }
...@@ -5,8 +5,8 @@ import com.github.pagehelper.PageHelper; ...@@ -5,8 +5,8 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.zyd.blog.business.annotation.RedisCache; import com.zyd.blog.business.annotation.RedisCache;
import com.zyd.blog.business.dto.BizCommentDTO; import com.zyd.blog.business.dto.BizCommentDTO;
import com.zyd.blog.business.entity.BaseConfig;
import com.zyd.blog.business.entity.Comment; import com.zyd.blog.business.entity.Comment;
import com.zyd.blog.business.entity.Config;
import com.zyd.blog.business.entity.User; import com.zyd.blog.business.entity.User;
import com.zyd.blog.business.enums.CommentStatusEnum; import com.zyd.blog.business.enums.CommentStatusEnum;
import com.zyd.blog.business.enums.TemplateKeyEnum; import com.zyd.blog.business.enums.TemplateKeyEnum;
...@@ -124,7 +124,7 @@ public class BizCommentServiceImpl implements BizCommentService { ...@@ -124,7 +124,7 @@ public class BizCommentServiceImpl implements BizCommentService {
@Override @Override
@RedisCache(flush = true) @RedisCache(flush = true)
public void commentForAdmin(Comment comment) throws ZhydCommentException { public void commentForAdmin(Comment comment) throws ZhydCommentException {
Config config = configService.get(); BaseConfig config = configService.getBaseConfig();
User user = SessionUtil.getUser(); User user = SessionUtil.getUser();
comment.setQq(user.getQq()); comment.setQq(user.getQq());
comment.setEmail(user.getEmail()); comment.setEmail(user.getEmail());
...@@ -184,7 +184,7 @@ public class BizCommentServiceImpl implements BizCommentService { ...@@ -184,7 +184,7 @@ public class BizCommentServiceImpl implements BizCommentService {
// comment.setOsShortName(os.getShortName());// 此处需开发者自己处理 // comment.setOsShortName(os.getShortName());// 此处需开发者自己处理
comment.setIp(IpUtil.getRealIp(request)); comment.setIp(IpUtil.getRealIp(request));
String address = "定位失败"; String address = "定位失败";
Config config = configService.get(); BaseConfig config = configService.getBaseConfig();
try { try {
String locationJson = RestClientUtil.get(UrlBuildUtil.getLocationByIp(comment.getIp(), config.getBaiduApiAk())); String locationJson = RestClientUtil.get(UrlBuildUtil.getLocationByIp(comment.getIp(), config.getBaiduApiAk()));
JSONObject localtionContent = JSONObject.parseObject(locationJson).getJSONObject("content"); JSONObject localtionContent = JSONObject.parseObject(locationJson).getJSONObject("content");
......
package com.zyd.blog.business.service.impl; package com.zyd.blog.business.service.impl;
import com.zyd.blog.business.entity.Comment; import com.zyd.blog.business.entity.*;
import com.zyd.blog.business.entity.Config;
import com.zyd.blog.business.entity.Link;
import com.zyd.blog.business.entity.MailDetail;
import com.zyd.blog.business.entity.Template;
import com.zyd.blog.business.enums.TemplateKeyEnum; import com.zyd.blog.business.enums.TemplateKeyEnum;
import com.zyd.blog.business.service.MailService; import com.zyd.blog.business.service.MailService;
import com.zyd.blog.business.service.SysConfigService; import com.zyd.blog.business.service.SysConfigService;
...@@ -73,7 +69,7 @@ public class MailServiceImpl implements MailService { ...@@ -73,7 +69,7 @@ public class MailServiceImpl implements MailService {
@Async @Async
public void send(Link link, TemplateKeyEnum keyEnum) { public void send(Link link, TemplateKeyEnum keyEnum) {
if (!StringUtils.isEmpty(link.getEmail())) { if (!StringUtils.isEmpty(link.getEmail())) {
Config config = configService.get(); BaseConfig config = configService.getBaseConfig();
Template template = templateService.getTemplate(keyEnum); Template template = templateService.getTemplate(keyEnum);
String temXml = template.getRefValue(); String temXml = template.getRefValue();
Map<String, Object> map = new HashMap<>(2); Map<String, Object> map = new HashMap<>(2);
...@@ -102,7 +98,7 @@ public class MailServiceImpl implements MailService { ...@@ -102,7 +98,7 @@ public class MailServiceImpl implements MailService {
this.sendToAdmin(comment); this.sendToAdmin(comment);
return; return;
} }
Config config = configService.get(); BaseConfig config = configService.getBaseConfig();
Template template = templateService.getTemplate(keyEnum); Template template = templateService.getTemplate(keyEnum);
String temXml = template.getRefValue(); String temXml = template.getRefValue();
Map<String, Object> map = new HashMap<>(2); Map<String, Object> map = new HashMap<>(2);
...@@ -128,7 +124,7 @@ public class MailServiceImpl implements MailService { ...@@ -128,7 +124,7 @@ public class MailServiceImpl implements MailService {
@Override @Override
@Async @Async
public void sendToAdmin(Link link) { public void sendToAdmin(Link link) {
Config config = configService.get(); BaseConfig config = configService.getBaseConfig();
Template template = templateService.getTemplate(TemplateKeyEnum.TM_LINKS_TO_ADMIN); Template template = templateService.getTemplate(TemplateKeyEnum.TM_LINKS_TO_ADMIN);
String temXml = template.getRefValue(); String temXml = template.getRefValue();
Map<String, Object> map = new HashMap<>(1); Map<String, Object> map = new HashMap<>(1);
...@@ -152,7 +148,7 @@ public class MailServiceImpl implements MailService { ...@@ -152,7 +148,7 @@ public class MailServiceImpl implements MailService {
@Override @Override
@Async @Async
public void sendToAdmin(Comment comment) { public void sendToAdmin(Comment comment) {
Config config = configService.get(); BaseConfig config = configService.getBaseConfig();
Template template = templateService.getTemplate(TemplateKeyEnum.TM_NEW_COMMENT); Template template = templateService.getTemplate(TemplateKeyEnum.TM_NEW_COMMENT);
String temXml = template.getRefValue(); String temXml = template.getRefValue();
Map<String, Object> map = new HashMap<>(2); Map<String, Object> map = new HashMap<>(2);
......
...@@ -86,7 +86,7 @@ public class RemoverServiceImpl implements RemoverService { ...@@ -86,7 +86,7 @@ public class RemoverServiceImpl implements RemoverService {
// 处理标签,并获取最终待添加的标签id // 处理标签,并获取最终待添加的标签id
List<Long> tagIds = null; List<Long> tagIds = null;
Tags newTag = null; Tags newTag = null;
String qiniuBasePath = sysConfigService.get().getQiniuBasePath(); String qiniuBasePath = sysConfigService.getBaseConfig().getQiniuBasePath();
for (Article spiderArticle : list) { for (Article spiderArticle : list) {
writerUtil.print("------------------------------------------------------------------------------------"); writerUtil.print("------------------------------------------------------------------------------------");
writerUtil.print(String.format("准备持久化 - %s", spiderArticle.getTitle())); writerUtil.print(String.format("准备持久化 - %s", spiderArticle.getTitle()));
......
package com.zyd.blog.business.service.impl; package com.zyd.blog.business.service.impl;
import com.zyd.blog.business.annotation.RedisCache; import com.alibaba.fastjson.JSON;
import com.zyd.blog.business.entity.Config; import com.zyd.blog.business.consts.DateConst;
import com.zyd.blog.business.entity.BaseConfig;
import com.zyd.blog.business.enums.QiniuUploadType;
import com.zyd.blog.business.service.SysConfigService; import com.zyd.blog.business.service.SysConfigService;
import com.zyd.blog.framework.property.AppProperties; import com.zyd.blog.framework.property.AppProperties;
import com.zyd.blog.persistence.beans.SysConfig; import com.zyd.blog.persistence.beans.SysConfig;
import com.zyd.blog.persistence.mapper.SysConfigMapper; import com.zyd.blog.persistence.mapper.SysConfigMapper;
import com.zyd.blog.util.DateUtil; import com.zyd.blog.util.DateUtil;
import com.zyd.blog.util.FileUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -38,63 +44,82 @@ public class SysConfigServiceImpl implements SysConfigService { ...@@ -38,63 +44,82 @@ public class SysConfigServiceImpl implements SysConfigService {
* @return * @return
*/ */
@Override @Override
@RedisCache public BaseConfig getBaseConfig() {
public Config get() { List<SysConfig> list = sysConfigMapper.selectAll();
SysConfig config = sysConfigMapper.get(); if (CollectionUtils.isEmpty(list)) {
return null == config ? null : new Config(config); return null;
}
String updateTimeKey = "updateTime";
Map<String, Object> res = new HashMap<>();
res.put(updateTimeKey, DateUtil.str2Date("2019-01-01 00:00:00", DateConst.YYYY_MM_DD_HH_MM_SS_EN));
list.forEach((sysConfig) -> {
res.put(String.valueOf(sysConfig.getConfigKey()), sysConfig.getConfigValue());
if (sysConfig.getUpdateTime().after(((Date) res.get(updateTimeKey)))) {
res.put(updateTimeKey, sysConfig.getUpdateTime());
}
});
return JSON.parseObject(JSON.toJSONString(res), BaseConfig.class);
} }
/**
* 添加系统配置
*
* @param config
* @return
*/
@Override @Override
@RedisCache(flush = true) public void saveFile(String key, MultipartFile file) {
public Config insert(Config config) { if (key == null) {
config.setCreateTime(new Date()); return;
config.setUpdateTime(new Date()); }
sysConfigMapper.insert(config.getSysConfig()); if (file != null) {
return config; this.saveConfig(key, FileUtil.uploadToQiniu(file, QiniuUploadType.QRCODE, true));
}
} }
/**
* 删除系统配置记录
*
* @param id
*/
@Override @Override
@RedisCache(flush = true) public void saveConfig(String key, String value) {
public void remove(Long id) { if (!StringUtils.isEmpty(key)) {
sysConfigMapper.deleteByPrimaryKey(id); SysConfig config = null;
if (null == (config = this.getByKey(key))) {
config = new SysConfig();
config.setConfigKey(key);
config.setConfigValue(value);
config.setCreateTime(new Date());
config.setUpdateTime(new Date());
this.sysConfigMapper.insert(config);
} else {
config.setConfigKey(key);
config.setConfigValue(value);
config.setUpdateTime(new Date());
this.sysConfigMapper.updateByPrimaryKeySelective(config);
}
}
}
@Override
public SysConfig getByKey(String key) {
if (StringUtils.isEmpty(key)) {
return null;
}
SysConfig sysConfig = new SysConfig();
sysConfig.setConfigKey(key);
return this.sysConfigMapper.selectOne(sysConfig);
} }
/** /**
* 修改系统配置记录 * 添加/修改系统配置
* *
* @param config * @param configs 所有的配置项
*/ */
@Override @Override
@RedisCache(flush = true) public void saveConfig(Map<String, String> configs) {
public void update(Config config) { if (!CollectionUtils.isEmpty(configs)) {
config.setUpdateTime(new Date()); configs.forEach(this::saveConfig);
sysConfigMapper.updateByPrimaryKeySelective(config.getSysConfig()); }
} }
/** /**
* 获取网站详情 * 获取网站详情
*
* @return
*/ */
@Override @Override
public Map<String, Object> getSiteInfo() { public Map<String, Object> getSiteInfo() {
Map<String, Object> map = sysConfigMapper.getSiteInfo(); Map<String, Object> map = sysConfigMapper.getSiteInfo();
if (!CollectionUtils.isEmpty(map)) { if (!CollectionUtils.isEmpty(map)) {
Date lastUpdateTime = (Date) map.get("lastUpdateTime");
if (!StringUtils.isEmpty(lastUpdateTime)) {
map.put("lastUpdateTime", DateUtil.date2Str(lastUpdateTime, "yyyy年MM月dd日HH点"));
}
// 获取建站天数 // 获取建站天数
map.put("buildSiteDate", DateUtil.getGapDay(properties.getBuildWebsiteDate(), new Date())); map.put("buildSiteDate", DateUtil.getGapDay(properties.getBuildWebsiteDate(), new Date()));
} }
......
...@@ -3,7 +3,7 @@ package com.zyd.blog.business.service.impl; ...@@ -3,7 +3,7 @@ package com.zyd.blog.business.service.impl;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.zyd.blog.business.annotation.RedisCache; import com.zyd.blog.business.annotation.RedisCache;
import com.zyd.blog.business.entity.Config; import com.zyd.blog.business.entity.BaseConfig;
import com.zyd.blog.business.entity.Link; import com.zyd.blog.business.entity.Link;
import com.zyd.blog.business.enums.LinkSourceEnum; import com.zyd.blog.business.enums.LinkSourceEnum;
import com.zyd.blog.business.enums.TemplateKeyEnum; import com.zyd.blog.business.enums.TemplateKeyEnum;
...@@ -146,7 +146,7 @@ public class SysLinkServiceImpl implements SysLinkService { ...@@ -146,7 +146,7 @@ public class SysLinkServiceImpl implements SysLinkService {
if (bo != null) { if (bo != null) {
throw new ZhydLinkException("本站已经添加过贵站的链接!"); throw new ZhydLinkException("本站已经添加过贵站的链接!");
} }
Config config = configService.get(); BaseConfig config = configService.getBaseConfig();
if (!(LinksUtil.hasLinkByHtml(url, config.getDomain())) if (!(LinksUtil.hasLinkByHtml(url, config.getDomain()))
&& !LinksUtil.hasLinkByChinaz(url, config.getDomain())) { && !LinksUtil.hasLinkByChinaz(url, config.getDomain())) {
throw new ZhydLinkException("贵站暂未添加本站友情链接!请先添加本站友链后重新提交申请!"); throw new ZhydLinkException("贵站暂未添加本站友情链接!请先添加本站友链后重新提交申请!");
......
package com.zyd.blog.framework.config; package com.zyd.blog.framework.config;
import org.mybatis.spring.annotation.MapperScan; import tk.mybatis.spring.annotation.MapperScan;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
......
package com.zyd.blog.framework.runner; package com.zyd.blog.framework.runner;
import com.zyd.blog.business.consts.DateConst;
import com.zyd.blog.util.DateUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner; import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Date;
/** /**
* 程序启动后通过ApplicationRunner处理一些事务 * 程序启动后通过ApplicationRunner处理一些事务
* *
...@@ -22,8 +19,11 @@ import java.util.Date; ...@@ -22,8 +19,11 @@ import java.util.Date;
@Component @Component
public class BlogApplicationRunner implements ApplicationRunner { public class BlogApplicationRunner implements ApplicationRunner {
@Value("${server.port}")
private int port;
@Override @Override
public void run(ApplicationArguments applicationArguments) { public void run(ApplicationArguments applicationArguments) {
log.info("博客部署完成,当前时间:" + DateUtil.date2Str(new Date(), DateConst.YYYY_MM_DD_HH_MM_SS_EN)); log.info("博客部署完成,博客访问地址:http://localhost:" + port);
} }
} }
...@@ -4,54 +4,17 @@ import com.zyd.blog.framework.object.AbstractDO; ...@@ -4,54 +4,17 @@ import com.zyd.blog.framework.object.AbstractDO;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.util.Date;
/** /**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com) * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @website https://www.zhyd.me
* @version 1.0 * @version 1.0
* @website https://www.zhyd.me
* @date 2018/4/16 16:26 * @date 2018/4/16 16:26
* @since 1.0 * @since 1.0
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class SysConfig extends AbstractDO { public class SysConfig extends AbstractDO {
private String homeDesc; private String configKey;
private String homeKeywords; private String configValue;
private String domain; private String configDesc;
private String cmsUrl;
private String siteUrl;
private String siteName;
private String siteDesc;
private String siteFavicon;
private String staticWebSite;
private String authorName;
private String authorEmail;
private String wxCode;
private String qq;
private String weibo;
private String github;
private Boolean maintenance;
private Date maintenanceDate;
private Boolean comment;
private String qiniuBasePath;
private String qiniuAccessKey;
private String qiniuSecretKey;
private String qiniuBucketName;
private String baiduPushToken;
/**
* 赞赏码
*/
private String wxPraiseCode;
private String zfbPraiseCode;
/**
* 百度api授权AK(获取地址:http://lbsyun.baidu.com/apiconsole/key)
* 调用百度的api时必须
*/
private String baiduApiAk;
} }
...@@ -8,15 +8,12 @@ import java.util.Map; ...@@ -8,15 +8,12 @@ import java.util.Map;
/** /**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com) * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @website https://www.zhyd.me
* @version 1.0 * @version 1.0
* @website https://www.zhyd.me
* @date 2018/4/16 16:26 * @date 2018/4/16 16:26
* @since 1.0 * @since 1.0
*/ */
@Repository @Repository
public interface SysConfigMapper extends BaseMapper<SysConfig> { public interface SysConfigMapper extends BaseMapper<SysConfig> {
SysConfig get();
Map<String, Object> getSiteInfo(); Map<String, Object> getSiteInfo();
} }
...@@ -9,7 +9,7 @@ import com.qiniu.util.Auth; ...@@ -9,7 +9,7 @@ import com.qiniu.util.Auth;
import com.qiniu.util.StringMap; import com.qiniu.util.StringMap;
import com.zyd.blog.business.consts.CommonConst; import com.zyd.blog.business.consts.CommonConst;
import com.zyd.blog.business.consts.DateConst; import com.zyd.blog.business.consts.DateConst;
import com.zyd.blog.business.entity.Config; import com.zyd.blog.business.entity.BaseConfig;
import com.zyd.blog.business.enums.QiniuUploadType; import com.zyd.blog.business.enums.QiniuUploadType;
import com.zyd.blog.business.service.SysConfigService; import com.zyd.blog.business.service.SysConfigService;
import com.zyd.blog.framework.holder.SpringContextHolder; import com.zyd.blog.framework.holder.SpringContextHolder;
...@@ -33,14 +33,14 @@ import java.util.Date; ...@@ -33,14 +33,14 @@ import java.util.Date;
@Slf4j @Slf4j
public class QiniuApi { public class QiniuApi {
private static final Object LOCK = new Object(); private static final Object LOCK = new Object();
private Config config; private BaseConfig config;
private String key; private String key;
private Auth auth; private Auth auth;
private UploadManager uploadManager; private UploadManager uploadManager;
private QiniuApi() { private QiniuApi() {
SysConfigService configService = SpringContextHolder.getBean(SysConfigService.class); SysConfigService configService = SpringContextHolder.getBean(SysConfigService.class);
this.config = configService.get(); this.config = configService.getBaseConfig();
auth = Auth.create(config.getQiniuAccessKey(), config.getQiniuSecretKey()); auth = Auth.create(config.getQiniuAccessKey(), config.getQiniuSecretKey());
uploadManager = new UploadManager(); uploadManager = new UploadManager();
} }
...@@ -64,7 +64,7 @@ public class QiniuApi { ...@@ -64,7 +64,7 @@ public class QiniuApi {
} }
private String getUpToken() { private String getUpToken() {
return this.auth.uploadToken(config.getQiniuBucketName(), this.key, 3600L, new StringMap().put("insertOnly", Integer.valueOf(1))); return this.auth.uploadToken(config.getQiniuBucketName(), this.key, 3600L, new StringMap().put("insertOnly", 1));
} }
public String upload(File fileByte) throws IOException { public String upload(File fileByte) throws IOException {
......
...@@ -2,46 +2,6 @@ ...@@ -2,46 +2,6 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.zyd.blog.persistence.mapper.SysConfigMapper"> <mapper namespace="com.zyd.blog.persistence.mapper.SysConfigMapper">
<resultMap id="rm" type="com.zyd.blog.persistence.beans.SysConfig">
<result property="id" jdbcType="INTEGER" column="id"/>
<result property="homeDesc" jdbcType="VARCHAR" column="home_desc"/>
<result property="homeKeywords" jdbcType="VARCHAR" column="home_keywords"/>
<result property="domain" jdbcType="VARCHAR" column="domain"/>
<result property="cmsUrl" jdbcType="VARCHAR" column="cms_url"/>
<result property="siteUrl" jdbcType="VARCHAR" column="site_url"/>
<result property="siteName" jdbcType="VARCHAR" column="site_name"/>
<result property="siteDesc" jdbcType="VARCHAR" column="site_desc"/>
<result property="siteFavicon" jdbcType="VARCHAR" column="site_favicon"/>
<result property="staticWebSite" jdbcType="VARCHAR" column="static_web_site"/>
<result property="authorName" jdbcType="VARCHAR" column="author_name"/>
<result property="authorEmail" jdbcType="VARCHAR" column="author_email"/>
<result property="wxCode" jdbcType="VARCHAR" column="wx_code"/>
<result property="qq" jdbcType="VARCHAR" column="qq"/>
<result property="weibo" jdbcType="VARCHAR" column="weibo"/>
<result property="github" jdbcType="VARCHAR" column="github"/>
<result property="maintenance" jdbcType="BIT" column="maintenance"/>
<result property="maintenanceDate" jdbcType="TIMESTAMP" column="maintenance_date"/>
<result property="comment" jdbcType="BIT" column="comment"/>
<result property="qiniuBasePath" jdbcType="VARCHAR" column="qiniu_base_path"/>
<result property="qiniuAccessKey" jdbcType="VARCHAR" column="qiniu_access_key"/>
<result property="qiniuSecretKey" jdbcType="VARCHAR" column="qiniu_secret_key"/>
<result property="qiniuBucketName" jdbcType="VARCHAR" column="qiniu_bucket_name"/>
<result property="baiduPushToken" jdbcType="VARCHAR" column="baidu_push_token"/>
<result property="wxPraiseCode" jdbcType="VARCHAR" column="wx_praise_code"/>
<result property="zfbPraiseCode" jdbcType="VARCHAR" column="zfb_praise_code"/>
<result property="baiduApiAk" jdbcType="VARCHAR" column="baidu_api_ak"/>
<result property="createTime" jdbcType="TIMESTAMP" column="create_time"/>
<result property="updateTime" jdbcType="TIMESTAMP" column="update_time"/>
</resultMap>
<select id="get" resultMap="rm">
SELECT
t.*
FROM
sys_config t
WHERE
1 = 1
</select>
<select id="getSiteInfo" resultType="map"> <select id="getSiteInfo" resultType="map">
SELECT SELECT
...@@ -80,7 +40,7 @@ ...@@ -80,7 +40,7 @@
) c, ) c,
( (
SELECT SELECT
recorde_time DATE_FORMAT(recorde_time,'%Y年%m月%d日%H点') AS recorde_time
FROM FROM
sys_update_recorde sys_update_recorde
ORDER BY ORDER BY
......
...@@ -66,7 +66,7 @@ public class RestWebSiteController { ...@@ -66,7 +66,7 @@ public class RestWebSiteController {
map.put("articleTypeList", typeService.listAll()); map.put("articleTypeList", typeService.listAll());
map.put("articleTagsList", tagsService.listAll()); map.put("articleTagsList", tagsService.listAll());
map.put("articleList", articleService.listAll()); map.put("articleList", articleService.listAll());
map.put("config", configService.get()); map.put("config", configService.getBaseConfig());
return FreeMarkerUtil.template2String(template.getRefValue(), map, true); return FreeMarkerUtil.template2String(template.getRefValue(), map, true);
} }
} }
package com.zyd.blog.service;
import com.alibaba.fastjson.JSON;
import com.zyd.blog.BaseJunitTest;
import com.zyd.blog.business.service.SysConfigService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2019/1/7 14:35
* @since 1.8
*/
public class SysConfigServiceImplTest extends BaseJunitTest {
@Autowired
private SysConfigService configService;
@Test
public void comment() throws InterruptedException {
System.out.println(JSON.toJSONString(configService.getBaseConfig()));
}
}
...@@ -154,32 +154,8 @@ CREATE TABLE `biz_type` ( ...@@ -154,32 +154,8 @@ CREATE TABLE `biz_type` (
DROP TABLE IF EXISTS `sys_config`; DROP TABLE IF EXISTS `sys_config`;
CREATE TABLE `sys_config` ( CREATE TABLE `sys_config` (
`id` int(20) UNSIGNED NOT NULL AUTO_INCREMENT, `id` int(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`home_desc` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '首页描述', `config_key` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '首页描述',
`home_keywords` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '首页关键字', `config_value` varchar(300) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '首页关键字',
`domain` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '根域名',
`cms_url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '管理系统的url',
`site_url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '网站地址',
`site_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '站点名称',
`site_desc` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '站点描述',
`site_favicon` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '站点LOGO',
`static_web_site` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '资源文件(js、css等的路径)',
`author_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '站长名称',
`author_email` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '站长邮箱',
`wx_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '微信二维码地址',
`qq` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'QQ',
`weibo` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '微博',
`github` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'github',
`maintenance` tinyint(1) UNSIGNED NULL DEFAULT NULL COMMENT '是否开启维护通知',
`maintenance_date` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '系统维护时间',
`comment` tinyint(1) UNSIGNED NULL DEFAULT 1 COMMENT '是否开启评论',
`qiniu_base_path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '七牛路径',
`qiniu_access_key` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '七牛ACCESS_KEY',
`qiniu_secret_key` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '七牛SECRET_KEY',
`qiniu_bucket_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '七牛BUCKET_NAME',
`baidu_push_token` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '百度推送的token',
`wx_praise_code` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '微信赞赏码',
`zfb_praise_code` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '支付宝赞赏码',
`baidu_api_ak` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '百度api授权AK(获取地址:http://lbsyun.baidu.com/apiconsole/key)',
`create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间', `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
`update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间', `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
......
...@@ -36,7 +36,32 @@ INSERT INTO `dblog`.`biz_type` VALUES ('3', null, '其他文章', '记录网站 ...@@ -36,7 +36,32 @@ INSERT INTO `dblog`.`biz_type` VALUES ('3', null, '其他文章', '记录网站
# 清空系统配置表 # 清空系统配置表
TRUNCATE TABLE `dblog`.`sys_config`; TRUNCATE TABLE `dblog`.`sys_config`;
# 初始化系统配置 # 初始化系统配置
INSERT INTO `dblog`.`sys_config` VALUES ('1', 'OneBlog是一款简洁美观、自适应的Java博客系统。使用springboot开发,前端使用Bootstrap。支持移动端自适应,配有完备的前台和后台管理功能。', 'OneBlog,开源博客', 'zhyd.me', 'http://localhost:8085', 'http://localhost:8443', 'OneBlog开源博客', 'OneBlog是一款简洁美观、自适应的Java博客系统', 'http://localhost:8443/img/favicon.ico', 'http://localhost:8443', '张亚东', 'yadong.zhang0415#gmail.com', 'https://static.zhyd.me/static/img/wechat_account.jpg', '843977358', 'http://weibo.com/211230415', 'https://github.com/zhangyd-c', 0, now(), 1, 'http://pe6duqm84.bkt.clouddn.com/', NULL, NULL, NULL, NULL, 'qrcode/wx_code.png', 'qrcode/zfb_code.png', 'NwHaYlGalDEpgxm46xBaC3T9', now(), now()); INSERT INTO `dblog`.`sys_config` VALUES (1, 'homeDesc', 'OneBlog是一款简洁美观、自适应的Java博客系统。使用springboot开发,前端使用Bootstrap。支持移动端自适应,配有完备的前台和后台管理功能。', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (2, 'homeKeywords', 'OneBlog,开源博客', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (3, 'domain', 'zhyd.me', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (4, 'cmsUrl', 'http://localhost:8086', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (5, 'siteUrl', 'http://localhost:8443', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (6, 'siteName', 'OneBlog开源博客', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (7, 'siteDesc', 'OneBlog是一款简洁美观、自适应的Java博客系统', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (8, 'siteFavicon', 'http://localhost:8443/img/favicon.ico', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (9, 'staticWebSite', 'http://localhost:8443', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (10, 'authorName', '张亚东', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (11, 'authorEmail', 'yadong.zhang0415#gmail.com', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (12, 'wxCode', 'https://static.zhyd.me/static/img/wechat_account.jpg', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (13, 'qq', '843977358', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (14, 'weibo', 'http://weibo.com/211230415', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (15, 'github', 'https://github.com/zhangyd-c', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (16, 'maintenance', '0', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (17, 'maintenanceDate', now(), now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (18, 'comment', '1', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (19, 'qiniuBasePath', 'http://pe6duqm84.bkt.clouddn.com/', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (20, 'qiniuAccessKey', NULL, now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (21, 'qiniuSecretKey', NULL, now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (22, 'qiniuBucketName', NULL, now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (23, 'baiduPushToken', NULL, now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (24, 'wxPraiseCode', 'qrcode/wx_code.png', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (25, 'zfbPraiseCode', 'qrcode/zfb_code.png', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (26, 'baiduApiAk', 'NwHaYlGalDEpgxm46xBaC3T9', now(), now());
# 清空友情链接表 # 清空友情链接表
TRUNCATE TABLE `dblog`.`sys_link`; TRUNCATE TABLE `dblog`.`sys_link`;
...@@ -247,4 +272,9 @@ TRUNCATE TABLE `dblog`.`sys_user_role`; ...@@ -247,4 +272,9 @@ TRUNCATE TABLE `dblog`.`sys_user_role`;
# 初始化用户角色关联数据 # 初始化用户角色关联数据
INSERT INTO `dblog`.`sys_user_role` VALUES ('1', '1', '1', now(), now()); INSERT INTO `dblog`.`sys_user_role` VALUES ('1', '1', '1', now(), now());
INSERT INTO `dblog`.`sys_user_role` VALUES ('2', '2', '2', now(), now()); INSERT INTO `dblog`.`sys_user_role` VALUES ('2', '2', '2', now(), now());
INSERT INTO `dblog`.`sys_user_role` VALUES ('3', '3', '3', now(), now()); INSERT INTO `dblog`.`sys_user_role` VALUES ('3', '3', '3', now(), now());
\ No newline at end of file
# 清空评论数据
TRUNCATE TABLE `dblog`.`biz_comment`;
# 初始化评论数据
INSERT INTO `dblog`.`biz_comment` VALUES (0, '1', null, '0', '843977358', '七彩狼', 'https://q1.qlogo.cn/g?b=qq&nk=843977358&s=40', '843977358@qq.com', 'https://www.zhyd.me', 'VERIFYING', '0:0:0:0:0:0:0:1', null, null, '未知', 'Windows 7', null, 'Chrome 65.0.3325.146', null, '<p>测试评论</p>', null, '0', '0', now(), now());
...@@ -150,3 +150,44 @@ ALTER TABLE `biz_comment` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unico ...@@ -150,3 +150,44 @@ ALTER TABLE `biz_comment` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unico
ALTER TABLE `dblog`.`sys_config` ALTER TABLE `dblog`.`sys_config`
CHANGE COLUMN `maintenance_data` `maintenance_date` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '系统维护时间' AFTER `maintenance`, CHANGE COLUMN `maintenance_data` `maintenance_date` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '系统维护时间' AFTER `maintenance`,
CHANGE COLUMN `qiuniu_base_path` `qiniu_base_path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '七牛路径' AFTER `comment`; CHANGE COLUMN `qiuniu_base_path` `qiniu_base_path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '七牛路径' AFTER `comment`;
# 2019-01-21 修改config表结构,建议升级之前先备份本地的config表数据
DROP TABLE IF EXISTS `sys_config`;
CREATE TABLE `sys_config` (
`id` int(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`config_key` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '首页描述',
`config_value` varchar(300) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '首页关键字',
`create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
`update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
# 清空系统配置表
TRUNCATE TABLE `dblog`.`sys_config`;
# 初始化系统配置
INSERT INTO `dblog`.`sys_config` VALUES (1, 'homeDesc', 'OneBlog是一款简洁美观、自适应的Java博客系统。使用springboot开发,前端使用Bootstrap。支持移动端自适应,配有完备的前台和后台管理功能。', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (2, 'homeKeywords', 'OneBlog,开源博客', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (3, 'domain', 'zhyd.me', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (4, 'cmsUrl', 'http://localhost:8086', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (5, 'siteUrl', 'http://localhost:8443', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (6, 'siteName', 'OneBlog开源博客', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (7, 'siteDesc', 'OneBlog是一款简洁美观、自适应的Java博客系统', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (8, 'siteFavicon', 'http://localhost:8443/img/favicon.ico', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (9, 'staticWebSite', 'http://localhost:8443', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (10, 'authorName', '张亚东', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (11, 'authorEmail', 'yadong.zhang0415#gmail.com', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (12, 'wxCode', 'https://static.zhyd.me/static/img/wechat_account.jpg', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (13, 'qq', '843977358', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (14, 'weibo', 'http://weibo.com/211230415', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (15, 'github', 'https://github.com/zhangyd-c', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (16, 'maintenance', '0', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (17, 'maintenanceDate', now(), now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (18, 'comment', '1', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (19, 'qiniuBasePath', 'http://pe6duqm84.bkt.clouddn.com/', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (20, 'qiniuAccessKey', NULL, now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (21, 'qiniuSecretKey', NULL, now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (22, 'qiniuBucketName', NULL, now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (23, 'baiduPushToken', NULL, now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (24, 'wxPraiseCode', 'qrcode/wx_code.png', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (25, 'zfbPraiseCode', 'qrcode/zfb_code.png', now(), now());
INSERT INTO `dblog`.`sys_config` VALUES (26, 'baiduApiAk', 'NwHaYlGalDEpgxm46xBaC3T9', now(), now());
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册