自动设置数据库

This commit is contained in:
hoteas 2019-11-10 16:49:05 +08:00
parent 58b908f8ba
commit fa641b9dcd
2 changed files with 13 additions and 12 deletions

View File

@ -1,14 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="b2aca021-ff30-4cbf-8dc9-8cdd4f4c39dc" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/dri/db/auto.go" afterDir="false" />
<change afterPath="$PROJECT_DIR$/dri/mysql/mysql.go" afterDir="false" />
<change afterPath="$PROJECT_DIR$/dri/sqlite/sqlite.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/config/config.json" beforeDir="false" afterPath="$PROJECT_DIR$/example/config/config.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/example/main.go" afterDir="false" />
</list>
<list default="true" id="b2aca021-ff30-4cbf-8dc9-8cdd4f4c39dc" name="Default Changelist" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -74,7 +67,7 @@
<option name="presentableId" value="Default" />
<updated>1573372557346</updated>
<workItem from="1573372558521" duration="18000" />
<workItem from="1573372583551" duration="2743000" />
<workItem from="1573372583551" duration="3000000" />
</task>
<task id="LOCAL-00001" summary="清理">
<created>1573372845218</created>
@ -90,7 +83,14 @@
<option name="project" value="LOCAL" />
<updated>1573372887175</updated>
</task>
<option name="localTasksCounter" value="3" />
<task id="LOCAL-00003" summary="自动设置数据库">
<created>1573375369161</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1573375369161</updated>
</task>
<option name="localTasksCounter" value="4" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -111,6 +111,7 @@
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="清理" />
<option name="LAST_COMMIT_MESSAGE" value="清理" />
<MESSAGE value="自动设置数据库" />
<option name="LAST_COMMIT_MESSAGE" value="自动设置数据库" />
</component>
</project>

View File

@ -8,7 +8,7 @@ import (
)
func SetDB(appIns *hotime.Application) {
if appIns.Config.GetString("dbType") == "sqlite" || strings.Contains(appIns.Config.GetString("dbName"), ".db") {
if appIns.Config.GetString("dbType") == "sqlite" || strings.Index(appIns.Config.GetString("dbName"), ".db") == len(appIns.Config.GetString("dbName"))-3 {
sqlite.SetDB(appIns)
} else {
mysql.SetDB(appIns)