chore: stabilize lint and verify builds

This commit is contained in:
2026-02-06 11:51:32 +08:00
parent edede17880
commit 1782f64417
114 changed files with 3032 additions and 1345 deletions

View File

@@ -33,6 +33,7 @@ func (s *tenant) ApplyJoin(ctx context.Context, tenantID, userID int64, form *te
if errors.Is(err, gorm.ErrRecordNotFound) {
return errorx.ErrRecordNotFound.WithMsg("租户不存在")
}
return errorx.ErrDatabaseError.WithCause(err)
}
if tenant.Status != consts.TenantStatusVerified {
@@ -83,6 +84,7 @@ func (s *tenant) ApplyJoin(ctx context.Context, tenantID, userID int64, form *te
if err := qReq.Create(req); err != nil {
return errorx.ErrDatabaseError.WithCause(err)
}
return nil
}
@@ -104,12 +106,14 @@ func (s *tenant) CancelJoin(ctx context.Context, tenantID, userID int64) error {
if errors.Is(err, gorm.ErrRecordNotFound) {
return errorx.ErrRecordNotFound.WithMsg("申请不存在")
}
return errorx.ErrDatabaseError.WithCause(err)
}
if _, err := qReq.Where(tblReq.ID.Eq(req.ID)).Delete(); err != nil {
return errorx.ErrDatabaseError.WithCause(err)
}
return nil
}
@@ -142,6 +146,7 @@ func (s *tenant) ReviewJoin(
if errors.Is(err, gorm.ErrRecordNotFound) {
return errorx.ErrRecordNotFound.WithMsg("申请不存在")
}
return errorx.ErrDatabaseError.WithCause(err)
}
if req.TenantID != tenantID {
@@ -167,6 +172,7 @@ func (s *tenant) ReviewJoin(
if err != nil {
return errorx.ErrDatabaseError.WithCause(err)
}
return nil
}
@@ -207,6 +213,7 @@ func (s *tenant) ReviewJoin(
if err != nil {
return errorx.ErrDatabaseError.WithCause(err)
}
return nil
})
}
@@ -260,6 +267,7 @@ func (s *tenant) CreateInvite(
if err := models.TenantInviteQuery.WithContext(ctx).Create(invite); err != nil {
return nil, errorx.ErrDatabaseError.WithCause(err)
}
return s.toTenantInviteItem(invite), nil
}
@@ -288,6 +296,7 @@ func (s *tenant) AcceptInvite(ctx context.Context, tenantID, userID int64, form
if errors.Is(err, gorm.ErrRecordNotFound) {
return errorx.ErrRecordNotFound.WithMsg("邀请码无效")
}
return errorx.ErrDatabaseError.WithCause(err)
}
@@ -301,6 +310,7 @@ func (s *tenant) AcceptInvite(ctx context.Context, tenantID, userID int64, form
if err != nil {
return errorx.ErrDatabaseError.WithCause(err)
}
return errorx.ErrBadRequest.WithMsg("邀请码已过期")
}
if invite.UsedCount >= invite.MaxUses {
@@ -335,6 +345,7 @@ func (s *tenant) AcceptInvite(ctx context.Context, tenantID, userID int64, form
if err != nil {
return errorx.ErrDatabaseError.WithCause(err)
}
return nil
})
}
@@ -620,6 +631,7 @@ func (s *tenant) DisableInvite(ctx context.Context, tenantID, operatorID, invite
if errors.Is(err, gorm.ErrRecordNotFound) {
return errorx.ErrRecordNotFound.WithMsg("邀请记录不存在")
}
return errorx.ErrDatabaseError.WithCause(err)
}
if invite.TenantID != tenantID {
@@ -641,6 +653,7 @@ func (s *tenant) DisableInvite(ctx context.Context, tenantID, operatorID, invite
if err != nil {
return errorx.ErrDatabaseError.WithCause(err)
}
return nil
}
@@ -664,6 +677,7 @@ func (s *tenant) RemoveMember(ctx context.Context, tenantID, operatorID, memberI
if errors.Is(err, gorm.ErrRecordNotFound) {
return errorx.ErrRecordNotFound.WithMsg("成员不存在")
}
return errorx.ErrDatabaseError.WithCause(err)
}
if member.TenantID != tenantID {
@@ -676,6 +690,7 @@ func (s *tenant) RemoveMember(ctx context.Context, tenantID, operatorID, memberI
if _, err := q.Where(tbl.ID.Eq(member.ID)).Delete(); err != nil {
return errorx.ErrDatabaseError.WithCause(err)
}
return nil
}
@@ -690,6 +705,7 @@ func (s *tenant) ensureTenantAdmin(ctx context.Context, tenantID, userID int64)
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, errorx.ErrRecordNotFound.WithMsg("租户不存在")
}
return nil, errorx.ErrDatabaseError.WithCause(err)
}
if tenant.UserID == userID {
@@ -710,6 +726,7 @@ func (s *tenant) ensureTenantAdmin(ctx context.Context, tenantID, userID int64)
if !exists {
return nil, errorx.ErrPermissionDenied.WithMsg("无权限操作该租户")
}
return tenant, nil
}
@@ -725,6 +742,7 @@ func (s *tenant) normalizeInviteExpiry(form *tenant_dto.TenantInviteCreateForm)
if expireAt.Before(time.Now()) {
return time.Time{}, errorx.ErrBadRequest.WithMsg("过期时间不能早于当前时间")
}
return expireAt, nil
}
@@ -741,6 +759,7 @@ func (s *tenant) newInviteCode(ctx context.Context) (string, error) {
return code, nil
}
}
return "", errorx.ErrInternalError.WithMsg("生成邀请码失败")
}
@@ -756,6 +775,7 @@ func (s *tenant) toTenantInviteItem(invite *models.TenantInvite) *tenant_dto.Ten
if !invite.CreatedAt.IsZero() {
createdAt = invite.CreatedAt.Format(time.RFC3339)
}
return &tenant_dto.TenantInviteItem{
ID: invite.ID,
Code: invite.Code,
@@ -772,6 +792,7 @@ func (s *tenant) toTenantMemberUserLite(user *models.User) *tenant_dto.TenantMem
if user == nil {
return nil
}
return &tenant_dto.TenantMemberUserLite{
ID: user.ID,
Username: user.Username,
@@ -795,6 +816,7 @@ func (s *tenant) loadUserMap(ctx context.Context, userIDs []int64) (map[int64]*m
for _, user := range users {
userMap[user.ID] = user
}
return userMap, nil
}
@@ -819,6 +841,7 @@ func (s *tenant) lookupUserIDs(ctx context.Context, keyword *string) ([]int64, b
for _, user := range users {
ids = append(ids, user.ID)
}
return ids, true, nil
}
@@ -826,5 +849,6 @@ func (s *tenant) formatTime(t time.Time) string {
if t.IsZero() {
return ""
}
return t.Format(time.RFC3339)
}