feat: GetProfileByUsername implemented
This commit is contained in:
@@ -22,8 +22,10 @@ import (
|
||||
"easywish/internal/dto"
|
||||
errs "easywish/internal/errors"
|
||||
mapspecial "easywish/internal/utils/mapSpecial"
|
||||
"errors"
|
||||
|
||||
"github.com/go-redis/redis/v8"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -63,8 +65,32 @@ func (p *profileServiceImpl) GetMyProfile(cinfo dto.ClientInfo) (*dto.ProfileDto
|
||||
return &profileDto, nil
|
||||
}
|
||||
|
||||
// TODO: Profile privacy settings checks
|
||||
func (p *profileServiceImpl) GetProfileByUsername(cinfo dto.ClientInfo, username string) (*dto.ProfileDto, error) {
|
||||
panic("unimplemented")
|
||||
helper, db, err := database.NewDbHelperTransaction(p.dbctx); if err != nil {
|
||||
p.log.Error(
|
||||
"Failed to start transaction",
|
||||
zap.Error(err))
|
||||
return nil, errs.ErrServerError
|
||||
}
|
||||
defer helper.Rollback()
|
||||
|
||||
profile, err := db.TXQueries.GetProfileByUsername(db.CTX, username); if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return nil, errs.ErrNotFound
|
||||
}
|
||||
|
||||
p.log.Error(
|
||||
"Failed to get user profile by username",
|
||||
zap.String("username", username),
|
||||
zap.Error(err))
|
||||
return nil, errs.ErrServerError
|
||||
}
|
||||
|
||||
var profileDto dto.ProfileDto
|
||||
mapspecial.MapProfileDto(profile, profileDto)
|
||||
|
||||
return &profileDto, nil
|
||||
}
|
||||
|
||||
func (p *profileServiceImpl) GetProfileSettings(cinfo dto.ClientInfo) (*dto.ProfileSettingsDto, error) {
|
||||
|
||||
Reference in New Issue
Block a user