1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 14:08:06 +08:00

feat: model.Database -> model.AppDatabase

This commit is contained in:
zhengkunwang223 2022-10-20 16:15:11 +08:00 committed by ssongliu
parent 1cd18a9938
commit b2653c2aef
8 changed files with 51 additions and 19 deletions

1
.gitignore vendored
View File

@ -22,3 +22,4 @@ build
# vendor/ # vendor/
/pkg/ /pkg/
backend/__debug_bin backend/__debug_bin
cmd/server/__debug_bin

View File

@ -48,4 +48,4 @@ cors:
# 加密设置 # 加密设置
encrypt: encrypt:
key: 1Panel123@2022! key: 1Panel123@2022!!

View File

@ -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)
}

View File

@ -24,7 +24,8 @@
<SvgIcon :iconName="(subItem.meta?.icon as string)" :className="'svg-icon'"></SvgIcon> <SvgIcon :iconName="(subItem.meta?.icon as string)" :className="'svg-icon'"></SvgIcon>
</el-icon> </el-icon>
<template #title> <template #title>
<span style="margin-left: 10px">{{ $t(subItem.meta?.title as string) }}</span> <span v-if="subItem.meta?.icon">{{ $t(subItem.meta?.title as string) }}</span>
<span v-else style="margin-left: 10px">{{ $t(subItem.meta?.title as string) }}</span>
</template> </template>
</el-menu-item> </el-menu-item>
</template> </template>

View File

@ -97,10 +97,6 @@ const paginationConfig = reactive({
total: 0, total: 0,
}); });
const logSearch = reactive({
page: 1,
pageSize: 10,
});
const weekOptions = [ const weekOptions = [
{ label: i18n.global.t('cronjob.monday'), value: 1 }, { label: i18n.global.t('cronjob.monday'), value: 1 },
{ label: i18n.global.t('cronjob.tuesday'), value: 2 }, { label: i18n.global.t('cronjob.tuesday'), value: 2 },
@ -112,9 +108,11 @@ const weekOptions = [
]; ];
const search = async () => { const search = async () => {
logSearch.page = paginationConfig.currentPage; let params = {
logSearch.pageSize = paginationConfig.pageSize; page: paginationConfig.currentPage,
const res = await getCronjobPage(logSearch); pageSize: paginationConfig.pageSize,
};
const res = await getCronjobPage(params);
data.value = res.data.items || []; data.value = res.data.items || [];
for (const item of data.value) { for (const item of data.value) {
if (item.targetDir !== '-') { if (item.targetDir !== '-') {

View File

@ -96,14 +96,14 @@ const loginRules = reactive({
const loginForm = reactive<Login.ReqLoginForm>({ const loginForm = reactive<Login.ReqLoginForm>({
name: 'admin', name: 'admin',
password: 'Calong@2015', password: '1Panel@2022',
captcha: '', captcha: '',
captchaID: '', captchaID: '',
authMethod: '', authMethod: '',
}); });
const mfaLoginForm = reactive<Login.MFALoginForm>({ const mfaLoginForm = reactive<Login.MFALoginForm>({
name: 'admin', name: 'admin',
password: 'Calong@2015', password: '1Panel@2022',
secret: '', secret: '',
code: '', code: '',
authMethod: '', authMethod: '',

View File

@ -78,15 +78,12 @@ const paginationConfig = reactive({
total: 0, total: 0,
}); });
const logSearch = reactive({
page: 1,
pageSize: 5,
});
const search = async () => { const search = async () => {
logSearch.page = paginationConfig.currentPage; let params = {
logSearch.pageSize = paginationConfig.pageSize; page: paginationConfig.currentPage,
const res = await getOperationList(logSearch); pageSize: paginationConfig.pageSize,
};
const res = await getOperationList(params);
data.value = res.data.items; data.value = res.data.items;
paginationConfig.total = res.data.total; paginationConfig.total = res.data.total;
}; };

1
go.sum
View File

@ -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.4/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
gorm.io/gorm v1.23.8 h1:h8sGJ+biDgBA1AD1Ha9gFCx7h8npU7AsLdlkX0n2TpE= gorm.io/gorm v1.23.8 h1:h8sGJ+biDgBA1AD1Ha9gFCx7h8npU7AsLdlkX0n2TpE=
gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= 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 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.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8= gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=