This commit is contained in:
Liang Ding 2022-07-05 22:03:06 +08:00
parent 4388d8dee7
commit 3e5e0376a3
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
5 changed files with 92 additions and 6 deletions

View file

@ -43,6 +43,42 @@ func checkoutRepo(c *gin.Context) {
}
}
func downloadCloudSnapshot(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
id := arg["id"].(string)
tag := arg["tag"].(string)
if err := model.DownloadCloudSnapshot(tag, id); nil != err {
ret.Code = -1
ret.Msg = err.Error()
return
}
}
func uploadCloudSnapshot(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
id := arg["id"].(string)
tag := arg["tag"].(string)
if err := model.UploadCloudSnapshot(tag, id); nil != err {
ret.Code = -1
ret.Msg = err.Error()
return
}
}
func getRepoSnapshots(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)

View file

@ -260,6 +260,8 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/repo/getRepoSnapshots", model.CheckAuth, getRepoSnapshots)
ginServer.Handle("POST", "/api/repo/getRepoTagSnapshots", model.CheckAuth, getRepoTagSnapshots)
ginServer.Handle("POST", "/api/repo/getCloudRepoTagSnapshots", model.CheckAuth, getCloudRepoTagSnapshots)
ginServer.Handle("POST", "/api/repo/uploadCloudSnapshot", model.CheckAuth, uploadCloudSnapshot)
ginServer.Handle("POST", "/api/repo/downloadCloudSnapshot", model.CheckAuth, downloadCloudSnapshot)
ginServer.Handle("POST", "/api/notification/pushMsg", model.CheckAuth, pushMsg)
ginServer.Handle("POST", "/api/notification/pushErrMsg", model.CheckAuth, pushErrMsg)