feat(main): fix url

This commit is contained in:
2025-02-18 15:23:26 +08:00
parent 761796bd35
commit 6a5eab11ea
12 changed files with 616 additions and 53 deletions

View File

@@ -0,0 +1,48 @@
package agent
import (
"context"
"database/sql"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"qnc-server/common/ctxdata"
"qnc-server/common/xerr"
"qnc-server/app/user/cmd/api/internal/svc"
"qnc-server/app/user/cmd/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type GetAgentInfoLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetAgentInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAgentInfoLogic {
return &GetAgentInfoLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *GetAgentInfoLogic) GetAgentInfo() (resp *types.AgentInfoResp, err error) {
userID, err := ctxdata.GetUidFromCtx(l.ctx)
if err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取代理信息, %+v", err)
}
agent, err := l.svcCtx.AgentModel.FindOneByUserId(l.ctx, userID)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
return &types.AgentInfoResp{
IsAgent: false,
}, nil
}
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "获取代理信息, %+v", err)
}
copier.Copy(&resp, agent)
resp.IsAgent = true
return resp, nil
}