This commit is contained in:
Mrx
2026-02-09 10:58:32 +08:00
parent e96adc9f98
commit ad809f6f8b
32 changed files with 1875 additions and 1781 deletions

View File

@@ -0,0 +1,50 @@
package agent
import (
"net/http"
"strings"
"ycc-server/app/main/api/internal/logic/agent"
"ycc-server/app/main/api/internal/svc"
"ycc-server/app/main/api/internal/types"
"ycc-server/common/result"
"ycc-server/pkg/lzkit/validator"
"github.com/zeromicro/go-zero/rest/httpx"
)
func GetInvitePosterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetInvitePosterReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
req.Format = strings.TrimSpace(strings.ToLower(req.Format))
if err := validator.Validate(req); err != nil {
result.ParamValidateErrorResult(r, w, err)
return
}
l := agent.NewGetInvitePosterLogic(r.Context(), svcCtx)
if req.Format == "base64" {
base64Str, err := l.GetInvitePosterBase64(&req)
if err != nil {
result.HttpResult(r, w, nil, err)
return
}
result.HttpResult(r, w, &types.GetInvitePosterResp{PosterBase64: base64Str}, nil)
return
}
pngBytes, err := l.GetInvitePoster(&req)
if err != nil {
result.HttpResult(r, w, nil, err)
return
}
w.Header().Set("Content-Type", "image/png")
w.WriteHeader(http.StatusOK)
_, _ = w.Write(pngBytes)
}
}

View File

@@ -690,6 +690,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/info",
Handler: agent.GetAgentInfoHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/invite/poster",
Handler: agent.GetInvitePosterHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/invite_code/delete",