Browse Source

feat:完善前后端回滚交互信息交换

main
songzhibin97 3 years ago
parent
commit
90f3eddc14
  1. 10
      server/model/sys_autocode_history.go
  2. 4
      server/service/sys_auto_code.go
  3. 6
      server/service/sys_autocode_history.go

10
server/model/sys_autocode_history.go

@ -7,10 +7,12 @@ import "gin-vue-admin/global"
type SysAutoCodeHistory struct { type SysAutoCodeHistory struct {
global.GVA_MODEL global.GVA_MODEL
TableName string `json:"tableName"` TableName string `json:"tableName"`
RequestMeta string `gorm:"type:text" json:"requestMeta,omitempty"` // 前端传入的结构化信息
AutoCodePath string `gorm:"type:text" json:"autoCodePath"` // 其他meta信息 path;path
InjectionMeta string `gorm:"type:text" json:"injectionMeta"` // 注入的内容 RouterPath@functionName@RouterString;
ApiIDs string `json:"apiIDs"` // api表注册内容
RequestMeta string `gorm:"type:text" json:"requestMeta,omitempty"` // 前端传入的结构化信息
AutoCodePath string `gorm:"type:text" json:"autoCodePath,omitempty"` // 其他meta信息 path;path
InjectionMeta string `gorm:"type:text" json:"injectionMeta,omitempty"` // 注入的内容 RouterPath@functionName@RouterString;
StructName string `json:"structName"`
StructCNName string `json:"structCNName"`
ApiIDs string `json:"apiIDs,omitempty"` // api表注册内容
Flag int // 表示对应状态 0 代表创建, 1 代表回滚 ... Flag int // 表示对应状态 0 代表创建, 1 代表回滚 ...
} }

4
server/service/sys_auto_code.go

@ -185,6 +185,8 @@ func CreateTemp(autoCode model.AutoCodeStruct, ids ...uint) (err error) {
if autoCode.TableName != "" { if autoCode.TableName != "" {
err = CreateAutoCodeHistory( err = CreateAutoCodeHistory(
string(meta), string(meta),
autoCode.StructName,
autoCode.Description,
bf.String(), bf.String(),
injectionCodeMeta.String(), injectionCodeMeta.String(),
autoCode.TableName, autoCode.TableName,
@ -193,6 +195,8 @@ func CreateTemp(autoCode model.AutoCodeStruct, ids ...uint) (err error) {
} else { } else {
err = CreateAutoCodeHistory( err = CreateAutoCodeHistory(
string(meta), string(meta),
autoCode.StructName,
autoCode.Description,
bf.String(), bf.String(),
injectionCodeMeta.String(), injectionCodeMeta.String(),
autoCode.StructName, autoCode.StructName,

6
server/service/sys_autocode_history.go

@ -11,11 +11,13 @@ import (
) )
// CreateAutoCodeHistory RouterPath : RouterPath@RouterString;RouterPath2@RouterString2 // CreateAutoCodeHistory RouterPath : RouterPath@RouterString;RouterPath2@RouterString2
func CreateAutoCodeHistory(meta, autoCodePath string, injectionMeta string, tableName string, apiIds string) error {
func CreateAutoCodeHistory(meta, structName, structCNName, autoCodePath string, injectionMeta string, tableName string, apiIds string) error {
return global.GVA_DB.Create(&model.SysAutoCodeHistory{ return global.GVA_DB.Create(&model.SysAutoCodeHistory{
RequestMeta: meta, RequestMeta: meta,
AutoCodePath: autoCodePath, AutoCodePath: autoCodePath,
InjectionMeta: injectionMeta, InjectionMeta: injectionMeta,
StructName: structName,
StructCNName: structCNName,
TableName: tableName, TableName: tableName,
ApiIDs: apiIds, ApiIDs: apiIds,
}).Error }).Error
@ -74,6 +76,6 @@ func GetSysHistoryPage(info request.PageInfo) (err error, list interface{}, tota
db := global.GVA_DB db := global.GVA_DB
var fileLists []model.SysAutoCodeHistory var fileLists []model.SysAutoCodeHistory
err = db.Find(&fileLists).Count(&total).Error err = db.Find(&fileLists).Count(&total).Error
err = db.Limit(limit).Offset(offset).Order("updated_at desc").Select("id,created_at,updated_at,table_name,auto_code_path,injection_meta,api_ids,flag").Find(&fileLists).Error
err = db.Limit(limit).Offset(offset).Order("updated_at desc").Select("id,created_at,updated_at,struct_name,struct_cn_name,flag").Find(&fileLists).Error
return err, fileLists, total return err, fileLists, total
} }
Loading…
Cancel
Save