mirror of
https://github.com/Hello-hao/Tbed.git
synced 2024-04-21 12:32:10 +00:00
:art:修改系统配置表数据结构,添加数据库连接检测
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
FROM openjdk:8
|
||||
|
||||
# Add the service itself
|
||||
ARG JAR_FILE
|
||||
#ADD target/${JAR_FILE} /usr/share/docker-springboot-demo.jar
|
||||
ADD web.tar /web.tar
|
||||
|
||||
#COPY web/webapps/hellohao/config.json /HellohaoData/web/config/config.json
|
||||
COPY application.properties /application.properties
|
||||
#COPY hellohao /hellohao
|
||||
COPY Tbed.jar /Tbed.jar
|
||||
#CMD ["/bin/bash","/web/start.sh"]
|
||||
EXPOSE 10088
|
||||
EXPOSE 10089
|
||||
ENTRYPOINT["/start.sh"]
|
||||
#ENTRYPOINT ["java","-jar", "./Tbed.jar"]
|
||||
@@ -0,0 +1,4 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM mysql:8.0.31
|
||||
#把sql文件复制到工作目录下
|
||||
COPY ./tbed_core.sql /docker-entrypoint-initdb.d
|
||||
@@ -0,0 +1,39 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
hellohao-tbed:
|
||||
build:
|
||||
# dockerfile存放路径
|
||||
context: .
|
||||
# 配置启动参数
|
||||
args:
|
||||
JAR_FILE: tbed.jar
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "10088:10088"
|
||||
- "10089:10089"
|
||||
volumes:
|
||||
- /HellohaoData/:/HellohaoData/
|
||||
environment:
|
||||
# 环境变量, 在application.yml中读取
|
||||
MYSQL_URL: jdbc:mysql://hellohaodb/tbed?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
|
||||
MYSQL_PASS: 923453645
|
||||
HELLOHAO_SERVER_HOST: http://152.32.134.33:10088
|
||||
HELLOHAO_WEB_HOST: http://152.32.134.33:10089
|
||||
hellohaodb:
|
||||
image: mysql:8.0.31
|
||||
# container_name: tbed
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile-mysql
|
||||
ports:
|
||||
- "3306:3306"
|
||||
volumes:
|
||||
- /HellohaoData/mysql:/var/lib/mysql
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: 923453645
|
||||
|
||||
# docker-compose中需要声明named volumes
|
||||
volumes:
|
||||
sb-10-docker-mysql-data:
|
||||
|
||||
@@ -1,24 +1,23 @@
|
||||
package cn.hellohao;
|
||||
|
||||
import javax.servlet.MultipartConfigElement;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import cn.hellohao.utils.Print;
|
||||
import cn.hellohao.dao.KeysMapper;
|
||||
import cn.hellohao.utils.FirstRun;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.jdbc.DatabaseDriver;
|
||||
import org.springframework.boot.web.servlet.MultipartConfigFactory;
|
||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.jdbc.support.DatabaseStartupValidator;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import org.springframework.util.unit.DataSize;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.Scanner;
|
||||
import javax.servlet.MultipartConfigElement;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@SpringBootApplication
|
||||
@Configuration
|
||||
@@ -30,6 +29,31 @@ public class TbedApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(TbedApplication.class, args);
|
||||
}
|
||||
|
||||
//延缓Spring Boot启动时间直到数据库启动的方法
|
||||
@Bean
|
||||
public DatabaseStartupValidator databaseStartupValidator(DataSource dataSource) {
|
||||
DatabaseStartupValidator databaseStartupValidator = new DatabaseStartupValidator();
|
||||
databaseStartupValidator.setDataSource(dataSource);
|
||||
databaseStartupValidator.setValidationQuery(DatabaseDriver.POSTGRESQL.getValidationQuery());
|
||||
return databaseStartupValidator;
|
||||
}
|
||||
@Bean
|
||||
public static BeanFactoryPostProcessor dependsOnPostProcessor() {
|
||||
return bf -> {
|
||||
// Let beans that need the database depend on the DatabaseStartupValidator
|
||||
// like the JPA EntityManagerFactory or Flyway
|
||||
String[] flyway = bf.getBeanNamesForType(FirstRun.class);
|
||||
Stream.of(flyway)
|
||||
.map(bf::getBeanDefinition)
|
||||
.forEach(it -> it.setDependsOn("databaseStartupValidator"));
|
||||
|
||||
String[] jpa = bf.getBeanNamesForType(KeysMapper.class);
|
||||
Stream.of(jpa)
|
||||
.map(bf::getBeanDefinition)
|
||||
.forEach(it -> it.setDependsOn("databaseStartupValidator"));
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 文件上传配置
|
||||
* @return
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.List;
|
||||
@RequestMapping("/admin/root")
|
||||
public class AdminRootController {
|
||||
@Autowired
|
||||
private ConfigService configService;
|
||||
private ConfdataService confdataService;
|
||||
@Autowired
|
||||
private KeysService keysService;
|
||||
@Autowired
|
||||
@@ -260,7 +260,7 @@ public class AdminRootController {
|
||||
User u = (User) subject.getPrincipal();
|
||||
try {
|
||||
UploadConfig uploadConfig = uploadConfigService.getUpdateConfig();
|
||||
Config config = configService.getSourceype();
|
||||
final Confdata confdata = confdataService.selectConfdata("config");
|
||||
SysConfig sysConfig = sysConfigService.getstate();
|
||||
AppClient appClientData = appClientService.getAppClientData("app");
|
||||
uploadConfig.setUsermemory(Long.toString(Long.valueOf(uploadConfig.getUsermemory()) / 1024 / 1024));
|
||||
@@ -268,7 +268,7 @@ public class AdminRootController {
|
||||
uploadConfig.setFilesizetourists(Long.toString(Long.valueOf(uploadConfig.getFilesizetourists()) / 1024 / 1024));
|
||||
uploadConfig.setFilesizeuser(Long.toString(Long.valueOf(uploadConfig.getFilesizeuser()) / 1024 / 1024));
|
||||
jsonObject.put("uploadConfig", uploadConfig);
|
||||
jsonObject.put("config", config);
|
||||
jsonObject.put("config", JSONObject.parseObject(confdata.getJsondata()));
|
||||
jsonObject.put("sysConfig", sysConfig);
|
||||
jsonObject.put("appClient", appClientData);
|
||||
msg.setData(jsonObject);
|
||||
@@ -296,7 +296,7 @@ public class AdminRootController {
|
||||
msg.setCode("500");
|
||||
return msg;
|
||||
}
|
||||
Config config = JSON.toJavaObject((JSON) jsonObject.get("config"), Config.class);
|
||||
// Config config = JSON.toJavaObject((JSON) jsonObject.get("config"), Config.class);
|
||||
SysConfig sysConfig = JSON.toJavaObject((JSON) jsonObject.get("sysConfig"), SysConfig.class);
|
||||
AppClient appClient = JSON.toJavaObject((JSON) jsonObject.get("appClient"), AppClient.class);
|
||||
if (Integer.valueOf(vm) == -1) {
|
||||
@@ -308,7 +308,10 @@ public class AdminRootController {
|
||||
uploadConfig.setUsermemory(Long.toString(Long.valueOf(uploadConfig.getUsermemory()) * 1024 * 1024));
|
||||
uploadConfig.setFilesizeuser(Long.toString(Long.valueOf(uploadConfig.getFilesizeuser()) * 1024 * 1024));
|
||||
uploadConfigService.setUpdateConfig(uploadConfig);
|
||||
configService.setSourceype(config);
|
||||
Confdata confdata = new Confdata();
|
||||
confdata.setKey("config");
|
||||
confdata.setJsondata(jsonObject.getJSONObject("config").toJSONString());
|
||||
confdataService.updateConfdata(confdata);
|
||||
sysConfigService.setstate(sysConfig);
|
||||
if (!appClient.getIsuse().equals("on")) {
|
||||
appClient.setIsuse("off");
|
||||
|
||||
@@ -3,7 +3,6 @@ package cn.hellohao.controller;
|
||||
import cn.hellohao.auth.token.JWTUtil;
|
||||
import cn.hellohao.pojo.*;
|
||||
import cn.hellohao.service.*;
|
||||
import cn.hellohao.service.impl.AlbumServiceImpl;
|
||||
import cn.hellohao.service.impl.UploadServicel;
|
||||
import cn.hellohao.service.impl.deleImages;
|
||||
import cn.hellohao.utils.GetIPS;
|
||||
@@ -34,7 +33,7 @@ import java.util.UUID;
|
||||
public class IndexController {
|
||||
@Autowired private ImgService imgService;
|
||||
@Autowired private SysConfigService sysConfigService;
|
||||
@Autowired private ConfigService configService;
|
||||
@Autowired private ConfdataService confdataService;
|
||||
@Autowired private UploadConfigService uploadConfigService;
|
||||
@Autowired private UploadServicel uploadServicel;
|
||||
@Autowired private deleImages deleimages;
|
||||
@@ -54,21 +53,21 @@ public class IndexController {
|
||||
@ResponseBody
|
||||
public Msg webInfo() {
|
||||
Msg msg = new Msg();
|
||||
Config config = configService.getSourceype();
|
||||
final Confdata confdata = confdataService.selectConfdata("config");
|
||||
JSONObject cd = JSONObject.parseObject(confdata.getJsondata());
|
||||
UploadConfig updateConfig = uploadConfigService.getUpdateConfig();
|
||||
SysConfig sysConfig = sysConfigService.getstate();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
AppClient appClient = appClientService.getAppClientData("app");
|
||||
jsonObject.put("webname", config.getWebname());
|
||||
jsonObject.put("websubtitle", config.getWebsubtitle());
|
||||
jsonObject.put("keywords", config.getWebkeywords());
|
||||
jsonObject.put("description", config.getWebms());
|
||||
jsonObject.put("explain", config.getExplain());
|
||||
jsonObject.put("favicon", config.getWebfavicons());
|
||||
jsonObject.put("baidu", config.getBaidu());
|
||||
jsonObject.put("links", config.getLinks());
|
||||
jsonObject.put("aboutinfo", config.getAboutinfo());
|
||||
jsonObject.put("logo", config.getLogo());
|
||||
jsonObject.put("webname", cd.getString("webname"));
|
||||
jsonObject.put("websubtitle", cd.getString("websubtitle"));
|
||||
jsonObject.put("keywords", cd.getString("keywords"));
|
||||
jsonObject.put("description", cd.getString("description"));
|
||||
jsonObject.put("explain", cd.getString("explain"));
|
||||
jsonObject.put("baidu", cd.getString("baidu"));
|
||||
jsonObject.put("links", cd.getString("links"));
|
||||
jsonObject.put("aboutinfo", cd.getString("aboutinfo"));
|
||||
jsonObject.put("logo", cd.getString("logo"));
|
||||
jsonObject.put("api", updateConfig.getApi());
|
||||
jsonObject.put("register", sysConfig.getRegister());
|
||||
jsonObject.put("isuse", appClient.getIsuse());
|
||||
|
||||
@@ -5,8 +5,10 @@ import cn.hellohao.auth.token.JWTUtil;
|
||||
import cn.hellohao.config.SysName;
|
||||
import cn.hellohao.pojo.*;
|
||||
import cn.hellohao.service.*;
|
||||
import cn.hellohao.utils.*;
|
||||
import cn.hutool.captcha.ShearCaptcha;
|
||||
import cn.hellohao.utils.Base64Encryption;
|
||||
import cn.hellohao.utils.NewSendEmail;
|
||||
import cn.hellohao.utils.Print;
|
||||
import cn.hellohao.utils.SetText;
|
||||
import cn.hutool.core.util.HexUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
@@ -35,7 +37,7 @@ public class UserController {
|
||||
@Autowired
|
||||
private EmailConfigService emailConfigService;
|
||||
@Autowired
|
||||
private ConfigService configService;
|
||||
private ConfdataService confdataService;
|
||||
@Autowired
|
||||
private UploadConfigService uploadConfigService;
|
||||
@Autowired
|
||||
@@ -109,14 +111,15 @@ public class UserController {
|
||||
user.setUsername(username);
|
||||
user.setPassword(password);
|
||||
user.setToken(UUID.randomUUID().toString().replace("-", ""));
|
||||
Config config = configService.getSourceype();
|
||||
final Confdata confdata = confdataService.selectConfdata("config");
|
||||
JSONObject jsonObject = JSONObject.parseObject(confdata.getJsondata());
|
||||
Integer type = 0;
|
||||
if(emailConfig.getUsing()==1){
|
||||
user.setIsok(0);
|
||||
//注册完发激活链接
|
||||
Thread thread = new Thread() {
|
||||
public void run() {
|
||||
Integer a = NewSendEmail.sendEmail(emailConfig,user.getUsername(), uid, user.getEmail(),config);
|
||||
Integer a = NewSendEmail.sendEmail(emailConfig,user.getUsername(), uid, user.getEmail(),jsonObject);
|
||||
}
|
||||
};
|
||||
thread.start();
|
||||
@@ -222,7 +225,6 @@ public class UserController {
|
||||
|
||||
@RequestMapping(value = "/activation", method = RequestMethod.GET)
|
||||
public String activation(Model model, HttpServletRequest request, HttpSession session, String activation, String username) {
|
||||
Config config = configService.getSourceype();
|
||||
Integer ret = 0;
|
||||
User u2 = new User();
|
||||
u2.setUid(activation);
|
||||
@@ -288,10 +290,11 @@ public class UserController {
|
||||
msg.setInfo("当前用户已被冻结,禁止操作");
|
||||
return msg;
|
||||
}
|
||||
Config config = configService.getSourceype();
|
||||
final Confdata confdata = confdataService.selectConfdata("config");
|
||||
JSONObject jsonObject = JSONObject.parseObject(confdata.getJsondata());
|
||||
Thread thread = new Thread() {
|
||||
public void run() {
|
||||
Integer a = NewSendEmail.sendEmailFindPass(emailConfig,user.getUsername(), user.getUid(), user.getEmail(),config);
|
||||
Integer a = NewSendEmail.sendEmailFindPass(emailConfig,user.getUsername(), user.getUid(), user.getEmail(),jsonObject);
|
||||
}
|
||||
};
|
||||
thread.start();
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.hellohao.dao;
|
||||
|
||||
import cn.hellohao.pojo.Confdata;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface ConfdataMapper {
|
||||
Confdata selectConfdata(@Param("key") String key);
|
||||
Integer updateConfdata(Confdata confdata);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package cn.hellohao.dao;
|
||||
|
||||
import cn.hellohao.pojo.Config;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Mapper
|
||||
public interface ConfigMapper {
|
||||
Config getSourceype();
|
||||
Integer setSourceype(Config config);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.hellohao.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Hellohao
|
||||
* @version 1.0
|
||||
* @date 2023/3/2 10:21
|
||||
*/
|
||||
@Data
|
||||
public class Confdata {
|
||||
|
||||
private String key;
|
||||
private String jsondata;
|
||||
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package cn.hellohao.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Config {
|
||||
private Integer id;
|
||||
private Integer sourcekey;
|
||||
@@ -23,201 +26,5 @@ public class Config {
|
||||
private String logo;
|
||||
private String aboutinfo;
|
||||
|
||||
public Config() {
|
||||
}
|
||||
|
||||
public Config(Integer id, Integer sourcekey, Integer emails, String webname, String explain, String video, Integer backtype,
|
||||
String links, String notice, String baidu, String domain, String background1, String background2, String sett,
|
||||
String webms, String webkeywords, String webfavicons, Integer theme,String websubtitle,String logo,String aboutinfo) {
|
||||
this.id = id;
|
||||
this.sourcekey = sourcekey;
|
||||
this.emails = emails;
|
||||
this.webname = webname;
|
||||
this.explain = explain;
|
||||
this.video = video;
|
||||
this.backtype = backtype;
|
||||
this.links = links;
|
||||
this.notice = notice;
|
||||
this.baidu = baidu;
|
||||
this.domain = domain;
|
||||
this.background1 = background1;
|
||||
this.background2 = background2;
|
||||
this.sett = sett;
|
||||
this.webms = webms;
|
||||
this.webkeywords = webkeywords;
|
||||
this.webfavicons = webfavicons;
|
||||
this.theme = theme;
|
||||
this.websubtitle = websubtitle;
|
||||
this.logo = logo;
|
||||
this.aboutinfo = aboutinfo;
|
||||
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getSourcekey() {
|
||||
return sourcekey;
|
||||
}
|
||||
|
||||
public void setSourcekey(Integer sourcekey) {
|
||||
this.sourcekey = sourcekey;
|
||||
}
|
||||
|
||||
public Integer getEmails() {
|
||||
return emails;
|
||||
}
|
||||
|
||||
public void setEmails(Integer emails) {
|
||||
this.emails = emails;
|
||||
}
|
||||
|
||||
public String getWebname() {
|
||||
return webname;
|
||||
}
|
||||
|
||||
public void setWebname(String webname) {
|
||||
this.webname = webname;
|
||||
}
|
||||
|
||||
public String getExplain() {
|
||||
return explain;
|
||||
}
|
||||
|
||||
public void setExplain(String explain) {
|
||||
this.explain = explain;
|
||||
}
|
||||
|
||||
public String getVideo() {
|
||||
return video;
|
||||
}
|
||||
|
||||
public void setVideo(String video) {
|
||||
this.video = video;
|
||||
}
|
||||
|
||||
public Integer getBacktype() {
|
||||
return backtype;
|
||||
}
|
||||
|
||||
public void setBacktype(Integer backtype) {
|
||||
this.backtype = backtype;
|
||||
}
|
||||
|
||||
public String getLinks() {
|
||||
return links;
|
||||
}
|
||||
|
||||
public void setLinks(String links) {
|
||||
this.links = links;
|
||||
}
|
||||
|
||||
public String getNotice() {
|
||||
return notice;
|
||||
}
|
||||
|
||||
public void setNotice(String notice) {
|
||||
this.notice = notice;
|
||||
}
|
||||
|
||||
public String getBaidu() {
|
||||
return baidu;
|
||||
}
|
||||
|
||||
public void setBaidu(String baidu) {
|
||||
this.baidu = baidu;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
public void setDomain(String domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
public String getBackground1() {
|
||||
return background1;
|
||||
}
|
||||
|
||||
public void setBackground1(String background1) {
|
||||
this.background1 = background1;
|
||||
}
|
||||
|
||||
public String getBackground2() {
|
||||
return background2;
|
||||
}
|
||||
|
||||
public void setBackground2(String background2) {
|
||||
this.background2 = background2;
|
||||
}
|
||||
|
||||
public String getSett() {
|
||||
return sett;
|
||||
}
|
||||
|
||||
public void setSett(String sett) {
|
||||
this.sett = sett;
|
||||
}
|
||||
|
||||
public String getWebms() {
|
||||
return webms;
|
||||
}
|
||||
|
||||
public void setWebms(String webms) {
|
||||
this.webms = webms;
|
||||
}
|
||||
|
||||
public String getWebkeywords() {
|
||||
return webkeywords;
|
||||
}
|
||||
|
||||
public void setWebkeywords(String webkeywords) {
|
||||
this.webkeywords = webkeywords;
|
||||
}
|
||||
|
||||
public String getWebfavicons() {
|
||||
return webfavicons;
|
||||
}
|
||||
|
||||
public void setWebfavicons(String webfavicons) {
|
||||
this.webfavicons = webfavicons;
|
||||
}
|
||||
|
||||
public Integer getTheme() {
|
||||
return theme;
|
||||
}
|
||||
|
||||
public void setTheme(Integer theme) {
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public String getWebsubtitle() {
|
||||
return websubtitle;
|
||||
}
|
||||
|
||||
public void setWebsubtitle(String websubtitle) {
|
||||
this.websubtitle = websubtitle;
|
||||
}
|
||||
|
||||
public String getLogo() {
|
||||
return logo;
|
||||
}
|
||||
|
||||
public void setLogo(String logo) {
|
||||
this.logo = logo;
|
||||
}
|
||||
|
||||
public String getAboutinfo() {
|
||||
return aboutinfo;
|
||||
}
|
||||
|
||||
public void setAboutinfo(String aboutinfo) {
|
||||
this.aboutinfo = aboutinfo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.hellohao.service;
|
||||
|
||||
import cn.hellohao.pojo.Confdata;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public interface ConfdataService {
|
||||
Confdata selectConfdata(String key);
|
||||
Integer updateConfdata(Confdata confdata);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package cn.hellohao.service;
|
||||
|
||||
import cn.hellohao.pojo.Config;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public interface ConfigService {
|
||||
Config getSourceype();
|
||||
Integer setSourceype(Config config);
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package cn.hellohao.service.impl;
|
||||
|
||||
import cn.hellohao.dao.AlbumMapper;
|
||||
import cn.hellohao.dao.ConfigMapper;
|
||||
import cn.hellohao.dao.ImgAndAlbumMapper;
|
||||
import cn.hellohao.dao.ImgMapper;
|
||||
import cn.hellohao.exception.CodeException;
|
||||
@@ -25,7 +24,6 @@ import java.util.List;
|
||||
public class AlbumServiceImpl implements AlbumService {
|
||||
@Autowired AlbumMapper albumMapper;
|
||||
@Autowired ImgAndAlbumMapper andAlbumMapper;
|
||||
@Autowired ConfigMapper configMapper;
|
||||
@Autowired ImgMapper imgMapper;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.hellohao.service.impl;
|
||||
|
||||
import cn.hellohao.dao.ConfdataMapper;
|
||||
import cn.hellohao.pojo.Confdata;
|
||||
import cn.hellohao.service.ConfdataService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ConfdataServiceImpl implements ConfdataService {
|
||||
@Autowired
|
||||
private ConfdataMapper confdataMapper;
|
||||
|
||||
@Override
|
||||
public Confdata selectConfdata(String key) {
|
||||
return confdataMapper.selectConfdata(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer updateConfdata(Confdata confdata) {
|
||||
return confdataMapper.updateConfdata(confdata);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package cn.hellohao.service.impl;
|
||||
|
||||
import cn.hellohao.dao.ConfigMapper;
|
||||
import cn.hellohao.pojo.Config;
|
||||
import cn.hellohao.pojo.Images;
|
||||
import cn.hellohao.service.ConfigService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ConfigServiceImpl implements ConfigService {
|
||||
@Autowired
|
||||
private ConfigMapper configMapper;
|
||||
|
||||
@Override
|
||||
public Config getSourceype() {
|
||||
return configMapper.getSourceype();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer setSourceype(Config config) {
|
||||
return configMapper.setSourceype(config);
|
||||
}
|
||||
}
|
||||
@@ -91,6 +91,12 @@ public class FirstRun implements InitializingBean {
|
||||
RunSqlScript.RunInsert(instartAppclient);
|
||||
Print.Normal("Add table.appclient");
|
||||
}
|
||||
Integer isconfdata = RunSqlScript.RunSelectCount(isTableName+"'confdata'");
|
||||
if(isconfdata==0){
|
||||
Integer integer = RunSqlScript.RunInsert(createConfdata);
|
||||
RunSqlScript.RunInsert(instartConfdata);
|
||||
Print.Normal("Add table.confdata");
|
||||
}
|
||||
// Integer ret6 = RunSqlScript.RunSelectCount(judgeTable+" 'imgdata' and column_name = 'idname'");
|
||||
// if(ret6==0){
|
||||
// RunSqlScript.RunInsert(sql11);
|
||||
@@ -127,6 +133,26 @@ public class FirstRun implements InitializingBean {
|
||||
//创建客户端程序相关表
|
||||
private String createAppclient = "CREATE TABLE `appclient` (`id` varchar(10) NOT NULL,`isuse` varchar(10) NOT NULL,`winpackurl` varchar(255) NULL DEFAULT NULL,`macpackurl` varchar(255) NULL DEFAULT NULL,`appname` varchar(20) NULL,`applogo` varchar(255) NULL,`appupdate` varchar(10) NOT NULL) ";
|
||||
private String instartAppclient = "INSERT INTO `appclient` VALUES ('app', 'on', NULL, NULL, 'Hellohao图像托管', 'https://hellohao.nos-eastchina1.126.net/TbedClient/app.png', '1.0.1');";
|
||||
//创建confdata表
|
||||
private String createConfdata = "CREATE TABLE tbed.confdata ( `key` varchar(100) NULL, jsondata LONGTEXT NULL )";
|
||||
private String instartConfdata = "INSERT INTO `confdata` VALUES ('config', '{" +
|
||||
" \"sourcekey\":7," +
|
||||
" \"emails\":1," +
|
||||
" \"webname\":\"Hellohao图床\"," +
|
||||
" \"explain\":\"Hellohao图像托管,是一家免费开源的图像托管,即时分享你的美好瞬间。\"," +
|
||||
" \"links\":\"<p style=\\\"color:#7c7c88;\\\">© 2019 <a href=\\\"http://www.Hellohao.cn/\\\" target=\\\"_blank\\\" title=\\\"Hellohao\\\">Hellohao</a><span> - All Rights Reserved</span> </p>\",\n" +
|
||||
" \"notice\":\"也许...|这将是最好用的图床|为了更好的用户体验,建议您注册本站继续免费使用Hellohao图床。本站不得上传任何形式的非法图片,一旦发现,永久删除并禁封账户。情节严重者将相关资料交于相关部门处理。\",\n" +
|
||||
" \"domain\":\"http://127.0.0.1:10088\"," +
|
||||
" \"background1\":\"\"," +
|
||||
" \"sett\":\"1\"," +
|
||||
" \"webms\":\"Hellohao图像托管,是一家免费开源的图像托管,即时分享你的美好瞬间。\"," +
|
||||
" \"webkeywords\":\"hellohao图床,图床,图片上传,开源图床,hellohao,图像托管,图片分享\"," +
|
||||
" \"theme\":2," +
|
||||
" \"websubtitle\":\"这将是你用过最优秀的图像托管程序\"," +
|
||||
" \"logo\":null," +
|
||||
" \"aboutinfo\":\"<img width=\\\"300px\\\" src=\\\"http://img.wwery.com/hellohao/rPscRYwz.png\\\">\\n <br />\\n <br />\\n <p>也许,这将是你用到最优秀的图像托管程序</p>\\n <p>本程序为Hellohao图象托管程序</p>\\n <br/>\\n <p style=\\\"color: #656565;\\\">作者:hellohao独立开发</p>\\n <p style=\\\"color: #656565;\\\">www.hellohao.cn</p>\"" +
|
||||
"}');";
|
||||
|
||||
|
||||
|
||||
private String inddx_md5key = "ALTER TABLE imgdata ADD INDEX index_md5key_url ( md5key,imgurl)";
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package cn.hellohao.utils;
|
||||
|
||||
import cn.hellohao.pojo.Config;
|
||||
import cn.hellohao.pojo.EmailConfig;
|
||||
import cn.hellohao.pojo.Msg;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.HexUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.mitchellbosecke.pebble.PebbleEngine;
|
||||
import com.mitchellbosecke.pebble.template.PebbleTemplate;
|
||||
import io.github.biezhi.ome.OhMyEmail;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.HashMap;
|
||||
@@ -18,7 +19,7 @@ import java.util.UUID;
|
||||
|
||||
public class NewSendEmail {
|
||||
|
||||
public static Integer sendEmail(EmailConfig emailConfig, String username, String uid, String toEmail, Config config) {
|
||||
public static Integer sendEmail(EmailConfig emailConfig, String username, String uid, String toEmail, JSONObject jsonObject) {
|
||||
|
||||
Properties props = new Properties();
|
||||
props.put("mail.smtp.auth", "true");
|
||||
@@ -33,8 +34,8 @@ public class NewSendEmail {
|
||||
// OhMyEmail.config(OhMyEmail.SMTP_QQ(false), "xxxx@qq.com", "your@password");
|
||||
OhMyEmail.config(props, emailConfig.getEmails(), emailConfig.getEmailkey());
|
||||
|
||||
String webname=config.getWebname();
|
||||
String domain = config.getDomain();
|
||||
String webname=jsonObject.getString("webname");
|
||||
String domain = jsonObject.getString("domain");
|
||||
try {
|
||||
//生成模板
|
||||
PebbleEngine engine = new PebbleEngine.Builder().build();
|
||||
@@ -90,7 +91,7 @@ public class NewSendEmail {
|
||||
}
|
||||
|
||||
|
||||
public static Integer sendEmailFindPass(EmailConfig emailConfig,String username, String uid, String toEmail, Config config) {
|
||||
public static Integer sendEmailFindPass(EmailConfig emailConfig,String username, String uid, String toEmail, JSONObject jsonObject) {
|
||||
Properties props = new Properties();
|
||||
props.put("mail.smtp.auth", "true");
|
||||
props.put("mail.smtp.ssl.enable", "true");
|
||||
@@ -103,8 +104,8 @@ public class NewSendEmail {
|
||||
// 配置一次即可,可以配置为静态方法
|
||||
// OhMyEmail.config(OhMyEmail.SMTP_QQ(false), "xxxx@qq.com", "your@password");
|
||||
OhMyEmail.config(props, emailConfig.getEmails(), emailConfig.getEmailkey());
|
||||
String webname=config.getWebname();
|
||||
String domain = config.getDomain();
|
||||
String webname=jsonObject.getString("webname");
|
||||
String domain = jsonObject.getString("domain");
|
||||
String new_pass = UUID.randomUUID().toString().replace("-", "").toLowerCase().substring(0,10);
|
||||
try {
|
||||
//生成模板
|
||||
|
||||
@@ -1,64 +1,6 @@
|
||||
package cn.hellohao.utils;
|
||||
|
||||
import cn.hellohao.pojo.Keys;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public class StringUtils {
|
||||
//此方法目前未使用2020-04-06
|
||||
public static Boolean doNull(Integer sourcekey,Keys k) {
|
||||
if(sourcekey==1){
|
||||
if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null
|
||||
&& k.getBucketname()!=null && k.getRequestAddress()!=null ){
|
||||
if(!k.getEndpoint().equals("") && !k.getAccessSecret().equals("") && !k.getEndpoint().equals("")
|
||||
&& !k.getBucketname().equals("") && !k.getRequestAddress().equals("") ){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}else if(sourcekey==2){
|
||||
if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null
|
||||
&& k.getBucketname()!=null && k.getRequestAddress()!=null ) {
|
||||
if(!k.getEndpoint().equals("") && !k.getAccessSecret().equals("") && !k.getEndpoint().equals("")
|
||||
&& !k.getBucketname().equals("") && !k.getRequestAddress().equals("") ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}else if(sourcekey==3){
|
||||
if(k.getEndpoint()!=null && k.getAccessSecret()!=null
|
||||
&& k.getBucketname()!=null && k.getRequestAddress()!=null ) {
|
||||
if(!k.getEndpoint().equals("") && !k.getAccessSecret().equals("")
|
||||
&& !k.getBucketname().equals("") && !k.getRequestAddress().equals("") ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}else if(sourcekey==4){
|
||||
if (k.getEndpoint() != null && k.getAccessSecret() != null && k.getEndpoint() != null
|
||||
&& k.getBucketname() != null && k.getRequestAddress() != null) {
|
||||
if (!k.getEndpoint().equals("") && !k.getAccessSecret() .equals("") && !k.getEndpoint() .equals("")
|
||||
&& !k.getBucketname() .equals("") && !k.getRequestAddress().equals("")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}else if(sourcekey==6){
|
||||
if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null
|
||||
&& k.getBucketname()!=null && k.getRequestAddress()!=null ) {
|
||||
if(!k.getEndpoint().equals("") && !k.getAccessSecret().equals("") && !k.getEndpoint().equals("")
|
||||
&& !k.getBucketname().equals("") && !k.getRequestAddress().equals("") ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}else if(sourcekey==7){
|
||||
if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null && k.getRequestAddress()!=null ) {
|
||||
if(!k.getEndpoint().equals("") && !k.getAccessSecret().equals("") && !k.getEndpoint().equals("") && !k.getRequestAddress().equals("") ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除 URL 中的第一个 '/'
|
||||
* @return 如 path = '/folder1/file1', 返回 'folder1/file1'
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
#端口
|
||||
server.port=10088
|
||||
#前端域名需要带协议头http(s)://
|
||||
CROS_ALLOWED_ORIGINS=${HELLOHAO_WEB_HOST:http://127.0.0.1:8080}
|
||||
#数据库账号
|
||||
spring.datasource.username=root
|
||||
#数据库密码test
|
||||
spring.datasource.password=root
|
||||
spring.datasource.password=${MYSQL_PASS:923453645}
|
||||
#数据库链接地址
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/tbed?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
|
||||
#端口
|
||||
server.port=8089
|
||||
#前端域名需要带协议头http(s)://
|
||||
CROS_ALLOWED_ORIGINS=http://127.0.0.1:8080
|
||||
|
||||
#spring.datasource.url=jdbc:mysql://file.tdo.ink:3306/tbed?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
|
||||
spring.datasource.url=${MYSQL_URL:jdbc:mysql://152.32.134.33:3306/tbed?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8}
|
||||
#MySQL Driver 无需修改
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
|
||||
#下边的配置项不需要修改。
|
||||
#logging.config=classpath:logback-spring.xml
|
||||
@@ -19,7 +21,6 @@ mybatis.mapper-locations=classpath:mapper/*.xml
|
||||
logging.level.cn.hellohao.dao=debug
|
||||
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
|
||||
spring.jackson.time-zone=GMT+8
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
||||
spring.thymeleaf.cache=false
|
||||
multipart.maxFileSize=10240KB
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.hellohao.dao.ConfdataMapper">
|
||||
|
||||
<select id="selectConfdata" resultType="cn.hellohao.pojo.Confdata">
|
||||
select * from confdata where `key`=#{key}
|
||||
</select>
|
||||
|
||||
<update id="updateConfdata" parameterType="cn.hellohao.pojo.Confdata">
|
||||
UPDATE confdata
|
||||
<set>
|
||||
<if test="jsondata != null">
|
||||
jsondata = #{jsondata},
|
||||
</if>
|
||||
</set>
|
||||
where `key`=#{key}
|
||||
</update>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -1,79 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.hellohao.dao.ConfigMapper">
|
||||
|
||||
<select id="getSourceype" resultType="cn.hellohao.pojo.Config">
|
||||
select * from config where id = 1
|
||||
</select>
|
||||
|
||||
<update id="setSourceype" parameterType="cn.hellohao.pojo.Config">
|
||||
UPDATE config
|
||||
<set>
|
||||
<if test="sourcekey != null">
|
||||
sourcekey = #{sourcekey},
|
||||
</if>
|
||||
<if test="emails != null">
|
||||
emails = #{emails},
|
||||
</if>
|
||||
<if test="webname != null">
|
||||
webname = #{webname},
|
||||
</if>
|
||||
<if test="explain != null">
|
||||
`explain` = #{explain},
|
||||
</if>
|
||||
<if test="video != null">
|
||||
`video` = #{video},
|
||||
</if>
|
||||
<if test="backtype != null">
|
||||
`backtype` = #{backtype},
|
||||
</if>
|
||||
<if test="links != null">
|
||||
`links` = #{links},
|
||||
</if>
|
||||
<if test="notice != null">
|
||||
`notice` = #{notice},
|
||||
</if>
|
||||
<if test="baidu != null">
|
||||
`baidu` = #{baidu},
|
||||
</if>
|
||||
<if test="domain != null">
|
||||
`domain` = #{domain},
|
||||
</if>
|
||||
<if test="background1 != null">
|
||||
`background1` = #{background1},
|
||||
</if>
|
||||
<if test="background2 != null">
|
||||
`background2` = #{background2},
|
||||
</if>
|
||||
<if test="sett != null">
|
||||
`sett` = #{sett},
|
||||
</if>
|
||||
<if test="webms != null">
|
||||
`webms` = #{webms},
|
||||
</if>
|
||||
<if test="webkeywords != null">
|
||||
`webkeywords` = #{webkeywords},
|
||||
</if>
|
||||
<if test="webfavicons != null">
|
||||
`webfavicons` = #{webfavicons},
|
||||
</if>
|
||||
<if test="theme != null">
|
||||
`theme` = #{theme},
|
||||
</if>
|
||||
<if test="websubtitle != null">
|
||||
websubtitle = #{websubtitle},
|
||||
</if>
|
||||
<if test="logo != null">
|
||||
logo = #{logo},
|
||||
</if>
|
||||
<if test="aboutinfo != null">
|
||||
aboutinfo = #{aboutinfo},
|
||||
</if>
|
||||
|
||||
|
||||
</set>
|
||||
where id=1
|
||||
</update>
|
||||
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user