From 9d88c7c467f8d93af4aab9ba0b6d6c01c2ffc546 Mon Sep 17 00:00:00 2001 From: sunty <1172534965@qq.com> Date: 星期四, 20 八月 2020 20:35:30 +0800 Subject: [PATCH] add get buckets contrl --- controllers/sdk.go | 84 +++++++++++++++++++++++++++++++++-------- 1 files changed, 67 insertions(+), 17 deletions(-) diff --git a/controllers/sdk.go b/controllers/sdk.go index 479c16c..76e1570 100644 --- a/controllers/sdk.go +++ b/controllers/sdk.go @@ -75,14 +75,16 @@ // @Produce json // @Tags 绠楁硶 // @Param sdkName query string false "鍙�夊弬鏁�" +// @Param installed query bool true "鏌ュ凡瀹夎鎴栬�呮煡鎵�鏈�" // @Success 200 {string} json "{"code":200, msg:"璇锋眰澶勭悊鎴愬姛",data:"绠楁硶鍒楄〃",success:true}" // @Failure 500 {string} json "{"code":500, msg:"璇锋眰澶辫触",data:"[]",success:false}" // @Router /data/api-v/sdk/findAllSdk [GET] func (sc SdkController) FindAllSdk(c *gin.Context) { sdkName := c.Query("sdkName") + installed, _ := strconv.ParseBool(c.Query("installed")) logger.Debug("FindAllSdk sdkName:", sdkName) - sdks := service.GetSdkList("") //鏈満宸插畨瑁呯殑绠楁硶 + sdks := service.GetSdkList("", installed) //鏈満宸插畨瑁呯殑绠楁硶 util.ResponseFormat(c, code.Success, sdks) } @@ -257,20 +259,66 @@ Header: header, } var sv service.SysService - if b,isComplete := sv.PatchUpload(&arg); b { - if isComplete { //涓婁紶瀹屾瘯闇�瑕佽嚜鍔ㄨЕ鍙戝畨瑁� - var sv service.SdkInstallService - if b,err := sv.SdkInstall(identifier, filename);b { - util.ResponseFormat(c,&code.Code{http.StatusOK, true, "绠楁硶瀹夎鎴愬姛"},"绠楁硶瀹夎鎴愬姛") - return - } else { - util.ResponseFormat(c,&code.Code{http.StatusBadRequest, false, "绠楁硶瀹夎澶辫触"},err.Error()) - return - } - } - util.ResponseFormat(c, code.Success, "") + if b,_ := sv.PatchUpload(&arg); b { + //if isComplete { //涓婁紶瀹屾瘯闇�瑕佽嚜鍔ㄨЕ鍙戝畨瑁� + // var sv service.SdkInstallService + // if b,err := sv.SdkInstall(identifier, filename);b { + // util.ResponseFormat(c,&code.Code{http.StatusOK, true, "绠楁硶瀹夎鎴愬姛"},"绠楁硶瀹夎鎴愬姛") + // return + // } else { + // util.ResponseFormat(c,&code.Code{http.StatusBadRequest, false, "绠楁硶瀹夎澶辫触"},err.Error()) + // return + // } + //} + util.ResponseFormat(c, code.Success, "涓婁紶瀹屾垚") } else { util.ResponseFormat(c, code.ComError, "") + } +} + +// @Security ApiKeyAuth +// @Summary 涓婁紶瀹屾垚鑾峰彇瀹夎淇℃伅 +// @Description 涓婁紶瀹屾垚鑾峰彇瀹夎淇℃伅 +// @Produce json +// @Tags 绠楁硶 +// @Param identifier formData string true "鏁翠釜鏂囦欢鐨勫敮涓�鏍囪瘑锛岀洰鍓嶆槸md5" +// @Param filename formData string true "鏂囦欢鍚嶇О" +// @Success 200 {string} json "{"code":200, msg:"", success:true}" +// @Failure 500 {string} json "{"code":500, msg:"", success:false}" +// @Router /data/api-v/sdk/showInstallInfo [post] +func (sc SdkController) ShowInstallInfo(c *gin.Context) { + identifier := c.Request.FormValue("identifier") + filename := c.Request.FormValue("filename") + var sv service.SdkInstallService + b,d, err := sv.ShowInstallInfo(identifier, filename) + if b { + util.ResponseFormat(c,code.Success, d) + } else { + util.ResponseFormat(c,&code.Code{http.StatusInternalServerError, false, err.Error()}, err.Error()) + } +} + +// @Security ApiKeyAuth +// @Summary 涓婁紶瀹屾垚寮�濮嬪畨瑁� +// @Description 涓婁紶瀹屾垚寮�濮嬪畨瑁� +// @Produce json +// @Tags 绠楁硶 +// @Param identifier formData string true "鏁翠釜鏂囦欢鐨勫敮涓�鏍囪瘑锛岀洰鍓嶆槸md5" +// @Param filename formData string true "鏂囦欢鍚嶇О" +// @Success 200 {string} json "{"code":200, msg:"", success:true}" +// @Failure 500 {string} json "{"code":500, msg:"", success:false}" +// @Router /data/api-v/sdk/install [post] +func (sc SdkController) Install(c *gin.Context) { + identifier := c.Request.FormValue("identifier") + filename := c.Request.FormValue("filename") + + var sv service.SdkInstallService + if b,err := sv.SdkInstall(identifier, filename);b { + util.ResponseFormat(c,&code.Code{http.StatusOK, true, "绠楁硶瀹夎鎴愬姛"},"绠楁硶瀹夎鎴愬姛") + return + } else { + util.ResponseFormat(c,&code.Code{http.StatusBadRequest, false, err.Error()},err.Error()) + return } } @@ -303,19 +351,21 @@ // @Produce json // @Tags 绠楁硶 // @Param code query string true "婵�娲荤爜" +// @Param sdkId query string true "绠楁硶id" // @Success 200 {string} json "{"code":200, msg:"", success:true}" // @Failure 500 {string} json "{"code":500, msg:"", success:false}" // @Router /data/api-v/sdk/active [get] func (sc SdkController) Active(c *gin.Context) { cod := c.GetString("code") - if cod == "" { - util.ResponseFormat(c, code.RequestParamError, "婵�娲荤爜涓嶈兘涓虹┖") + sdkId := c.GetString("sdkId") + if cod == "" || sdkId == "" { + util.ResponseFormat(c, code.RequestParamError, "婵�娲荤爜鍜岀畻娉昳d涓嶈兘涓虹┖") return } var sv service.SdkInstallService - err := sv.Active(cod) + d, err := sv.Active(cod, sdkId) if err == nil { - util.ResponseFormat(c,code.Success, "婵�娲绘垚鍔�") + util.ResponseFormat(c,code.Success, d) } else { util.ResponseFormat(c,code.ComError, err.Error()) } -- Gitblit v1.8.0