package application import ( "finclip-app-manager/infrastructure/client/httpcall" "finclip-app-manager/infrastructure/utility" "net/http" "strings" "github.com/gin-gonic/gin" "gitlab.finogeeks.club/finclip-backend/apm" ) /** * @api {POST} /api/v1/mop/finstore/dev/wechat/info [C/S]生成离线包下载信息 * @apiGroup Finclip App Manager * @apiParam (RequestBody) {string} appId //小程序id * @apiParam (RequestBody) {string} wechatAppSecret //微信密钥 * @apiParam (RequestBody) {string} wechatAppId //微信appid * @apiParam (RequestBody) {string} wechatPath //微信访问path * @apiParam (RequestBody) {string} wechatSize //尺寸 * @apiParamExample {json} Request-Example: * { * "appId":"61b32654659d2b00016264a8", * "seq": 1, * "wechatAppSecret":"3534534" * "wechatAppId":"23345", * "wechatPath":"sfsgfd", * "wechatSize":"345" * } * @apiSuccessExample {json} Success Status: * HTTP/1.1 200 OK * { * "data": {}, * "errcode": "OK", * "error": "" * } * @apiErrorExample Error Status: * HTTP/1.1 !=200 服务端异常 */ func UpdateWechatInfo(c *gin.Context) { traceCtx := apm.ApmClient().TraceContextFromGin(c) req := httpcall.UpdateWechatInfoReq{} if err := c.ShouldBindJSON(&req); err != nil { log.Errorf("UpdateWechatInfo bind err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_BAD_JSON, nil) return } errCode, err := hCaller.UpsertWeChatInfo(traceCtx, req) if err != nil { utility.MakeLocRsp(c, http.StatusBadRequest, errCode, nil) return } utility.MakeLocRsp(c, http.StatusOK, utility.OK, nil) return } func ReadWechatHint(c *gin.Context) { traceCtx := apm.ApmClient().TraceContextFromGin(c) req := httpcall.ReadWechatHintoReq{} developerID := c.Request.Header.Get("X-Consumer-Custom-ID") if err := c.ShouldBindJSON(&req); err != nil { log.Errorf("ReadWechatHint bind err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_BAD_JSON, nil) return } req.DeveloperId = developerID err := hCaller.ReadWechatHint(traceCtx, req) if err != nil { utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_SERVER_ERR, nil) return } utility.MakeLocRsp(c, http.StatusOK, utility.OK, nil) return } func GetAppByWechat(c *gin.Context) { traceCtx := apm.ApmClient().TraceContextFromGin(c) qrcode := c.Query("qrcode") if strings.TrimSpace(qrcode) == "" { utility.MakeLocRsp(c, http.StatusOK, utility.OK, "") return } appId, err := hCaller.GetAppByWechat(traceCtx, qrcode) if err != nil { utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_SERVER_ERR, "") return } utility.MakeLocRsp(c, http.StatusOK, utility.OK, appId) return }