From be9f911a2d4b152a2ba6173e5960739b6361930d Mon Sep 17 00:00:00 2001 From: Esben von Buchwald Date: Wed, 22 May 2024 15:11:50 +0200 Subject: [PATCH] Add optional description for packages --- code-push.sql | 4 ++++ model/package.go | 1 + request/app.go | 2 ++ request/client.go | 4 +++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/code-push.sql b/code-push.sql index def1f16..645eee5 100644 --- a/code-push.sql +++ b/code-push.sql @@ -111,6 +111,7 @@ CREATE TABLE `package` ( `deployment_id` int DEFAULT NULL, `size` bigint DEFAULT NULL, `hash` varchar(256) DEFAULT NULL, + `description` TEXT DEFAULT NULL, `download` varchar(256) DEFAULT NULL, `active` int DEFAULT '0', `failed` int DEFAULT '0', @@ -120,6 +121,9 @@ CREATE TABLE `package` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; +-- `description` is not part of v1.0.1, it can be added by +-- ALTER TABLE `package` ADD `description` TEXT DEFAULT NULL; + -- -- Dumping data for table `package` -- diff --git a/model/package.go b/model/package.go index 65fec7f..c75ce0a 100644 --- a/model/package.go +++ b/model/package.go @@ -10,6 +10,7 @@ type Package struct { Failed *int `json:"failed"` Installed *int `json:"installed"` CreateTime *int64 `json:"create_time"` + Description *string `json:"description"` } func (Package) TableName() string { diff --git a/request/app.go b/request/app.go index bbebf8d..74f6ed8 100644 --- a/request/app.go +++ b/request/app.go @@ -60,6 +60,7 @@ type createBundleReq struct { AppName *string `json:"appName" binding:"required"` Deployment *string `json:"deployment" binding:"required"` DownloadUrl *string `json:"downloadUrl" binding:"required"` + Description *string `json:"description" binding:"required"` Version *string `json:"version" binding:"required"` Size *int64 `json:"size" binding:"required"` Hash *string `json:"hash" binding:"required"` @@ -114,6 +115,7 @@ func (App) CreateBundle(ctx *gin.Context) { Size: createBundleReq.Size, Hash: createBundleReq.Hash, Download: createBundleReq.DownloadUrl, + Description: createBundleReq.Description, Active: utils.CreateInt(0), Installed: utils.CreateInt(0), Failed: utils.CreateInt(0), diff --git a/request/client.go b/request/client.go index 872cf85..5418df1 100644 --- a/request/client.go +++ b/request/client.go @@ -16,7 +16,7 @@ import ( type Client struct{} type updateInfo struct { DownloadUrl string `json:"download_url"` - // Description string `json:"description"` + Description string `json:"description"` IsAvailable bool `json:"is_available"` IsDisabled bool `json:"is_disabled"` TargetBinaryRange string `json:"target_binary_range"` @@ -62,6 +62,7 @@ func (Client) CheckUpdate(ctx *gin.Context) { label := strconv.Itoa(*packag.Id) updateInfoRedis.Label = label updateInfoRedis.DownloadUrl = config.ResourceUrl + *packag.Download + updateInfoRedis.Description = *packag.Description } } deploymentVersionNew := model.DeploymentVersion{}.GetNewVersionByKeyDeploymentId(*deployment.Id) @@ -79,6 +80,7 @@ func (Client) CheckUpdate(ctx *gin.Context) { updateInfo.IsMandatory = true updateInfo.Label = updateInfoRedis.Label updateInfo.DownloadUrl = updateInfoRedis.DownloadUrl + updateInfo.Description = updateInfoRedis.Description } else if updateInfoRedis.NewVersion != "" && appVersion != updateInfoRedis.NewVersion && utils.FormatVersionStr(appVersion) < utils.FormatVersionStr(updateInfoRedis.NewVersion) { updateInfo.TargetBinaryRange = updateInfoRedis.NewVersion updateInfo.UpdateAppVersion = true