This commit is contained in:
jinnrry committed 2023-08-06 09:33:51 +08:00
1 parent 8f7fbd4fee
commit c0f12558b5
54 files changed
+1273 -132

No files matched your search

+6 -3
View File
@@ -1,11 +1,14 @@
{
"domain": "jinnrry.com",
"domain": "",
"webDomain": "",
"dkimPrivateKeyPath": "config/dkim/dkim.priv",
"SSLPrivateKeyPath": "config/ssl/private.key",
"SSLPublicKeyPath": "config/ssl/public.crt",
"mysqlDSN": "",
"dbDSN": "",
"dbType": "",
"weChatPushAppId": "",
"weChatPushSecret": "",
"weChatPushTemplateId": "",
"weChatPushUserId": ""
"weChatPushUserId": "",
"isInit": false
}
+35 -17
View File
@@ -8,25 +8,35 @@ import (
"strings"
)
var IsInit bool
type Config struct {
Domain string `json:"domain"`
DkimPrivateKeyPath string `json:"dkimPrivateKeyPath"`
SSLPrivateKeyPath string `json:"SSLPrivateKeyPath"`
SSLPublicKeyPath string `json:"SSLPublicKeyPath"`
MysqlDSN string `json:"mysqlDSN"`
WeChatPushAppId string `json:"weChatPushAppId"`
WeChatPushSecret string `json:"weChatPushSecret"`
WeChatPushTemplateId string `json:"weChatPushTemplateId"`
WeChatPushUserId string `json:"weChatPushUserId"`
Tables map[string]string
TablesInitData map[string]string
Domain string `json:"domain"`
WebDomain string `json:"webDomain"`
DkimPrivateKeyPath string `json:"dkimPrivateKeyPath"`
SSLPrivateKeyPath string `json:"SSLPrivateKeyPath"`
SSLPublicKeyPath string `json:"SSLPublicKeyPath"`
DbDSN string `json:"dbDSN"`
DbType string `json:"dbType"`
WeChatPushAppId string `json:"weChatPushAppId"`
WeChatPushSecret string `json:"weChatPushSecret"`
WeChatPushTemplateId string `json:"weChatPushTemplateId"`
WeChatPushUserId string `json:"weChatPushUserId"`
IsInit bool `json:"isInit"`
Tables map[string]string `json:"-"`
TablesInitData map[string]string `json:"-"`
}
//go:embed tables/*
var tableConfig embed.FS
const Version = "1.1.0"
const DBTypeMySQL = "mysql"
const DBTypeSQLite = "sqlite"
var DBTypes []string = []string{DBTypeMySQL, DBTypeSQLite}
var Instance *Config
func Init() {
@@ -37,25 +47,29 @@ func Init() {
if len(args) >= 2 && args[len(args)-1] == "dev" {
cfgData, err = os.ReadFile("./config/config.dev.json")
if err != nil {
panic("dev环境配置文件加载失败" + err.Error())
return
}
} else {
cfgData, err = os.ReadFile("./config/config.json")
if err != nil {
panic("配置文件加载失败" + err.Error())
return
}
}
err = json.Unmarshal(cfgData, &Instance)
if err != nil {
panic("配置文件加载失败" + err.Error())
return
}
// 读取表设置
Instance.Tables = map[string]string{}
Instance.TablesInitData = map[string]string{}
err = fs.WalkDir(tableConfig, "tables", func(path string, info fs.DirEntry, err error) error {
root := "tables/mysql"
if Instance.DbType == DBTypeSQLite {
root = "tables/sqlite"
}
err = fs.WalkDir(tableConfig, root, func(path string, info fs.DirEntry, err error) error {
if !info.IsDir() && strings.HasSuffix(info.Name(), ".sql") {
tableName := strings.ReplaceAll(info.Name(), ".sql", "")
i, e := tableConfig.ReadFile(path)
@@ -76,4 +90,8 @@ func Init() {
panic(err)
}
if Instance.Domain != "" && Instance.IsInit {
IsInit = true
}
}
+6 -3
View File
@@ -1,11 +1,14 @@
{
"domain": "demo.com",
"domain": "",
"webDomain": "",
"dkimPrivateKeyPath": "config/dkim/dkim.priv",
"SSLPrivateKeyPath": "config/ssl/private.key",
"SSLPublicKeyPath": "config/ssl/public.crt",
"mysqlDSN": "",
"dbDSN": "",
"dbType": "",
"weChatPushAppId": "",
"weChatPushSecret": "",
"weChatPushTemplateId": "",
"weChatPushUserId": ""
"weChatPushUserId": "",
"isInit": false
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,2 @@
INSERT INTO user (account, name, password) VALUES ('admin', 'admin', 'faddb6ec2efe16116a342f5512583c48');
@@ -0,0 +1,2 @@
INSERT INTO user_auth (user_id, email_account) VALUES (1, '*');
+26
View File
@@ -0,0 +1,26 @@
CREATE table email
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
type tinyint(4) NOT NULL DEFAULT 0 ,
subject varchar(1000) NOT NULL DEFAULT '' ,
reply_to json ,
from_name varchar(50) NOT NULL DEFAULT '' ,
from_address varchar(150) NOT NULL DEFAULT '' ,
`to` json ,
bcc json ,
cc json ,
`text` text ,
html text ,
sender json ,
attachments json ,
spf_check tinyint(1) DEFAULT 0 ,
dkim_check tinyint(1) DEFAULT 0 ,
status tinyint(4) NOT NULL DEFAULT 0 ,
send_user_id int unsigned NOT NULL DEFAULT 0 ,
is_read tinyint(1) NOT NULL DEFAULT 0 ,
error text ,
cron_send_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ,
send_date datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ,
create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ,
update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
)
+8
View File
@@ -0,0 +1,8 @@
CREATE TABLE sessions
(
token TEXT PRIMARY KEY,
data BLOB NOT NULL,
expiry REAL NOT NULL
);
CREATE INDEX sessions_expiry_idx ON sessions (expiry);
+8
View File
@@ -0,0 +1,8 @@
CREATE TABLE user
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
account varchar(20),
name varchar(10),
password char(32)
);
CREATE UNIQUE INDEX udx_account on user (account);
@@ -0,0 +1,9 @@
CREATE TABLE user_auth
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id int ,
email_account varchar(30)
);
CREATE UNIQUE INDEX udx_uid_ename on user_auth ( user_id, email_account);
CREATE UNIQUE INDEX udx_ename_uid on user_auth ( email_account,user_id );