flipped-aurora/gin-vue-admin · error
已经创建过此数据结构,请勿重复创建!
Error message
已经创建过此数据结构,请勿重复创建!
What it means
autoCodeTemplate.Create first checks whether an autocode entry with the same identity (business DB, struct name, package/abbreviation) already exists via autoCodeIdentityExists. If it does, creation is refused with "已经创建过此数据结构,请勿重复创建!" (this data structure has already been created, do not duplicate it) to avoid generating duplicate code/history for the same table.
Source
Thrown at server/service/system/auto_code_template.go:84
// Frontend files are published last, but their Vite refresh may still cancel
// the HTTP request before the handler returns. The accepted create task must finish.
createCtx := autoCodeCreateContext(ctx)
var autoPkg model.SysAutoCodePackage
err := global.GVA_DB.WithContext(createCtx).Where("package_name = ?", info.Package).First(&autoPkg).Error
if err != nil {
return errors.Wrap(err, "查询包失败!")
}
err = s.checkPackage(info.Package, autoPkg.Template)
if err != nil {
return err
}
exists, err := autoCodeIdentityExists(createCtx, global.GVA_DB, info)
if err != nil {
return err
}
if exists {
return errors.New("已经创建过此数据结构,请勿重复创建!")
}
layout, err := newAutoCodeTaskLayout(
global.GVA_CONFIG.AutoCode.Root,
global.GVA_CONFIG.AutoCode.Server,
global.GVA_CONFIG.AutoCode.WebRoot(),
)
if err != nil {
return err
}
generated, templates, injections, err := s.generate(createCtx, info, autoPkg)
if err != nil {
return err
}
history := info.History()
history.Templates = templates
history.Injections = make(map[string]string, len(injections))
for key, value := range injections {View on GitHub (pinned to 3136500ef3)
Solutions
- Use the existing generated entry instead of re-creating it.
- If you genuinely need a second structure, change structName (and abbreviation/package as appropriate) to unique values.
- Clear stale autocode history rows for that table if a previous run failed and left an orphan record, then retry.
- Set IsAdd/overwrite semantics where supported instead of a plain create.
Example fix
// before: duplicate request
{"businessDB":"gva","structName":"User","package":"admin"} // already exists
// after: unique struct name
{"businessDB":"gva","structName":"UserProfile","package":"admin"} Defensive patterns
Strategy: validation
Validate before calling
exists, err := autoCodeIdentityExists(ctx, db, info)
if err == nil && exists {
return errors.New("该数据结构已存在, 请直接使用或更换 structName")
}
// safe to call Create Try / catch
if err := autoCodeService.CreateAutoCode(ctx, info); err != nil {
if strings.Contains(err.Error(), "请勿重复创建") {
return fmt.Errorf("请改用已有条目或修改 structName/package: %w", err)
}
return err
} Prevention
- Search existing autocode entries before creating a new one.
- Use unique structName/package per business table.
- Clean up history rows after failed generations before retrying.
- Debounce/double-click-guard the create button in the UI.
When it happens
Trigger: POSTing the same autocode create request twice; creating a struct with the same structName/package for the same business DB; retrying after a failed run that already recorded history.
Common situations: Users double-clicking the generate button; importing the same table into autocode from two places; leftover history rows from a previous partially completed generation.
Related errors
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/e641277f86b160f0.
Report an issue: GitHub.