mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 18:58:02 +08:00
[REV] Fix parse json format for export app struct.
This commit is contained in:
parent
869eac8def
commit
374140250f
@ -35,7 +35,6 @@ func (a *AppAction) Complete(tr *model.ExportAppStruct) error {
|
||||
return err
|
||||
}
|
||||
|
||||
tr.Body.GroupName = appName
|
||||
appName = unicode2zh(appName)
|
||||
tr.SourceDir = fmt.Sprintf("/grdata/export-app/%s-%s", appName, tr.Body.Version)
|
||||
|
||||
@ -47,7 +46,7 @@ func (a *AppAction) ExportApp(tr *model.ExportAppStruct) error {
|
||||
return util.CreateAPIHandleErrorFromDBError("Failed to export app", err)
|
||||
}
|
||||
|
||||
mqBody, err := json.Marshal(BuildExportAppBody(tr))
|
||||
mqBody, err := json.Marshal(model.BuildMQBodyFrom(tr))
|
||||
if err != nil {
|
||||
logrus.Error("Failed to encode json from ExportAppStruct:", err)
|
||||
return err
|
||||
@ -87,14 +86,13 @@ func (a *AppAction) ExportRunnableApp(tr *model.ExportAppStruct) error {
|
||||
}
|
||||
|
||||
appName = unicode2zh(appName)
|
||||
|
||||
tr.SourceDir = fmt.Sprintf("/grdata/export-runnable-app/%s-%s", appName, tr.Body.Version)
|
||||
|
||||
if err := saveMetadata(tr); err != nil {
|
||||
return util.CreateAPIHandleErrorFromDBError("Failed to export app", err)
|
||||
}
|
||||
|
||||
mqBody, err := json.Marshal(BuildExportAppBody(tr))
|
||||
mqBody, err := json.Marshal(model.BuildMQBodyFrom(tr))
|
||||
if err != nil {
|
||||
logrus.Error("Failed to encode json from ExportAppStruct:", err)
|
||||
return err
|
||||
@ -123,22 +121,6 @@ func (a *AppAction) ExportRunnableApp(tr *model.ExportAppStruct) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func BuildExportAppBody(tr *model.ExportAppStruct) *ExportAppBody {
|
||||
return &ExportAppBody{
|
||||
EventID: tr.Body.EventID,
|
||||
ServiceKey: tr.Body.GroupKey,
|
||||
Format: tr.Body.Format,
|
||||
SourceDir: tr.SourceDir,
|
||||
}
|
||||
}
|
||||
|
||||
type ExportAppBody struct {
|
||||
EventID string `json:"event_id"`
|
||||
ServiceKey string `json:"service_key"`
|
||||
Format string `json:"format"`
|
||||
SourceDir string `json:"source_dir"`
|
||||
}
|
||||
|
||||
func saveMetadata(tr *model.ExportAppStruct) error {
|
||||
os.RemoveAll(tr.SourceDir)
|
||||
os.MkdirAll(tr.SourceDir, 0755)
|
||||
|
@ -1354,23 +1354,39 @@ type ExportAppStruct struct {
|
||||
Body struct {
|
||||
EventID string `json:"event_id"`
|
||||
GroupKey string `json:"group_key"`
|
||||
GroupName string `json:"group_name"`
|
||||
Version string `json:"version"`
|
||||
Format string `json:"format"` // only rainbond-app/docker-compose
|
||||
GroupMetadata string `json:"group_metadata"`
|
||||
}
|
||||
}
|
||||
|
||||
func NewAppStatusFrom(exportApp *ExportAppStruct) *dbmodel.AppStatus {
|
||||
func BuildMQBodyFrom(app *ExportAppStruct) *MQBody {
|
||||
return &MQBody{
|
||||
EventID: app.Body.EventID,
|
||||
GroupKey: app.Body.GroupKey,
|
||||
Version: app.Body.Version,
|
||||
Format: app.Body.Format,
|
||||
SourceDir: app.SourceDir,
|
||||
}
|
||||
}
|
||||
|
||||
type MQBody struct {
|
||||
EventID string `json:"event_id"`
|
||||
GroupKey string `json:"group_key"`
|
||||
Version string `json:"version"`
|
||||
Format string `json:"format"` // only rainbond-app/docker-compose
|
||||
SourceDir string `json:"source_dir"`
|
||||
}
|
||||
|
||||
func NewAppStatusFrom(app *ExportAppStruct) *dbmodel.AppStatus {
|
||||
return &dbmodel.AppStatus{
|
||||
GroupKey: exportApp.Body.GroupKey,
|
||||
GroupName: exportApp.Body.GroupName, // TODO 以后可能会去掉
|
||||
Version: exportApp.Body.Version,
|
||||
Format: exportApp.Body.Format,
|
||||
EventID: exportApp.Body.EventID,
|
||||
SourceDir: exportApp.SourceDir,
|
||||
GroupKey: app.Body.GroupKey,
|
||||
Version: app.Body.Version,
|
||||
Format: app.Body.Format,
|
||||
EventID: app.Body.EventID,
|
||||
SourceDir: app.SourceDir,
|
||||
Status: "exporting",
|
||||
TarFile: exportApp.SourceDir + ".tar",
|
||||
TarFile: app.SourceDir + ".tar",
|
||||
TimeStamp: time.Now().Nanosecond(),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user