From b2653c2aef94960a69b522a6351808b660b3973f Mon Sep 17 00:00:00 2001 From: zhengkunwang223 Date: Thu, 20 Oct 2022 16:15:11 +0800 Subject: [PATCH] feat: model.Database -> model.AppDatabase --- .gitignore | 1 + backend/app.yaml | 2 +- backend/app/service/mysql_test.go | 34 +++++++++++++++++++ .../app-layout/menu/components/sub-item.vue | 3 +- frontend/src/views/cronjob/index.vue | 12 +++---- .../src/views/login/components/login-form.vue | 4 +-- frontend/src/views/operation-log/index.vue | 13 +++---- go.sum | 1 + 8 files changed, 51 insertions(+), 19 deletions(-) create mode 100644 backend/app/service/mysql_test.go diff --git a/.gitignore b/.gitignore index 816771c9c..a04c14bdf 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ build # vendor/ /pkg/ backend/__debug_bin +cmd/server/__debug_bin diff --git a/backend/app.yaml b/backend/app.yaml index 9e51cf59e..641320c6e 100644 --- a/backend/app.yaml +++ b/backend/app.yaml @@ -48,4 +48,4 @@ cors: # 加密设置 encrypt: - key: 1Panel123@2022! \ No newline at end of file + key: 1Panel123@2022!! \ No newline at end of file diff --git a/backend/app/service/mysql_test.go b/backend/app/service/mysql_test.go new file mode 100644 index 000000000..f23f27e74 --- /dev/null +++ b/backend/app/service/mysql_test.go @@ -0,0 +1,34 @@ +package service + +import ( + "context" + "database/sql" + "fmt" + "log" + "testing" + "time" + + _ "gorm.io/driver/mysql" +) + +func TestMysql(t *testing.T) { + connArgs := fmt.Sprintf("%s:%s@tcp(%s:%d)/?charset=utf8", "root", "Calong@2015", "localhost", 2306) + db, err := sql.Open("mysql", connArgs) + if err != nil { + fmt.Println(err) + } + defer db.Close() + ctx, cancelfunc := context.WithTimeout(context.Background(), 5*time.Second) + defer cancelfunc() + res, err := db.ExecContext(ctx, "CREATE DATABASE IF NOT EXISTS "+"songli") + if err != nil { + log.Printf("Error %s when creating DB\n", err) + return + } + + // res, err := db.Exec("SHOW DATABASES;") + // if err != nil { + // fmt.Println(err) + // } + fmt.Println(res) +} diff --git a/frontend/src/components/app-layout/menu/components/sub-item.vue b/frontend/src/components/app-layout/menu/components/sub-item.vue index d2805d16a..848de48ac 100644 --- a/frontend/src/components/app-layout/menu/components/sub-item.vue +++ b/frontend/src/components/app-layout/menu/components/sub-item.vue @@ -24,7 +24,8 @@ diff --git a/frontend/src/views/cronjob/index.vue b/frontend/src/views/cronjob/index.vue index 67783ec80..bc4726d2e 100644 --- a/frontend/src/views/cronjob/index.vue +++ b/frontend/src/views/cronjob/index.vue @@ -97,10 +97,6 @@ const paginationConfig = reactive({ total: 0, }); -const logSearch = reactive({ - page: 1, - pageSize: 10, -}); const weekOptions = [ { label: i18n.global.t('cronjob.monday'), value: 1 }, { label: i18n.global.t('cronjob.tuesday'), value: 2 }, @@ -112,9 +108,11 @@ const weekOptions = [ ]; const search = async () => { - logSearch.page = paginationConfig.currentPage; - logSearch.pageSize = paginationConfig.pageSize; - const res = await getCronjobPage(logSearch); + let params = { + page: paginationConfig.currentPage, + pageSize: paginationConfig.pageSize, + }; + const res = await getCronjobPage(params); data.value = res.data.items || []; for (const item of data.value) { if (item.targetDir !== '-') { diff --git a/frontend/src/views/login/components/login-form.vue b/frontend/src/views/login/components/login-form.vue index 222b4f894..bda20e005 100644 --- a/frontend/src/views/login/components/login-form.vue +++ b/frontend/src/views/login/components/login-form.vue @@ -96,14 +96,14 @@ const loginRules = reactive({ const loginForm = reactive({ name: 'admin', - password: 'Calong@2015', + password: '1Panel@2022', captcha: '', captchaID: '', authMethod: '', }); const mfaLoginForm = reactive({ name: 'admin', - password: 'Calong@2015', + password: '1Panel@2022', secret: '', code: '', authMethod: '', diff --git a/frontend/src/views/operation-log/index.vue b/frontend/src/views/operation-log/index.vue index a33728481..f84b0ddbe 100644 --- a/frontend/src/views/operation-log/index.vue +++ b/frontend/src/views/operation-log/index.vue @@ -78,15 +78,12 @@ const paginationConfig = reactive({ total: 0, }); -const logSearch = reactive({ - page: 1, - pageSize: 5, -}); - const search = async () => { - logSearch.page = paginationConfig.currentPage; - logSearch.pageSize = paginationConfig.pageSize; - const res = await getOperationList(logSearch); + let params = { + page: paginationConfig.currentPage, + pageSize: paginationConfig.pageSize, + }; + const res = await getOperationList(params); data.value = res.data.items; paginationConfig.total = res.data.total; }; diff --git a/go.sum b/go.sum index 225e98255..009168150 100644 --- a/go.sum +++ b/go.sum @@ -1466,6 +1466,7 @@ gorm.io/driver/sqlserver v1.3.2 h1:yYt8f/xdAKLY7lCCyXxIUEgZ/WsURos3dHrx8MKFGAk= gorm.io/gorm v1.23.4/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= gorm.io/gorm v1.23.8 h1:h8sGJ+biDgBA1AD1Ha9gFCx7h8npU7AsLdlkX0n2TpE= gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= +gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=