package application import ( "finclip-app-manager/domain/entity" "finclip-app-manager/domain/entity/proto/apiproto" "finclip-app-manager/domain/repository" "finclip-app-manager/domain/service" "finclip-app-manager/infrastructure/config" "finclip-app-manager/infrastructure/utility" "net/http" "strconv" "github.com/gin-gonic/gin" "gitlab.finogeeks.club/finclip-backend/apm" ) /** * @api {POST} {{URL_PREFIX}}/apps/builds [C/S][MOP]获取当前app的可审核版本 * @apiGroup Finclip App Manager * @apiVersion __API_VERSION__ * @apiPrivate * * @apiParam (RequestBody) {string} [developerId] 开发者id,URL_PREFIX为/api/v1/finstore时填写 * @apiParam (RequestBody) {string} appId 应用id * @apiParam (RequestBody) {bool=true,false} needAutoPub=false 审核通过是否自动上架 * @apiSuccessExample {json} Success-Response: {} */ type GetAppBuildsReq struct { AppId string `form:"appId"` PageSize int `form:"pageSize"` PageNo int `form:"pageNo"` } type GetAppBuildsRspItem struct { Id string `json:"id" bson:"id"` BuildInfoId string `json:"buildInfoId" bson:"buildInfoId"` Source string `json:"source" bson:"source"` // 该上传版本的状态: build:正常版本, trail:被设置为体验版 AppID string `json:"appId" bson:"appId"` GroupID string `json:"groupId" bson:"groupId"` Created int64 `json:"created" bson:"created"` //创建该编译版本的时间 UserId string `json:"userId" bson:"userId"` CreatedBy string `json:"createdBy" bson:"createdBy"` //创建人 CustomData entity.CustomDataInfo `json:"customData" bson:"customData"` Version string `json:"version" bson:"version"` StartParams entity.AppStartParams `json:"startParams" bson:"startParams"` Status bool `json:"status" bson:"status"` IsSecurityAuditPass int `json:"isSecurityAuditPass" bson:"isSecurityAuditPass"` //安全审核是否通过(0,未通过 1:通过) } /** * @api {GET} /api/v1/mop/finstore/dev/appInfo/builds?appId=62986ead277a0d00017b782f [C/S]获取编译开发列表 * @apiGroup Finclip App Manager * @apiParam (RequestParam) {string} appId //小程序id * @apiSuccessExample {json} Success Status: * HTTP/1.1 200 OK * { * "data": { * "appBuilds": [ * { * "id": "62986ead277a0d00017b782f", * "buildInfoId": "ac8f47cf-65a9-43d8-b2ac-34fba808707a", * "source": "build", * "appId": "62986e87277a0d00017b782e", * "groupId": "628b2215062d300001e36286", * "created": 1654156973289, * "userId": "628b2215062d300001e36285", * "createdBy": "15377373355", * "customData": { * "detailDescription": "", * "sourceFile": [ * { * "fileMd5": "159eed6c06432b1a4f68ced6c19a1bfe", * "name": "app.zip", * "sourceFileUrl": "/api/v1/mop/netdisk/download/62986eaa1f1afd0001c3698c", * "uploadDate": 1654156973289, * "url": "/api/v1/mop/netdisk/download/62986ead1f1afd0001c3698d", * "encryptedUrl": "/api/v1/mop/netdisk/download/62986ead1f1afd0001c3698e", * "encryptedFileMd5": "fad7bd98dbcabb560ca30f4c99121a42", * "encryptedFileSha256": "c9e9db06725f95a4418c83d54dda3499946b8e1c894583b6477a36cc1d796668", * "basicPackVer": "", * "Packages": [], * "EncryptPackages": [] * } * ], * "versionDescription": "1.0.0", * "developer": "15377373355" * }, * "version": "1.0.0", * "startParams": { * "pathAndQuery": "" * }, * "status": true * } * ], * "total": 1 * }, * "errcode": "OK", * "error": "" * } * @apiErrorExample Error Status: * HTTP/1.1 !=200 服务端异常 */ func GetAppBuilds(c *gin.Context) { traceCtx := apm.ApmClient().TraceContextFromGin(c) req := GetAppBuildsReq{} if err := c.BindQuery(&req); err != nil { log.Errorf("GetAppBuilds bind err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_BAD_JSON, gin.H{}) return } pageNo := c.DefaultQuery("pageNo", "0") pageSize := c.DefaultQuery("pageSize", "20") //config.GetConfig().CodePackageNumLimit pageNoInt, _ := strconv.Atoi(pageNo) pageNoInt += 1 pageSizeInt, _ := strconv.Atoi(pageSize) appId := c.Query("appId") userId := utility.GetUserId(c) log.Infof("GetAppBuilds req:%+v,pageNo:%d,pageSize:%d,userId:%s", req, pageNoInt, pageSizeInt, userId) svr := service.NewAppAppletInfoService() appBuilds, total, err := svr.GetAppBuilds(traceCtx, userId, appId, pageSizeInt, pageNoInt) if err != nil { log.Errorf("GetAppBuilds err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusInternalServerError, utility.FS_SYSTEM_CALL, gin.H{}) return } log.Debugf("appBuilds:%+v", appBuilds) res := make([]GetAppBuildsRspItem, 0) for _, v := range appBuilds { item := GetAppBuildsRspItem{ Id: v.Id, BuildInfoId: v.BuildInfoId, Source: v.Source, AppID: v.AppID, GroupID: v.GroupID, Created: v.Created, UserId: v.UserId, CreatedBy: v.CreatedBy, CustomData: entity.CustomDataInfo{ VersionDescription: v.CustomData.VersionDescription, SourceFile: v.CustomData.SourceFile, Developer: v.CustomData.Developer, }, Version: v.Version, StartParams: entity.AppStartParams{}, Status: v.Status, } if config.GetConfig().IsOpenAuditSecurity { auditInfo, err := hCaller.GetAuditDataInfoByBuildInfoId(traceCtx, v.BuildInfoId) log.Debugln("GetAuditDataInfoByBuildInfoId:%v", utility.InterfaceToJsonString(auditInfo)) if err != nil { log.Errorf("GetAuditDataInfoByBuildInfoId err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusInternalServerError, utility.FS_SYSTEM_CALL, gin.H{}) return } item.IsSecurityAuditPass = 0 //0无,1审核中,2通过,3不通过 if auditInfo.Data.Status == 2 { item.IsSecurityAuditPass = 1 } //0:无 1:审批通过 if auditInfo.Data.OperOpinion == 1 { item.IsSecurityAuditPass = 1 } } else { item.IsSecurityAuditPass = 1 } res = append(res, item) } utility.MakeLocRsp(c, http.StatusOK, utility.OK, gin.H{"appBuilds": res, "total": total}) } type WechatInfoRsp struct { WechatAppSecret string `json:"wechatAppSecret" bson:"wechatAppSecret"` WechatAppId string `json:"wechatAppId" bson:"wechatAppId"` WechatPath string `json:"wechatPath" bson:"wechatPath"` WechatSize string `json:"wechatSize" bson:"wechatSize"` QrcodeUrl string `json:"qrcodeUrl" bson:"qrcodeUrl"` QrcodeDownloadUrl string `json:"qrcodeDownloadUrl" bson:"qrcodeDownloadUrl"` Updated int64 `json:"updated" bson:"updated"` ShowHint bool `json:"showHint" bson:"-"` // 是否展示提示 } type GetLatestAppInfoRsp struct { OnlineAppInfo interface{} `json:"onlineAppInfo"` //线上小程序详情 ReviewVersion interface{} `json:"reviewVersion"` //最新审核版本信息 TrialVersion interface{} `json:"trialVersion"` //最新体验版本信息 ExtInfo map[string]interface{} `json:"extInfo"` //额外数据 extInfo: {trialQrcodeHasRead: true} WechatInfo interface{} `json:"wechatInfo"` WechatLoginInfo interface{} `json:"wechatLoginInfo"` } /** * @api {GET} /api/v1/mop/finstore/dev/appInfo/latest?appId=62986ead277a0d00017b782f [C/S]获取最新线上版、最新审核版本、最新体验版 * @apiGroup Finclip App Manager * @apiParam (RequestParam) {string} appId //小程序id * @apiSuccessExample {json} Success Status: * HTTP/1.1 200 OK { "data": { "onlineAppInfo": { "appId": "62986e87277a0d00017b782e", "name": "1", "appClass": "jinrong", "appTag": [ "zhengquankaihu" ], "appType": "Applet", "status": { "value": "Published", "reason": "", "lastUpdated": 1654157465456, "modifiedBy": "自动上架" }, "publishingStatus": { "reason": "", "lastUpdated": 1654156994088, "modifiedBy": "15377373355" }, "unpublishingStatus": { "reason": "", "lastUpdated": 0, "modifiedBy": "" }, "publishingApprovalStatus": { "reason": "", "lastUpdated": 1654157465436, "modifiedBy": "15377373355" }, "unpublishingApprovalStatus": { "reason": "", "lastUpdated": 0, "modifiedBy": "" }, "publishedStatus": { "reason": "", "lastUpdated": 1654157465456, "modifiedBy": "自动上架" }, "unpublishedStatus": { "reason": "", "lastUpdated": 0, "modifiedBy": "", "type": "" }, "requestStatus": { "reason": "", "lastUpdated": 0, "modifiedBy": "" }, "approvalStatus": { "reason": "", "lastUpdated": 1654157465436, "modifiedBy": "15377373355" }, "actionStatus": { "reason": "", "lastUpdated": 1654157465456, "modifiedBy": "自动上架" }, "developerId": "628b2215062d300001e36285", "groupId": "628b2215062d300001e36286", "created": 1654156994088, "createdBy": "15377373355", "customData": { "detailDescription": "", "sourceFile": [ { "fileMd5": "159eed6c06432b1a4f68ced6c19a1bfe", "name": "app.zip", "sourceFileUrl": "/api/v1/mop/netdisk/download/62986eaa1f1afd0001c3698c", "uploadDate": 1654156973289, "url": "/api/v1/mop/netdisk/download/62986ead1f1afd0001c3698d", "encryptedUrl": "/api/v1/mop/netdisk/download/62986ead1f1afd0001c3698e", "encryptedFileMd5": "fad7bd98dbcabb560ca30f4c99121a42", "encryptedFileSha256": "c9e9db06725f95a4418c83d54dda3499946b8e1c894583b6477a36cc1d796668", "basicPackVer": "", "Packages": [], "EncryptPackages": [] } ], "versionDescription": "1.0.0", "developer": "15377373355" }, "version": "1.0.0", "sequence": 1, "corporationId": "", "coreDescription": "123", "logo": "https://www-cdn.finclip.com/images/ic-default.png", "isRollback": false, "testInfo": { "account": "", "password": "", "description": "", "images": [] }, "needAutoPub": true, "inGrayRelease": false, "expire": 0, "appBuildID": "62986ead277a0d00017b782f" }, "reviewVersion": { "appId": "62986e87277a0d00017b782e", "name": "1", "appClass": "jinrong", "appTag": [ "zhengquankaihu" ], "appType": "Applet", "status": { "value": "PublishApproved", "reason": "", "lastUpdated": 1654165268630, "modifiedBy": "15377373355" }, "publishingStatus": { "reason": "", "lastUpdated": 1654165260773, "modifiedBy": "15377373355" }, "unpublishingStatus": { "reason": "", "lastUpdated": 0, "modifiedBy": "" }, "publishingApprovalStatus": { "reason": "", "lastUpdated": 1654165268630, "modifiedBy": "15377373355" }, "unpublishingApprovalStatus": { "reason": "", "lastUpdated": 0, "modifiedBy": "" }, "publishedStatus": { "reason": "", "lastUpdated": 0, "modifiedBy": "" }, "unpublishedStatus": { "reason": "", "lastUpdated": 0, "modifiedBy": "", "type": "" }, "requestStatus": { "reason": "", "lastUpdated": 0, "modifiedBy": "" }, "approvalStatus": { "reason": "", "lastUpdated": 1654165268630, "modifiedBy": "15377373355" }, "actionStatus": { "reason": "", "lastUpdated": 1654165260773, "modifiedBy": "15377373355" }, "developerId": "628b2215062d300001e36285", "groupId": "628b2215062d300001e36286", "created": 1654165260773, "createdBy": "15377373355", "customData": { "detailDescription": "", "sourceFile": [ { "fileMd5": "159eed6c06432b1a4f68ced6c19a1bfe", "name": "app.zip", "sourceFileUrl": "/api/v1/mop/netdisk/download/62986eaa1f1afd0001c3698c", "uploadDate": 1654156973289, "url": "/api/v1/mop/netdisk/download/62986ead1f1afd0001c3698d", "encryptedUrl": "/api/v1/mop/netdisk/download/62986ead1f1afd0001c3698e", "encryptedFileMd5": "fad7bd98dbcabb560ca30f4c99121a42", "encryptedFileSha256": "c9e9db06725f95a4418c83d54dda3499946b8e1c894583b6477a36cc1d796668", "basicPackVer": "", "Packages": [], "EncryptPackages": [] } ], "versionDescription": "1.0.0", "developer": "15377373355" }, "version": "1.0.0", "sequence": 9, "corporationId": "", "coreDescription": "123", "logo": "https://www-cdn.finclip.com/images/ic-default.png", "isRollback": false, "testInfo": { "account": "", "password": "", "description": "", "images": [] }, "needAutoPub": false, "inGrayRelease": false, "expire": 0, "appBuildID": "62986ead277a0d00017b782f" }, "trialVersion": {}, "extInfo": { "trialQrcodeHasRead": true }, "wechatInfo": { "wechatAppSecret": "", "wechatAppId": "", "wechatPath": "", "wechatSize": "", "qrcodeUrl": "", "qrcodeDownloadUrl": "", "updated": 1654157465456, "showHint": false }, "wechatLoginInfo": { "wechatOriginId": "", "profileUrl": "", "phoneUrl": "" } }, "errcode": "OK", "error": "" } * @apiErrorExample Error Status: * HTTP/1.1 !=200 服务端异常 */ //GetLatestAppInfo 获取最新线上版、最新审核版本、最新体验版 func GetLatestAppInfo(c *gin.Context) { traceCtx := apm.ApmClient().TraceContextFromGin(c) appID := c.Query("appId") if appID == "" { log.Errorf("GetLatestAppInfo appid empty!") utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_LACK_OF_APPID, gin.H{}) return } svr := service.NewAppService() buildInfoSvr := service.NewAppAppletInfoService() developerID := c.Request.Header.Get("X-Consumer-Custom-ID") groupInfo, _ := hCaller.GetGroupInfoByUserId(traceCtx, developerID) app, err := svr.GetAppInfo(traceCtx, appID) if repository.NotFound(err) { utility.MakeLocRsp(c, http.StatusNotFound, utility.FS_APP_ID_NOT_FOUND, gin.H{}) return } else if groupInfo.GroupID != app.GroupID { utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_APPID_ORGANID_ERR, gin.H{}) return } var developer string if app.CustomData.Developer != "" { developer = app.CustomData.Developer } else { developer = app.CreatedBy app.CustomData.Developer = developer } rspData := GetLatestAppInfoRsp{ OnlineAppInfo: gin.H{}, ReviewVersion: gin.H{}, TrialVersion: gin.H{}, ExtInfo: gin.H{}, } latestPubVer, err := svr.GetLatestPubAppVer(traceCtx, appID) if err != nil { if !repository.NotFound(err) { log.Errorf("GetLatestAppInfo GetLatestPubAppVer err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusInternalServerError, utility.FS_DB_ERR, gin.H{}) return } } else { rspData.OnlineAppInfo = latestPubVer } reviewVersion, err := svr.GetLatestReviewAppVer(traceCtx, appID) if err != nil { if !repository.NotFound(err) { log.Errorf("GetLatestAppInfo GetLatestReviewAppVer err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusInternalServerError, utility.FS_DB_ERR, gin.H{}) return } } else { //且没有上、下架的版本 if reviewVersion.Status.Value != entity.StPublished && reviewVersion.Status.Value != entity.StUnpublished { rspData.ReviewVersion = reviewVersion } } trialInfo, err := buildInfoSvr.DevGetTrialInfo(traceCtx, appID) if err != nil { log.Debugln("GetTrailInfoByAppId err:%s", err.Error()) if repository.NotFound(err) { log.Debugln("GetLatestAppInfo DevGetTrialInfo err:%s", err.Error()) //utility.MakeLocRsp(c, http.StatusInternalServerError, utility.FS_DB_ERR, gin.H{}) rspData.TrialVersion = gin.H{} } else { utility.MakeLocRsp(c, http.StatusInternalServerError, utility.FS_DB_ERR, gin.H{}) return } } else { if trialInfo.CustomData.Developer == "" { trialInfo.CustomData.Developer = developer } rspData.TrialVersion = trialInfo trialAppQrRedDotHasRead, err := hCaller.IsTrialHasRead(traceCtx, trialInfo.Id, developerID) if err != nil { log.Errorf("GetLatestAppInfo IsTrialHasRead err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusInternalServerError, utility.FS_DB_ERR, gin.H{}) return } log.Debugln("trialQrcodeHasRead :%s", trialAppQrRedDotHasRead) rspData.ExtInfo["trialQrcodeHasRead"] = trialAppQrRedDotHasRead } if trialInfo != nil { rspData.TrialVersion = trialInfo } //extInfo := make(map[string]interface{}) rspData.ExtInfo["trialQrcodeHasRead"] = true if trialInfo != nil { hasRead, _ := hCaller.IsTrialHasRead(traceCtx, trialInfo.Id, utility.GetUserId(c)) log.Debugln("trialQrcodeHasRead :%s", hasRead) rspData.ExtInfo["trialQrcodeHasRead"] = hasRead } //rspData.ExtInfo = extInfo wechatInfoRsp := WechatInfoRsp{} wechatInfo, err := hCaller.GetWeChatInfo(traceCtx, appID) if err == nil { wechatInfoRsp.Updated = wechatInfo.Updated wechatInfoRsp.QrcodeDownloadUrl = wechatInfo.QrcodeDownloadUrl wechatInfoRsp.QrcodeUrl = wechatInfo.QrcodeUrl wechatInfoRsp.WechatPath = wechatInfo.WechatPath wechatInfoRsp.WechatAppId = wechatInfo.WechatAppId wechatInfoRsp.WechatAppSecret = wechatInfo.WechatAppSecret wechatInfoRsp.WechatSize = wechatInfo.WechatSize if wechatInfo.Updated == 0 { wechatInfoRsp.Updated = app.PublishedStatus.LastUpdated } isShowHint, _ := hCaller.IsShowHint(traceCtx, appID, developerID) wechatInfoRsp.ShowHint = isShowHint rspData.WechatInfo = wechatInfoRsp } else { log.Errorf("GetWeChatInfo err:%s", err.Error()) } wechatLoginInfo, err := hCaller.GetWeChatLoginInfo(traceCtx, appID) if err != nil { log.Errorf("GetWeChatInfo err:%s", err.Error()) } else { rspData.WechatLoginInfo = wechatLoginInfo } utility.MakeLocRsp(c, http.StatusOK, utility.OK, rspData) } func GetAppAdminAccount(c *gin.Context) { traceCtx := apm.ApmClient().TraceContextFromGin(c) appID := c.Param("appId") svr := service.NewAppService() app, err := svr.GetAppInfo(traceCtx, appID) if err != nil { if repository.NotFound(err) { utility.MakeLocRsp(c, http.StatusNotFound, utility.FS_APP_ID_NOT_FOUND, gin.H{}) } else { utility.MakeLocRsp(c, http.StatusInternalServerError, utility.FS_DB_ERR, gin.H{}) } return } groupInfo, err := hCaller.GetGroupInfoByGroupId(traceCtx, app.GroupID) if err != nil { utility.MakeLocRsp(c, http.StatusInternalServerError, utility.FS_SYSTEM_CALL, gin.H{}) } else { utility.MakeLocRsp(c, http.StatusOK, utility.OK, gin.H{"adminAccountId": groupInfo.AdminAccountId, "groupId": groupInfo.GroupID}) } } type UpdateTrailAppReq struct { Id string `json:"id"` AppId string `json:"appId"` Type string `json:"type"` } /** * @api {POST} /api/v1/mop/finstore/dev/trial/operate [C/S]添加体验版小程序 * @apiGroup Finclip App Manager * @apiParam (RequestBody) {string} id //编译id * @apiParam (RequestBody) {string} appId //小程序id * @apiParam (RequestBody) {string} type //add:添加,cancel:取消 * @apiParamExample {json} Request-Example: * { * "id":"61b32654659d2b00016264a9", * "appId":"61b32654659d2b00016264a8", * "type": "add" * } * @apiSuccessExample {json} Success Status: * HTTP/1.1 200 OK * { * "data": {}, * "errcode": "OK", * "error": "" * } * @apiErrorExample Error Status: * HTTP/1.1 !=200 服务端异常 */ func UpdateTrialApp(c *gin.Context) { traceCtx := apm.ApmClient().TraceContextFromGin(c) req := UpdateTrailAppReq{} if err := c.BindJSON(&req); err != nil { log.Errorf("UpdateTrialApp bind err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_PARAM_ERR, gin.H{}) return } log.Infof("UpdateTrialApp req:%+v", req) userId := utility.GetUserId(c) if req.Id == "" || req.Type == "" || userId == "" { log.Errorf("UpdateTrialApp req:[%+v] or user id:[%s] err", req, userId) utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_PARAM_ERR, gin.H{}) return } svr := service.NewAppAppletInfoService() err := svr.UpdateTrialApp(traceCtx, userId, req.Id, req.Type, req.AppId) if err != nil { log.Errorf("UpdateTrialApp get info err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_PARAM_ERR, gin.H{}) return } utility.MakeLocRsp(c, http.StatusOK, utility.OK, gin.H{}) return } /** * @api {POST} /api/v1/mop/finstore/dev/trial/path-query [C/S]更新体验版小程序path * @apiGroup Finclip App Manager * @apiParam (RequestBody) {string} traceId //编译id * @apiParam (RequestBody) {string} pathAndQuery //path * @apiParamExample {json} Request-Example: * { * "traceId":"61b32654659d2b00016264a9", * "pathAndQuery":"abc" * } * @apiSuccessExample {json} Success Status: * HTTP/1.1 200 OK * { * "data": {}, * "errcode": "OK", * "error": "" * } * @apiErrorExample Error Status: * HTTP/1.1 !=200 服务端异常 */ func UpdateTrialAppPathAndQueryHand(c *gin.Context) { traceCtx := apm.ApmClient().TraceContextFromGin(c) req := apiproto.UpdateTrialAppPathReq{} if err := c.BindJSON(&req); err != nil { log.Errorf("UpdateTrialAppPathHand bind err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_PARAM_ERR, gin.H{}) return } log.Infof("UpdateTrialAppPathHand req:%+v", req) if req.TraceId == "" { log.Errorf("UpdateTrialAppPathHand trace id empty,req:%+v", req) utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_PARAM_ERR, gin.H{}) return } userId := utility.GetUserId(c) if userId == "" { log.Errorf("UpdateTrialAppPathHand user id empty,req:%+v", req) utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_PARAM_ERR, gin.H{}) return } svr := service.NewAppAppletInfoService() err := svr.UpdateTrialAppPathAndQueryHand(traceCtx, userId, req.TraceId, req.PathAndQuery) if err != nil { log.Errorf("GetTrialInfoById err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_PARAM_ERR, gin.H{}) return } utility.MakeLocRsp(c, http.StatusOK, utility.OK, gin.H{}) return } /** * @api {GET} /api/v1/mop/finstore/dev/trial/info?appId=61b32654659d2b00016264a8 [C/S]获取小程序体验版信息 * @apiGroup Finclip App Manager * @apiParam (RequestBody) {string} traceId //编译id * @apiParam (RequestBody) {string} pathAndQuery //path * @apiParamExample {json} Request-Example: * { * "traceId":"61b32654659d2b00016264a9", * "pathAndQuery":"abc" * } * @apiSuccessExample {json} Success Status: * HTTP/1.1 200 OK { "data": { "qrcodeHasRead":true, //二维码是否已读 "info":{ "id":"id", "buildInfoId":"编译id", "source":"build", //build:正常版本, trail:被设置为体验版 "appId":"61b32654659d2b00016264a8", "groupId":"企业id", "created":1660291974, //创建时间 "userId":"用户id", "createdBy":"创建人", "customData": { "detailDescription": "", "sourceFile": [ { "fileMd5": "159eed6c06432b1a4f68ced6c19a1bfe", "name": "app.zip", "sourceFileUrl": "/api/v1/mop/netdisk/download/62986eaa1f1afd0001c3698c", "uploadDate": 1654156973289, "url": "/api/v1/mop/netdisk/download/62986ead1f1afd0001c3698d", "encryptedUrl": "/api/v1/mop/netdisk/download/62986ead1f1afd0001c3698e", "encryptedFileMd5": "fad7bd98dbcabb560ca30f4c99121a42", "encryptedFileSha256": "c9e9db06725f95a4418c83d54dda3499946b8e1c894583b6477a36cc1d796668", "basicPackVer": "", "Packages": [], "EncryptPackages": [] } ], "versionDescription": "1.0.0", "developer": "15377373355" }, "version":"1.0.0", "startParams": { "pathAndQuery": "" }, "status":true } } "errcode": "OK", "error": "" } * @apiErrorExample Error Status: * HTTP/1.1 !=200 服务端异常 */ func GetTrialAppInfo(c *gin.Context) { traceCtx := apm.ApmClient().TraceContextFromGin(c) appId := c.Query("appId") log.Infof("GetTrialAppInfo app id:%+v", appId) userId := utility.GetUserId(c) if appId == "" || userId == "" { log.Errorf("GetTrialAppInfo appId:[%s] or userId:[%s] empty, err", appId, userId) utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_PARAM_ERR, gin.H{}) return } svr := service.NewAppAppletInfoService() rspData, err := svr.GetTrialAppInfo(traceCtx, userId, appId) if err != nil { log.Errorf("GetTrialInfoById err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_PARAM_ERR, gin.H{}) return } utility.MakeLocRsp(c, http.StatusOK, utility.OK, rspData) return } // GetBuildAppInfo 获取由编译列表衍生的小程序详情 //目前包括临时小程序、体验版小程序 func GetBuildAppInfo(c *gin.Context) { traceCtx := apm.ApmClient().TraceContextFromGin(c) req := apiproto.GetBuildAppInfoReq{} if err := c.BindJSON(&req); err != nil { log.Errorf("GetBuildAppInfo bind err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_PARAM_ERR, gin.H{}) return } sdkKey := utility.GetSdkKey(c) log.Infof("GetBuildAppInfo req:%+v,sdk key:%s", req, sdkKey) svr := service.NewAppService() appInfo, rsp := svr.GetBuildInfo(traceCtx, req, sdkKey) if appInfo == nil { rsp.MakeRsp(c, gin.H{}) } else { rsp.MakeRsp(c, appInfo) } return } func GetBuildInfoById(c *gin.Context) { traceCtx := apm.ApmClient().TraceContextFromGin(c) t := c.Query("type") codeId := c.Query("codeId") if codeId == "" { log.Errorf("GetBuildInfoById type or code id is empty,t:[%s],code id:[%s]", t, codeId) utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_PARAM_ERR, gin.H{}) return } svr := service.NewAppAppletInfoService() appInfo, err := svr.GetInfoById(traceCtx, codeId) if err != nil { log.Errorf("GetInfoById err:%s", err.Error()) if service.NotFound(err) { utility.MakeLocRsp(c, http.StatusNotFound, utility.FS_NOT_FOUND, gin.H{}) return } utility.MakeLocRsp(c, http.StatusInternalServerError, utility.FS_DB_ERR, gin.H{}) return } utility.MakeLocRsp(c, http.StatusOK, utility.OK, appInfo) return } func GetInfoByBuildInfoId(c *gin.Context) { traceCtx := apm.ApmClient().TraceContextFromGin(c) buildInfoId := c.Query("buildInfoId") if buildInfoId == "" { log.Errorf("GetBuildInfoById type or code id is empty:[%s]", buildInfoId) utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_PARAM_ERR, gin.H{}) return } svr := service.NewAppAppletInfoService() appInfo, err := svr.GetInfoByBuildInfoId(traceCtx, buildInfoId) if err != nil { log.Errorf("GetInfoById err:%s", err.Error()) if service.NotFound(err) { utility.MakeLocRsp(c, http.StatusNotFound, utility.FS_NOT_FOUND, gin.H{}) return } utility.MakeLocRsp(c, http.StatusInternalServerError, utility.FS_DB_ERR, gin.H{}) return } utility.MakeLocRsp(c, http.StatusOK, utility.OK, appInfo) return } func GetManageAppList(c *gin.Context) { traceCtx := apm.ApmClient().TraceContextFromGin(c) sdkKey := c.GetHeader(entity.SDKKEY_HEADER_KEY) userId := c.Query("userId") apiServer := c.Query("apiServer") log.Infof("GetManageAppList req sdkKey:[%s],userId:[%s]", sdkKey, userId) if sdkKey == "" || userId == "" || apiServer == "" { log.Errorf("GetManageAppList type or appid is nil !") utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_PARAM_ERR, gin.H{}) return } svr := service.NewAppAppletInfoService() rspData, rsp := svr.GetManageAppList(traceCtx, userId, sdkKey, apiServer) if rspData == nil { rsp.MakeRsp(c, gin.H{}) } else { rsp.MakeRsp(c, rspData) } return } func GetManageAppVerList(c *gin.Context) { traceCtx := apm.ApmClient().TraceContextFromGin(c) listType := c.Query("listType") appId := c.Query("appId") apiServer := c.Query("apiServer") log.Infof("GetManageAppVerList req appId:[%s],listType:[%s],apiServer:[%s]", appId, listType, apiServer) if listType == "" || appId == "" { log.Errorf("GetManageAppVerList type or appid is nil !") utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_PARAM_ERR, gin.H{}) return } svr := service.NewAppAppletInfoService() rspData, rsp := svr.GetManageAppVerList(traceCtx, listType, appId, apiServer) if rspData == nil { rsp.MakeRsp(c, gin.H{}) } else { rsp.MakeRsp(c, rspData) } return } func FixDevListStatus(c *gin.Context) { traceCtx := apm.ApmClient().TraceContextFromGin(c) svr := service.NewAppAppletInfoService() rsp := svr.FixDevListStatus(traceCtx) rsp.MakeRsp(c, gin.H{}) return } type GenOfflinePackageInfoHandReq struct { AppId string `json:"appId"` Sequence int `json:"seq"` } /** * @api {POST} /api/v1/mop/finstore/dev/package/offline [C/S]生成离线包下载信息 * @apiGroup Finclip App Manager * @apiParam (RequestBody) {string} appId //小程序id * @apiParam (RequestBody) {int} seq //小程序序列号 * @apiParamExample {json} Request-Example: * { * "appId":"61b32654659d2b00016264a8", * "seq": 1, * } * @apiSuccessExample {json} Success Status: * HTTP/1.1 200 OK * { * "data": { * "netdiskId":"61b32654659d2b00016264a9" //网盘id * }, * "errcode": "OK", * "error": "" * } * @apiErrorExample Error Status: * HTTP/1.1 !=200 服务端异常 */ //GenOfflinePackageInfoHand 离线包下载信息获取 func GenOfflinePackageInfoHand(c *gin.Context) { traceCtx := apm.ApmClient().TraceContextFromGin(c) userId := utility.GetUserId(c) if userId == "" { log.Errorf("user id empty") utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_PARAM_ERR, gin.H{}) return } req := GenOfflinePackageInfoHandReq{} if err := c.BindJSON(&req); err != nil { log.Errorf("GenOfflinePackageInfoHand bind err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_PARAM_ERR, gin.H{}) return } log.Infof("GenOfflinePackageInfoHand req:%v", req) svr := service.NewAppService() fileId, err := svr.GenOfflinePackageInfo(traceCtx, req.AppId, req.Sequence, userId) if err != nil { log.Errorf("app ver service gen offline package err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusInternalServerError, utility.FS_SERVER_ERR, gin.H{}) return } //todo test utility.MakeLocRsp(c, http.StatusOK, utility.OK, gin.H{"netdiskId": fileId}) } type GetBindingIdBySdkKeyHandReq struct { SdkKey string `form:"sdkKey"` AppId string `form:"appId"` OrganId string `form:"organId"` } func GetBindingIdBySdkKeyHand(c *gin.Context) { traceCtx := apm.ApmClient().TraceContextFromGin(c) req := GetBindingIdBySdkKeyHandReq{} if err := c.Bind(&req); err != nil { log.Errorf("GetBindingIdBySdkKeyHand bind err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_BAD_JSON, gin.H{}) return } if req.SdkKey == "" { log.Errorf("GetBindingIdBySdkKeyHand sdk key empty") utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_SDKKEY_NOT, gin.H{}) return } log.Debugf("GetBindingIdBySdkKeyHand sdkkey=%s, appId=%s", req.SdkKey, req.AppId) svr := service.NewBindingService() info, err := svr.GetBindInfoByParam(traceCtx, req.SdkKey, req.OrganId, req.AppId) if err != nil { log.Errorf("GetBindingIdBySdkKeyHand bind err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusInternalServerError, utility.FS_SERVICE_UNAVAILABLE, gin.H{}) return } rspData := gin.H{ "bindingId": info.BindingID, "owner": info.Owner, } utility.MakeLocRsp(c, http.StatusOK, utility.OK, rspData) return } func GetBindingInfoBySdkKeyHand(c *gin.Context) { traceCtx := apm.ApmClient().TraceContextFromGin(c) req := GetBindingIdBySdkKeyHandReq{} if err := c.ShouldBindJSON(&req); err != nil { log.Errorf("GetBindingInfoBySdkKeyHand ShouldBindJSON err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_BAD_JSON, make(map[string]interface{})) return } if req.SdkKey == "" { log.Errorf("GetBindingIdBySdkKeyHand sdk key empty") utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_SDKKEY_NOT, gin.H{}) return } log.Debugf("GetBindingIdBySdkKeyHand sdkkey=%s, appId=%s", req.SdkKey) svr := service.NewBindingService() info, err := svr.GetBindingBySdkKey(traceCtx, req.SdkKey) if err != nil { log.Errorf("GetBindingIdBySdkKeyHand bind err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusInternalServerError, utility.FS_SERVICE_UNAVAILABLE, gin.H{}) return } utility.MakeLocRsp(c, http.StatusOK, utility.OK, info) return }