add wxmini

This commit is contained in:
2025-06-24 00:11:19 +08:00
parent b0e47d1658
commit 06eb69b39f
19 changed files with 508 additions and 30 deletions

View File

@@ -0,0 +1,36 @@
package agent
import (
"net/http"
"tydata-server/app/main/api/internal/logic/agent"
"tydata-server/app/main/api/internal/svc"
"tydata-server/app/main/api/internal/types"
"tydata-server/common/result"
"tydata-server/pkg/lzkit/validator"
"github.com/zeromicro/go-zero/rest/httpx"
)
func GetAgentPromotionQrcodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetAgentPromotionQrcodeReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
if err := validator.Validate(req); err != nil {
result.ParamValidateErrorResult(r, w, err)
return
}
// 注意:这里传入了 ResponseWriter用于直接写入图片数据
l := agent.NewGetAgentPromotionQrcodeLogic(r.Context(), svcCtx, w)
err := l.GetAgentPromotionQrcode(&req)
if err != nil {
// 如果处理过程中出错返回JSON错误响应
result.HttpResult(r, w, nil, err)
}
// 成功时图片数据已经通过logic直接写入ResponseWriter不需要额外处理
}
}

View File

@@ -514,6 +514,17 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
rest.WithPrefix("/api/v1/admin/user"),
)
server.AddRoutes(
[]rest.Route{
{
Method: http.MethodGet,
Path: "/promotion/qrcode",
Handler: agent.GetAgentPromotionQrcodeHandler(serverCtx),
},
},
rest.WithPrefix("/api/v1/agent"),
)
server.AddRoutes(
[]rest.Route{
{