| 123456789101112131415161718192021222324252627282930313233343536373839 |
- // Code scaffolded by goctl. Safe to edit.
- // goctl 1.10.1
- package pub
- import (
- "context"
- "perms-system-server/internal/svc"
- "perms-system-server/internal/types"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type CapEndpointLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- func NewCapEndpointLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CapEndpointLogic {
- return &CapEndpointLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
- // CapEndpoint 返回 cap.js 服务的完整验证端点 URL。
- // 未配置或 Enable != 1 时返回空 Data,前端据此降级为图片验证码。
- func (l *CapEndpointLogic) CapEndpoint() (*types.CapEndpointResp, error) {
- cfg := l.svcCtx.Config.Capjs
- if cfg.Enable != 1 || cfg.EndpointURL == "" || cfg.Key == "" {
- return &types.CapEndpointResp{Code: 0, Msg: "success", Data: ""}, nil
- }
- url := cfg.EndpointURL + "/" + cfg.Key + "/"
- return &types.CapEndpointResp{Code: 0, Msg: "success", Data: url}, nil
- }
|