Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
SShlykov committed Mar 25, 2024
1 parent f6daae1 commit 3b363c2
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
4 changes: 4 additions & 0 deletions auth/internal/domain/services/user/0_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ type Service struct {
repo Repository
}

const (
StatusError = "error"
)

func NewService(repository Repository) *Service {
return &Service{repo: repository}
}
Expand Down
4 changes: 2 additions & 2 deletions auth/internal/domain/services/user/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ func (uss *Service) Find(ctx context.Context, in *user_v1.ListUsersRequest) (*us

if in.Options.Pagination.Page > meta.TotalPages {
status.Message = "Запрашиваемая страница не существует"
status.Status = "error"
status.Status = StatusError

return resp, nil
}

users, err := uss.repo.List(ctx, dbutils.NewPaginationWithLimitOffset(meta.Page, meta.PageSize))
if err != nil {
status.Message = "Пользователи не найдены"
status.Status = "error"
status.Status = StatusError

return resp, nil
}
Expand Down
2 changes: 1 addition & 1 deletion auth/internal/domain/services/user/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func (uss *Service) Get(ctx context.Context, in *user_v1.GetUserRequest) (*user_

if err != nil {
status.Message = "Пользователь не найден"
status.Status = "error"
status.Status = StatusError

return resp, nil
}
Expand Down
2 changes: 1 addition & 1 deletion auth/internal/domain/services/user/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func (uss *Service) Update(ctx context.Context, in *user_v1.UpdateUserRequest) (

if err != nil {
status.Message = "Пользователь не найден"
status.Status = "error"
status.Status = StatusError

return resp, nil
}
Expand Down
22 changes: 11 additions & 11 deletions auth/internal/models/adapters/user_entity_proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ func UserProtoToEntity(u *user_v1.User) *entity.User {
ID: u.Id,
CreatedAt: ProtoToDt(u.CreatedAt),
UpdatedAt: ProtoToDt(u.UpdatedAt),
DeletedAt: ProtoToSqlDt(u.DeletedAt),
LoggedAt: ProtoToSqlDt(u.LoggedAt),
ConfirmedAt: ProtoToSqlDt(u.ConfirmedAt),
DeletedAt: ProtoToSQLDt(u.DeletedAt),
LoggedAt: ProtoToSQLDt(u.LoggedAt),
ConfirmedAt: ProtoToSQLDt(u.ConfirmedAt),

Login: u.Login,
Email: ProtoToSqlString(u.Email),
Email: ProtoToSQLString(u.Email),

DeletedBy: ProtoToSqlString(u.DeletedBy),
AccessTemplateID: ProtoToSqlInt(u.AccessTemplateId),
UpdateAfter: ProtoToSqlInt64(u.UpdateAfter),
DeletedBy: ProtoToSQLString(u.DeletedBy),
AccessTemplateID: ProtoToSQLInt(u.AccessTemplateId),
UpdateAfter: ProtoToSQLInt64(u.UpdateAfter),
}
}

Expand All @@ -61,28 +61,28 @@ func UserEntityToProto(u *entity.User) *user_v1.User {
}
}

func ProtoToSqlString(str *wrapperspb.StringValue) sql.Null[string] {
func ProtoToSQLString(str *wrapperspb.StringValue) sql.Null[string] {
if str != nil {
return sql.Null[string]{Valid: true, V: str.Value}
}
return sql.Null[string]{Valid: false}
}

func ProtoToSqlDt(dt *timestamppb.Timestamp) sql.Null[time.Time] {
func ProtoToSQLDt(dt *timestamppb.Timestamp) sql.Null[time.Time] {
if dt != nil {
return sql.Null[time.Time]{Valid: true, V: dt.AsTime()}
}
return sql.Null[time.Time]{Valid: false}
}

func ProtoToSqlInt(i *wrapperspb.Int32Value) sql.Null[int] {
func ProtoToSQLInt(i *wrapperspb.Int32Value) sql.Null[int] {
if i != nil {
return sql.Null[int]{Valid: true, V: int(i.Value)}
}
return sql.Null[int]{Valid: false}
}

func ProtoToSqlInt64(i *wrapperspb.Int64Value) sql.Null[int64] {
func ProtoToSQLInt64(i *wrapperspb.Int64Value) sql.Null[int64] {
if i != nil {
return sql.Null[int64]{Valid: true, V: i.Value}
}
Expand Down

0 comments on commit 3b363c2

Please sign in to comment.