package application import ( "finclip-app-manager/domain/entity" "finclip-app-manager/infrastructure/utility" "github.com/gin-gonic/gin" "net/http" ) func RuntimeGetAppInfo(c *gin.Context) { //traceCtx := apm.ApmClient().TraceContextFromGin(c) appID := c.Param("path1") //appId if appID == "" { log.Infof("RuntimeGetAppInfo appId empty!!!") utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_LACK_OF_APPID, gin.H{}) return } //key := c.Request.Header.Get("SDK-Key") ////安全校验 //err := CheckSignatureAuth(traceCtx, key, c) //if err != nil { // log.Infof("RuntimeGetAppInfo CheckSignatureAuth err:%s", err.Error()) // MakeRsp(c, http.StatusBadRequest, err.Error(), rsp) // return //} //rs := service.NewRuntimeService() //resp, err := rs.GetAppInfo(traceCtx, key, appID, "") //if err != nil { // log.Errorf("GetGrayAppInfo get info from cache err:%s", err.Error()) // MakeRsp(c, http.StatusInternalServerError, FS_SYSTEM_CALL, rsp) // return //} //if resp == nil { // log.Warnf("GetGrayAppInfo app info is nil !!!") // if rs.AppNotFound() { // log.Errorf("GetGrayAppInfo get info app id Not Found,appId:%s", appID) // MakeRsp(c, http.StatusNotFound, FS_APP_ID_NOT_FOUND, rsp) // return // } // if !rs.AppStatusValid() { // log.Errorf("GetGrayAppInfo get info app status invalid,appId:%s", appID) // MakeRsp(c, http.StatusForbidden, FS_SERVICE_UNAVAILABLE, rsp) // return // } // if !rs.PayAppIdStatusOk() { // log.Errorf("GetGrayAppInfo get info app pay status invaild,appId:%s", appID) // MakeRsp(c, http.StatusForbidden, FS_APP_PAY_EXPIRE, rsp) // return // } // if !rs.OrganIsValid() { // log.Errorf("GetGrayAppInfo get info organ info invalid,appId:%s", appID) // MakeRsp(c, http.StatusForbidden, FS_COOPERATION_TERMINATED, rsp) // return // } // if rs.BindNotFound() { // log.Errorf("GetGrayAppInfo get info bind not found,sdkKey:%s,appId:%s", key, appID) // MakeRsp(c, http.StatusForbidden, FS_COOPERATION_TERMINATED, rsp) // return // } // if !rs.BindCoopValid() { // log.Errorf("GetGrayAppInfo get info bind coop status invalid,sdkKey:%s", key) // MakeRsp(c, http.StatusForbidden, FS_COOPERATION_TERMINATED, rsp) // return // } // if !rs.BindAssociateValid() { // log.Errorf("GetGrayAppInfo get info bind ass app invalid,sdkKey:%s,appId:%s", key, appID) // MakeRsp(c, http.StatusForbidden, FS_APP_NOT_ASS_BIND, rsp) // return // } // if !rs.PayBindIdStatusOk() { // log.Errorf("GetGrayAppInfo get info bind pay status invaild,appId:%s", appID) // MakeRsp(c, http.StatusForbidden, FS_BIND_PAY_EXPIRE, rsp) // return // } // if !rs.LicenseValid() { // log.Errorf("GetGrayAppInfo get info license invalid,sdkKey:%s,appId:%s", key, appID) // MakeRsp(c, http.StatusForbidden, FS_LICENSE_INVALID_ERR, rsp) // return // } // MakeRsp(c, http.StatusInternalServerError, FS_SYSTEM_CALL, rsp) // return //} //c.JSON(http.StatusOK, resp) return } type RuntimeGetAppVersionInfoRsp struct { AppID string `json:"appId"` Name string `json:"name"` Sequence int `json:"sequence"` AppClass string `json:"appClass"` AppType string `json:"appType"` Status entity.Status `json:"status"` PublishedStatus entity.SpecificStatus `json:"publishedStatus"` ActionStatus entity.SpecificStatus `json:"actionStatus"` DeveloperID string `json:"developerId"` GroupID string `json:"groupId"` GroupName string `json:"groupName"` Created int64 `json:"created"` CreatedBy string `json:"createdBy"` //CustomData proto.AppRspCustomData `json:"customData"` Version string `json:"version"` CorporationID string `json:"corporationId"` CoreDescription string `json:"coreDescription"` Logo string `json:"logo"` Platform []string `json:"platform"` MarketID string `json:"marketId"` FcID string `json:"fcId"` } func RuntimeGetAppVersionInfo(c *gin.Context) { //traceCtx := apm.ApmClient().TraceContextFromGin(c) appID := c.Param("path1") seqStr := c.Param("path3") log.Infof("RuntimeGetAppVersionInfo appId:%s,sequence:%s", appID, seqStr) if appID == "" { log.Errorf("RuntimeGetAppVersionInfo appID empty!!!") utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_LACK_OF_APPID, gin.H{}) return } //sequence, err := strconv.Atoi(seqStr) //if err != nil { // log.Errorf("RuntimeGetAppVersionInfo seueence format err:%s,seqstr:%s", err.Error(), seqStr) // utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_BAD_JSON, gin.H{}) // return //} //t := db.NewTable(db.TableAppVersion) //appVerInfo := model.AppVersion{} //if err := t.GetOne(traceCtx, bson.M{"appId": appID, "sequence": sequence}, &appVerInfo); err != nil { // log.Errorf("RuntimeGetAppVersionInfo get appVer err:%s", err.Error()) // MakeRsp(c, http.StatusInternalServerError, FS_DB_ERR, rsp) // return //} //if t.NotFound() { // log.Error("RuntimeGetAppVersionInfo get appVer not found!") // MakeRsp(c, http.StatusNotFound, FS_APP_SEQUENCE_NOT_FOUND, rsp) // return //} // //key := c.Request.Header.Get("SDK-Key") ////白名单 //if !InArry(key, config.WhiteSDKArry) { // log.Errorf("RuntimeGetAppVersionInfo sdk not in white sdk arry,sdk-key:%s", key) // MakeRsp(c, http.StatusForbidden, FS_COOPERATION_TERMINATED, rsp) // return //} ////安全校验 //err = CheckSignatureAuth(traceCtx, key, c) //if err != nil { // log.Error("RuntimeGetAppVersionInfo CheckSignatureAuth err:%s", err.Error()) // MakeRsp(c, http.StatusBadRequest, err.Error(), rsp) // return //} ////校验企业的状态 //log.Infof("get group info id:%s", appVerInfo.GroupID) //groupInfo, err := provider.GetGroupInfoByGroupId(traceCtx, appVerInfo.GroupID) //if err != nil { // log.Errorf("RuntimeGetAppVersionInfo GetGroupInfoByGroupId err:%s", err.Error()) // MakeRsp(c, http.StatusBadRequest, FS_GET_GROUP_FAILED, rsp) // return //} //log.Infof("RuntimeGetAppVersionInfo get group info:%+v", groupInfo) ////如果是私有化版本,白名单不需要校验 //if config.Cfg.PublishEnv != ENV_PRIVATE { // if groupInfo.ReviewStatus != client.StOrganApproved && // groupInfo.ReviewStatus != client.StOrganPersonalReviewing && // groupInfo.ReviewStatus != client.StOrganPersonalUnPass { // log.Errorf("RuntimeGetAppVersionInfo organ status:%v", groupInfo.ReviewStatus) // MakeRsp(c, http.StatusForbidden, FS_COOPERATION_TERMINATED, rsp) // return // } //} ////appVerInfo.CustomData["appRuntimeDomain"] = data //rspInfo := RuntimeGetAppVersionInfoRsp{ // AppID: appVerInfo.AppID, // Name: appVerInfo.Name, // Sequence: appVerInfo.Sequence, // AppClass: appVerInfo.AppClass, // AppType: appVerInfo.AppType, // Status: appVerInfo.Status, // PublishedStatus: appVerInfo.PublishedStatus, // //UnpublishedStatus: appVerInfo.UnpublishedStatus, // ActionStatus: appVerInfo.ActionStatus, // DeveloperID: appVerInfo.DeveloperID, // GroupID: appVerInfo.GroupID, // GroupName: groupInfo.GroupName, //实时获取 todo 加个缓存 // Created: appVerInfo.Created, // CreatedBy: appVerInfo.CreatedBy, // //CustomData: appVerInfo.CustomData, // Version: appVerInfo.Version, // CorporationID: appVerInfo.CorporationID, // CoreDescription: appVerInfo.CoreDescription, // Logo: appVerInfo.Logo, // Platform: appVerInfo.Platform, // MarketID: appVerInfo.MarketID, // FcID: appVerInfo.FcID, //} //err, errCode, customData := service.ConvertModelCustomDataToRpc(traceCtx, service.NewRuntimeService(), appVerInfo.GroupID, appVerInfo.CustomData, nil, "") //rspInfo.CustomData = *customData //if err != nil { // log.Errorf("RuntimeGetAppVersionInfo ConvertModelCustomDataToPb err:%s", err.Error()) // MakeRsp(c, http.StatusInternalServerError, errCode, rsp) // return //} //c.JSON(http.StatusOK, rspInfo) //return }