parent
208541b9b3
commit
7886dad432
@ -1,20 +1,47 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/taoshihan1991/imaptool/tmpl"
|
||||
"net/http"
|
||||
"github.com/taoshihan1991/imaptool/config"
|
||||
"github.com/taoshihan1991/imaptool/tools"
|
||||
"os"
|
||||
)
|
||||
func MysqlGetConf(c *gin.Context) {
|
||||
|
||||
mysqlInfo:=config.GetMysql()
|
||||
c.JSON(200, gin.H{
|
||||
"code": 200,
|
||||
"msg": "验证成功",
|
||||
"result":mysqlInfo,
|
||||
})
|
||||
}
|
||||
func ActionMysqlSet(w http.ResponseWriter, r *http.Request) {
|
||||
render := tmpl.NewSettingHtml(w)
|
||||
render.SetLeft("setting_left")
|
||||
render.SetBottom("setting_bottom")
|
||||
render.Display("mysql_setting", render)
|
||||
func MysqlSetConf(c *gin.Context) {
|
||||
|
||||
mysqlServer:=c.PostForm("server")
|
||||
mysqlPort:=c.PostForm("port")
|
||||
mysqlDb:=c.PostForm("database")
|
||||
mysqlUsername:=c.PostForm("username")
|
||||
mysqlPassword:=c.PostForm("password")
|
||||
isExist, _ := tools.IsFileExist(config.Dir)
|
||||
if !isExist {
|
||||
os.Mkdir(config.Dir, os.ModePerm)
|
||||
}
|
||||
fileConfig := config.MysqlConf
|
||||
file, _ := os.OpenFile(fileConfig, os.O_RDWR|os.O_CREATE, os.ModePerm)
|
||||
|
||||
format := `{
|
||||
"Server":"%s",
|
||||
"Port":"%s",
|
||||
"Database":"%s",
|
||||
"Username":"%s",
|
||||
"Password":"%s"
|
||||
}
|
||||
`
|
||||
data := fmt.Sprintf(format, mysqlServer,mysqlPort,mysqlDb,mysqlUsername,mysqlPassword)
|
||||
file.WriteString(data)
|
||||
|
||||
c.JSON(200, gin.H{
|
||||
"code": 200,
|
||||
"msg": "操作成功",
|
||||
})
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
{{template "header" }}
|
||||
<div id="app" style="width:100%">
|
||||
<template>
|
||||
<el-container v-loading.fullscreen.lock="fullscreenLoading">
|
||||
<el-aside>
|
||||
{{template "setting_left" .}}
|
||||
</el-aside>
|
||||
|
||||
<el-main class="mainMain">
|
||||
<el-form :model="mysql" :rules="rules" ref="mysql" label-width="120px">
|
||||
<el-form-item label="服务地址" prop="server">
|
||||
<el-input v-model="mysql.server"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="端口" prop="port">
|
||||
<el-input v-model="mysql.port"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="数据库名" prop="database">
|
||||
<el-input v-model="mysql.database"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="用户名" prop="username">
|
||||
<el-input v-model="mysql.username"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="密码" prop="password">
|
||||
<el-input v-model="mysql.password"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="setMysql('mysql')">立即创建</el-button>
|
||||
<el-button @click="resetForm('mysql')">取消</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-main>
|
||||
|
||||
</el-container>
|
||||
</template>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
{{template "setting_bottom" .}}
|
Loading…
Reference in new issue