5
5
"os"
6
6
"path/filepath"
7
7
8
+ "github.com/dingdinglz/dingbot/appconfig"
9
+ "github.com/dingdinglz/dingbot/database"
8
10
"github.com/dingdinglz/dingbot/tool"
9
11
"github.com/gofiber/fiber/v2"
10
12
)
@@ -13,6 +15,8 @@ func InitRoute(c *fiber.Ctx) error {
13
15
port := c .FormValue ("port" , "" )
14
16
databaseType := c .FormValue ("database" , "" )
15
17
source := c .FormValue ("source" , "" )
18
+ user := c .FormValue ("username" , "" )
19
+ pass := c .FormValue ("password" , "" )
16
20
if port == "" {
17
21
return JsonMessage (c , 1 , "port不能为空!" )
18
22
}
@@ -22,8 +26,17 @@ func InitRoute(c *fiber.Ctx) error {
22
26
if source == "" {
23
27
return JsonMessage (c , 1 , "source不能为空!" )
24
28
}
29
+ if user == "" {
30
+ return JsonMessage (c , 1 , "username不能为空!" )
31
+ }
32
+ if pass == "" {
33
+ return JsonMessage (c , 1 , "password不能为空!" )
34
+ }
25
35
configText , _ := json .Marshal (fiber.Map {"port" : tool .StringToInt (port ), "database" : databaseType , "source" : source })
26
36
rootPath , _ := os .Getwd ()
27
37
os .WriteFile (filepath .Join (rootPath , "data" , "config.json" ), configText , os .ModePerm )
38
+ appconfig .ConfigInit ()
39
+ database .DatabaseInit ()
40
+ database .UserNew (user , pass )
28
41
return JsonMessage (c , 0 , "ok" )
29
42
}
0 commit comments