Skip to content

Commit

Permalink
feature:前端自动化增加分包
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelmaxQm committed Apr 7, 2024
1 parent 7365343 commit d1e0554
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion server/resource/autocode_template/web/form.vue.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ import {
create{{.StructName}},
update{{.StructName}},
find{{.StructName}}
} from '@/api/{{.PackageName}}'
} from '@/api/{{.Package}}/{{.PackageName}}'
defineOptions({
name: '{{.StructName}}Form'
Expand Down
2 changes: 1 addition & 1 deletion server/resource/autocode_template/web/table.vue.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ import {
update{{.StructName}},
find{{.StructName}},
get{{.StructName}}List
} from '@/api/{{.PackageName}}'
} from '@/api/{{.Package}}/{{.PackageName}}'
{{- if or .HasPic .HasFile}}
import { getUrl } from '@/utils/image'
Expand Down
21 changes: 17 additions & 4 deletions server/service/system/sys_auto_code.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,13 +498,13 @@ func (autoCodeService *AutoCodeService) addAutoMoveFile(data *tplData) {
} else if strings.Contains(fileSlice[1], "web") {
if strings.Contains(fileSlice[n-1], "js") {
data.autoMoveFilePath = filepath.Join(global.GVA_CONFIG.AutoCode.Root,
global.GVA_CONFIG.AutoCode.Web, global.GVA_CONFIG.AutoCode.WApi, base)
global.GVA_CONFIG.AutoCode.Web, global.GVA_CONFIG.AutoCode.WApi, data.autoPackage, base)
} else if strings.Contains(fileSlice[n-2], "form") {
data.autoMoveFilePath = filepath.Join(global.GVA_CONFIG.AutoCode.Root,
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")
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")
} else if strings.Contains(fileSlice[n-2], "table") {
data.autoMoveFilePath = filepath.Join(global.GVA_CONFIG.AutoCode.Root,
global.GVA_CONFIG.AutoCode.Web, global.GVA_CONFIG.AutoCode.WTable, filepath.Base(filepath.Dir(filepath.Dir(data.autoCodePath))), base)
global.GVA_CONFIG.AutoCode.Web, global.GVA_CONFIG.AutoCode.WTable, data.autoPackage, filepath.Base(filepath.Dir(filepath.Dir(data.autoCodePath))), base)
}
}
}
Expand Down Expand Up @@ -581,7 +581,7 @@ func (autoCodeService *AutoCodeService) AutoCreateMenu(a *system.AutoCodeStruct)
menu.Name = a.Abbreviation
menu.Path = a.Abbreviation
menu.Meta.Title = a.Description
menu.Component = fmt.Sprintf("view/%s/%s.vue", a.PackageName, a.PackageName)
menu.Component = fmt.Sprintf("view/%s/%s/%s.vue", a.Package, a.PackageName, a.PackageName)
err = global.GVA_DB.Create(&menu).Error
return menu.ID, err
}
Expand Down Expand Up @@ -694,6 +694,19 @@ func (autoCodeService *AutoCodeService) CreatePackageTemp(packageName string) er
name: packageAPIName,
temp: string(subcontract.API),
}}

webTemp := []string{
filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Web, global.GVA_CONFIG.AutoCode.WApi),
filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Web, global.GVA_CONFIG.AutoCode.WForm),
}

for _, s := range webTemp {
err := os.MkdirAll(filepath.Join(s, packageName), 0755)
if err != nil {
return err
}
}

for i, s := range pendingTemp {
pendingTemp[i].path = filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, filepath.Clean(fmt.Sprintf(s.path, packageName)))
}
Expand Down
1 change: 1 addition & 0 deletions server/service/system/sys_autocode_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (autoCodeHistoryService *AutoCodeHistoryService) CreateAutoCodeHistory(meta
TableName: tableName,
ApiIDs: apiIds,
BusinessDB: BusinessDB,
MenuID: menuID,
}).Error
}

Expand Down

0 comments on commit d1e0554

Please sign in to comment.