Merge branch 'main' of http://1.117.67.95:3000/team/tyapi-server
This commit is contained in:
@@ -310,7 +310,7 @@ func (s *ApiApplicationServiceImpl) validateApiCall(ctx context.Context, cmd *co
|
|||||||
s.logger.Warn("子账号主账号AccessId校验失败:未找到主从关系",
|
s.logger.Warn("子账号主账号AccessId校验失败:未找到主从关系",
|
||||||
zap.String("user_id", apiUser.UserId),
|
zap.String("user_id", apiUser.UserId),
|
||||||
zap.String("parent_access_id", parentAccessID))
|
zap.String("parent_access_id", parentAccessID))
|
||||||
return nil, ErrQueryFailed
|
return nil, ErrSubordinateLinkNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
parentApiUser, err := s.apiUserService.LoadApiUserByUserId(ctx, link.ParentUserID)
|
parentApiUser, err := s.apiUserService.LoadApiUserByUserId(ctx, link.ParentUserID)
|
||||||
@@ -326,7 +326,7 @@ func (s *ApiApplicationServiceImpl) validateApiCall(ctx context.Context, cmd *co
|
|||||||
zap.String("child_user_id", apiUser.UserId),
|
zap.String("child_user_id", apiUser.UserId),
|
||||||
zap.String("parent_user_id", link.ParentUserID),
|
zap.String("parent_user_id", link.ParentUserID),
|
||||||
zap.String("parent_access_id", parentAccessID))
|
zap.String("parent_access_id", parentAccessID))
|
||||||
return nil, ErrQueryFailed
|
return nil, ErrSubordinateParentMismatch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.SetRequestParams(paramsMap)
|
result.SetRequestParams(paramsMap)
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ var (
|
|||||||
ErrProductNotSubscribed = errors.New("未订阅此产品")
|
ErrProductNotSubscribed = errors.New("未订阅此产品")
|
||||||
ErrSubscriptionExpired = errors.New("订阅已过期")
|
ErrSubscriptionExpired = errors.New("订阅已过期")
|
||||||
ErrSubscriptionSuspended = errors.New("订阅已暂停")
|
ErrSubscriptionSuspended = errors.New("订阅已暂停")
|
||||||
ErrBusiness = errors.New("业务失败")
|
ErrBusiness = errors.New("业务失败")
|
||||||
|
ErrSubordinateLinkNotFound = errors.New("非子账号,无法使用master_accessid")
|
||||||
|
ErrSubordinateParentMismatch = errors.New("master_accessid与主账号不匹配")
|
||||||
)
|
)
|
||||||
|
|
||||||
// 错误码映射 - 严格按照用户要求
|
// 错误码映射 - 严格按照用户要求
|
||||||
@@ -45,7 +47,9 @@ var ErrorCodeMap = map[error]int{
|
|||||||
ErrProductNotSubscribed: 1008,
|
ErrProductNotSubscribed: 1008,
|
||||||
ErrSubscriptionExpired: 1008,
|
ErrSubscriptionExpired: 1008,
|
||||||
ErrSubscriptionSuspended: 1008,
|
ErrSubscriptionSuspended: 1008,
|
||||||
ErrBusiness: 2001,
|
ErrBusiness: 2001,
|
||||||
|
ErrSubordinateLinkNotFound: 1301,
|
||||||
|
ErrSubordinateParentMismatch: 1302,
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetErrorCode 获取错误对应的错误码
|
// GetErrorCode 获取错误对应的错误码
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ type SubPortalRegisterCommand struct {
|
|||||||
// CreateInvitationCommand 主账号创建邀请
|
// CreateInvitationCommand 主账号创建邀请
|
||||||
type CreateInvitationCommand struct {
|
type CreateInvitationCommand struct {
|
||||||
ParentUserID string
|
ParentUserID string
|
||||||
// ExpiresInHours 可选,0 用默认 168 小时
|
// ExpiresInHours 可选,0 或不传为永久有效(100年)
|
||||||
ExpiresInHours int `json:"expires_in_hours"`
|
ExpiresInHours int `json:"expires_in_hours"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,8 @@ func (s *SubordinateApplicationServiceImpl) RegisterSubPortal(ctx context.Contex
|
|||||||
func (s *SubordinateApplicationServiceImpl) CreateInvitation(ctx context.Context, cmd *commands.CreateInvitationCommand) (*responses.CreateInvitationResponse, error) {
|
func (s *SubordinateApplicationServiceImpl) CreateInvitation(ctx context.Context, cmd *commands.CreateInvitationCommand) (*responses.CreateInvitationResponse, error) {
|
||||||
hours := cmd.ExpiresInHours
|
hours := cmd.ExpiresInHours
|
||||||
if hours <= 0 {
|
if hours <= 0 {
|
||||||
hours = 24 * 7
|
// 永久有效:设置100年后过期
|
||||||
|
hours = 24 * 365 * 100
|
||||||
}
|
}
|
||||||
raw, hash, err := GenerateInviteToken()
|
raw, hash, err := GenerateInviteToken()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user