Skip to content

Commit d1e0554

Browse files
committed
feature:前端自动化增加分包
1 parent 7365343 commit d1e0554

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

server/resource/autocode_template/web/form.vue.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ import {
7171
create{{.StructName}},
7272
update{{.StructName}},
7373
find{{.StructName}}
74-
} from '@/api/{{.PackageName}}'
74+
} from '@/api/{{.Package}}/{{.PackageName}}'
7575
7676
defineOptions({
7777
name: '{{.StructName}}Form'

server/resource/autocode_template/web/table.vue.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ import {
327327
update{{.StructName}},
328328
find{{.StructName}},
329329
get{{.StructName}}List
330-
} from '@/api/{{.PackageName}}'
330+
} from '@/api/{{.Package}}/{{.PackageName}}'
331331
332332
{{- if or .HasPic .HasFile}}
333333
import { getUrl } from '@/utils/image'

server/service/system/sys_auto_code.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,13 +498,13 @@ func (autoCodeService *AutoCodeService) addAutoMoveFile(data *tplData) {
498498
} else if strings.Contains(fileSlice[1], "web") {
499499
if strings.Contains(fileSlice[n-1], "js") {
500500
data.autoMoveFilePath = filepath.Join(global.GVA_CONFIG.AutoCode.Root,
501-
global.GVA_CONFIG.AutoCode.Web, global.GVA_CONFIG.AutoCode.WApi, base)
501+
global.GVA_CONFIG.AutoCode.Web, global.GVA_CONFIG.AutoCode.WApi, data.autoPackage, base)
502502
} else if strings.Contains(fileSlice[n-2], "form") {
503503
data.autoMoveFilePath = filepath.Join(global.GVA_CONFIG.AutoCode.Root,
504-
global.GVA_CONFIG.AutoCode.Web, global.GVA_CONFIG.AutoCode.WForm, filepath.Base(filepath.Dir(filepath.Dir(data.autoCodePath))), strings.TrimSuffix(base, filepath.Ext(base))+"Form.vue")
504+
global.GVA_CONFIG.AutoCode.Web, global.GVA_CONFIG.AutoCode.WForm, data.autoPackage, filepath.Base(filepath.Dir(filepath.Dir(data.autoCodePath))), strings.TrimSuffix(base, filepath.Ext(base))+"Form.vue")
505505
} else if strings.Contains(fileSlice[n-2], "table") {
506506
data.autoMoveFilePath = filepath.Join(global.GVA_CONFIG.AutoCode.Root,
507-
global.GVA_CONFIG.AutoCode.Web, global.GVA_CONFIG.AutoCode.WTable, filepath.Base(filepath.Dir(filepath.Dir(data.autoCodePath))), base)
507+
global.GVA_CONFIG.AutoCode.Web, global.GVA_CONFIG.AutoCode.WTable, data.autoPackage, filepath.Base(filepath.Dir(filepath.Dir(data.autoCodePath))), base)
508508
}
509509
}
510510
}
@@ -581,7 +581,7 @@ func (autoCodeService *AutoCodeService) AutoCreateMenu(a *system.AutoCodeStruct)
581581
menu.Name = a.Abbreviation
582582
menu.Path = a.Abbreviation
583583
menu.Meta.Title = a.Description
584-
menu.Component = fmt.Sprintf("view/%s/%s.vue", a.PackageName, a.PackageName)
584+
menu.Component = fmt.Sprintf("view/%s/%s/%s.vue", a.Package, a.PackageName, a.PackageName)
585585
err = global.GVA_DB.Create(&menu).Error
586586
return menu.ID, err
587587
}
@@ -694,6 +694,19 @@ func (autoCodeService *AutoCodeService) CreatePackageTemp(packageName string) er
694694
name: packageAPIName,
695695
temp: string(subcontract.API),
696696
}}
697+
698+
webTemp := []string{
699+
filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Web, global.GVA_CONFIG.AutoCode.WApi),
700+
filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Web, global.GVA_CONFIG.AutoCode.WForm),
701+
}
702+
703+
for _, s := range webTemp {
704+
err := os.MkdirAll(filepath.Join(s, packageName), 0755)
705+
if err != nil {
706+
return err
707+
}
708+
}
709+
697710
for i, s := range pendingTemp {
698711
pendingTemp[i].path = filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, filepath.Clean(fmt.Sprintf(s.path, packageName)))
699712
}

server/service/system/sys_autocode_history.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func (autoCodeHistoryService *AutoCodeHistoryService) CreateAutoCodeHistory(meta
4141
TableName: tableName,
4242
ApiIDs: apiIds,
4343
BusinessDB: BusinessDB,
44+
MenuID: menuID,
4445
}).Error
4546
}
4647

0 commit comments

Comments
 (0)